Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added bash completion for Ubuntu and Debian - others untested #581

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ The following parameters are available in the `consul` class:
* [`acl_api_token`](#-consul--acl_api_token)
* [`arch`](#-consul--arch)
* [`archive_path`](#-consul--archive_path)
* [`bash_completion`](#-consul--bash_completion)
* [`bash_completion_compat_dir`](#-consul--bash_completion_compat_dir)
* [`bin_dir`](#-consul--bin_dir)
* [`binary_group`](#-consul--binary_group)
* [`binary_mode`](#-consul--binary_mode)
Expand Down Expand Up @@ -206,6 +208,22 @@ Path used when installing consul via the url

Default value: `undef`

##### <a name="-consul--bash_completion"></a>`bash_completion`

Data type: `Boolean`

Whether to setup bash completion. Adjust bin_dir when install_method == package.

Default value: `$consul::params::bash_completion`

##### <a name="-consul--bash_completion_compat_dir"></a>`bash_completion_compat_dir`

Data type: `String[1]`

Directory to place bash-completion file for Consul into.

Default value: `'/etc/bash_completion.d/'`

##### <a name="-consul--bin_dir"></a>`bin_dir`

Data type: `Stdlib::Absolutepath`
Expand Down
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# @param acl_api_token Global token of ACL API, will be merged with consul_token resources
# @param arch Architecture of consul binary to download
# @param archive_path Path used when installing consul via the url
# @param bash_completion Whether to setup bash completion. Adjust bin_dir when install_method == package.
# @param bash_completion_compat_dir Directory to place bash-completion file for Consul into.
# @param bin_dir Directory to create the symlink to the consul binary in.
# @param binary_group The group that the file belongs to.
# @param binary_mode Permissions mode for the file.
Expand Down Expand Up @@ -95,6 +97,8 @@
String[0] $acl_api_token = '', # lint:ignore:params_empty_string_assignment
String[1] $arch = $consul::params::arch,
Optional[Stdlib::Absolutepath] $archive_path = undef,
Boolean $bash_completion = $consul::params::bash_completion,
String[1] $bash_completion_compat_dir = '/etc/bash_completion.d/',
Stdlib::Absolutepath $bin_dir = $consul::params::bin_dir,
Optional[String[1]] $binary_group = $consul::params::binary_group,
String[1] $binary_mode = $consul::params::binary_mode,
Expand Down
14 changes: 14 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,18 @@
system => true,
}
}

if ($consul::bash_completion) and ($consul::install_method != 'docker' ) {
file { $consul::bash_completion_compat_dir:
ensure => 'directory',
}

file { "${consul::bash_completion_compat_dir}/consul":
ensure => file,
owner => 'root',
group => 'root',
mode => '0644',
content => "complete -C ${consul::bin_dir}/${consul::binary_name} consul\n",
}
}
}
7 changes: 7 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,31 @@

case $facts['os']['name'] {
'Ubuntu': {
$bash_completion = true
$shell = '/usr/sbin/nologin'
}
'RedHat': {
$bash_completion = false
$shell = '/sbin/nologin'
}
'Debian': {
$bash_completion = true
$shell = '/usr/sbin/nologin'
}
'Archlinux': {
$bash_completion = false
$shell = '/sbin/nologin'
}
'OpenSuSE': {
$bash_completion = false
$shell = '/usr/sbin/nologin'
}
/SLE[SD]/: {
$bash_completion = false
$shell = '/usr/sbin/nologin'
}
default: {
$bash_completion = false
$shell = undef
}
}
Expand Down