From 7600038e543dc28ebcef6cc5fc3f9782789459e9 Mon Sep 17 00:00:00 2001 From: Bartek Grzybowski Date: Tue, 16 Nov 2021 11:21:41 +0100 Subject: [ANSIBLE] Setup cmctl autocompletion Bash autocompletion code is generated to facilitate autocompletion for cmctl command. Change-Id: I03494293bf91aada54af70f6e0fd2c49e2feea64 Issue-ID: OOM-2871 Signed-off-by: Bartek Grzybowski --- ansible/roles/cert-manager/defaults/main.yml | 2 ++ ansible/roles/cert-manager/tasks/main.yml | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) (limited to 'ansible/roles/cert-manager') diff --git a/ansible/roles/cert-manager/defaults/main.yml b/ansible/roles/cert-manager/defaults/main.yml index aa59c240..81a66f4e 100644 --- a/ansible/roles/cert-manager/defaults/main.yml +++ b/ansible/roles/cert-manager/defaults/main.yml @@ -7,3 +7,5 @@ cert_manager: helm_values: installCRDs: true cmctl_bin_dir: /usr/local/bin +completion_dir: /etc/bash_completion.d +completion_package: bash-completion diff --git a/ansible/roles/cert-manager/tasks/main.yml b/ansible/roles/cert-manager/tasks/main.yml index 9bf7fde3..77063655 100644 --- a/ansible/roles/cert-manager/tasks/main.yml +++ b/ansible/roles/cert-manager/tasks/main.yml @@ -29,3 +29,25 @@ - 'cmctl' remote_src: true mode: 0755 + +- name: Install completion for the bash shell + package: + name: "{{ completion_package }}" + state: present + +- name: Generate shell autocompletion code for cmctl + command: cmctl completion bash + register: cmctl_completion + changed_when: false + +- name: Ensure bash completion dir exists + file: + path: "{{ completion_dir }}" + state: directory + mode: 0755 + +- name: Install bash autocompletion code for cmctl + copy: + content: "{{ cmctl_completion.stdout }}" + dest: "{{ completion_dir }}/cmctl" + mode: 0644 -- cgit 1.2.3-korg