Skip to content

Commit

Permalink
added bash completion for Ubuntu and Debian
Browse files Browse the repository at this point in the history
  • Loading branch information
jardleex committed Jun 1, 2023
1 parent d427176 commit 269d61f
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
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: `$consul::params::bash_completion_compat_dir`

##### <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 = $consul::params::bash_completion_compat_dir,
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",
}
}
}
4 changes: 4 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
default: {
# 0 instead of root because OS X uses "wheel".
$data_dir_mode = '0755'
$bash_completion_compat_dir = '/etc/bash_completion.d/'
$binary_group = '0'
$binary_mode = '0555'
$binary_name = 'consul'
Expand All @@ -63,12 +64,14 @@

case $facts['os']['name'] {
'Ubuntu': {
$bash_completion = true
$shell = '/usr/sbin/nologin'
}
'RedHat': {
$shell = '/sbin/nologin'
}
'Debian': {
$bash_completion = true
$shell = '/usr/sbin/nologin'
}
'Archlinux': {
Expand All @@ -81,6 +84,7 @@
$shell = '/usr/sbin/nologin'
}
default: {
$bash_completion = false
$shell = undef
}
}
Expand Down

0 comments on commit 269d61f

Please sign in to comment.