--- /dev/null
+---
+extends: default
+
+rules:
+ braces:
+ max-spaces-inside: 1
+ level: error
+ brackets:
+ max-spaces-inside: 1
+ level: error
+ line-length: disable
+ truthy: disable
--- /dev/null
+Role to install bash-completion
+===============================
+
+Role that installs the bash-completion package and generates the completion code for binary which name is passed via role parameter.
+
+Requirements
+------------
+
+For the role to operate properly it is expected that the binary for which the completion code is generated supports "completion bash" option.
+
+Role Variables
+--------------
+
+- completion\_bin (role's parameter) - name of the binary for which the completion code will be generated
+
--- /dev/null
+---
+completion_dir: /etc/bash_completion.d
+completion_package: bash-completion
--- /dev/null
+---
+- name: Converge
+ hosts: all
+ tasks:
+ - name: "Include bash-completion"
+ include_role:
+ name: "bash-completion"
--- /dev/null
+---
+dependency:
+ name: galaxy
+driver:
+ name: docker
+lint: |
+ set -e
+ yamllint .
+ ansible-lint .
+ flake8
+platforms:
+ - name: bash-completion
+ image: centos:7
+provisioner:
+ name: ansible
+ env:
+ ANSIBLE_ROLES_PATH: ../../../../test/roles
+ ANSIBLE_LIBRARY: ../../../../library
+ inventory:
+ group_vars:
+ all:
+ kubectl_install: true
+ completion_bin: kubectl
+verifier:
+ name: testinfra
--- /dev/null
+---
+- name: Prepare
+ hosts: all
+ roles:
+ # This role is played in prepare stage only to install kubectl which will be
+ # used as a binary to test the bash-completion role
+ - prepare-kubectl
--- /dev/null
+def test_bash_completion(host):
+ assert host.package("bash-completion").is_installed
+
+
+def test_bash_completion_kubectl(host):
+ f = host.file('/etc/bash_completion.d/kubectl')
+ assert f.exists
--- /dev/null
+---
+- name: Install completion for the bash shell
+ package:
+ name: "{{ completion_package }}"
+ state: present
+
+- name: Ensure bash completion dir exists
+ file:
+ path: "{{ completion_dir }}"
+ state: directory
+ mode: 0755
+
+- name: Generate shell autocompletion code for {{ completion_bin }}
+ command: "{{ completion_bin }} completion bash"
+ register: bash_completion
+ changed_when: false
+
+- name: Install bash autocompletion code for {{ completion_bin }}
+ copy:
+ content: "{{ bash_completion.stdout }}"
+ dest: "{{ completion_dir }}/{{ completion_bin }}"
+ mode: 0644