summaryrefslogtreecommitdiffstats
path: root/ansible/roles/kubectl/tasks
diff options
context:
space:
mode:
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-09-15 16:51:24 +0200
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-09-17 10:27:42 +0200
commite2b009b1c28575e34904b9f2275ced1c4ec06fec (patch)
treecc811af84d704a048605226fb4f7bf973c463a3f /ansible/roles/kubectl/tasks
parentf6c503b35aa9f999b0cff39bb305308e03afb80a (diff)
Add feature to install shell autocompletion for kubectl
Change-Id: I732dcd92144f9a8489a351047ab88b53ca36759e Issue-ID: OOM-2564 Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
Diffstat (limited to 'ansible/roles/kubectl/tasks')
-rw-r--r--ansible/roles/kubectl/tasks/main.yml22
1 files changed, 22 insertions, 0 deletions
diff --git a/ansible/roles/kubectl/tasks/main.yml b/ansible/roles/kubectl/tasks/main.yml
index 7c77c3c5..03b9f9b0 100644
--- a/ansible/roles/kubectl/tasks/main.yml
+++ b/ansible/roles/kubectl/tasks/main.yml
@@ -5,3 +5,25 @@
dest: "{{ kubectl_bin_dir }}/kubectl"
remote_src: true
mode: 0755
+
+- name: Install completion for the bash shell
+ package:
+ name: "{{ completion_package }}"
+ state: present
+
+- name: Generate shell autocompletion code for kubectl
+ command: kubectl completion bash
+ register: kubectl_completion
+ changed_when: false
+
+- name: Ensure bash completion dir exists
+ file:
+ path: "{{ completion_dir }}"
+ state: directory
+ mode: 0755
+
+- name: Install bash autocompletion code for kubectl
+ copy:
+ content: "{{ kubectl_completion.stdout }}"
+ dest: "{{ completion_dir }}/kubectl"
+ mode: 0644