From 89a45f210534031451f8fb1382954bbf9286a9c2 Mon Sep 17 00:00:00 2001 From: Varac <varac@varac.net> Date: Tue, 12 Mar 2019 16:29:55 +0100 Subject: [PATCH] Bash completion for kubectl and helm Closes: #79 --- ansible/roles/get_control/files/bashrc_oas | 9 +++++ ansible/roles/get_control/tasks/main.yml | 45 +++++++++++++++++----- 2 files changed, 44 insertions(+), 10 deletions(-) create mode 100644 ansible/roles/get_control/files/bashrc_oas diff --git a/ansible/roles/get_control/files/bashrc_oas b/ansible/roles/get_control/files/bashrc_oas new file mode 100644 index 000000000..fa73f8f60 --- /dev/null +++ b/ansible/roles/get_control/files/bashrc_oas @@ -0,0 +1,9 @@ +# Bashrc additions for Openappstack +# This file is sourced from .bashrc + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +if [ -f /etc/bash_completion ] && ! shopt -oq posix; then + . /etc/bash_completion +fi diff --git a/ansible/roles/get_control/tasks/main.yml b/ansible/roles/get_control/tasks/main.yml index a7917a8bf..28a06d7a3 100644 --- a/ansible/roles/get_control/tasks/main.yml +++ b/ansible/roles/get_control/tasks/main.yml @@ -41,19 +41,44 @@ content: "{{ ip_address }}" dest: "{{ configuration_directory }}/ip" -- name: Remove old files from previous deploys - file: - path: '{{ item }}' - state: absent - with_items: - - '/root/.bashrc_oas' - - '/root/.bash_aliases_oas' - become: true +- name: Install bash-completion + tags: + - bash + - completion + package: + name: "bash-completion" + +- name: Add kubectl bash kompletion + tags: + - bash + - kubectl + - completion + shell: kubectl completion bash > /etc/bash_completion.d/kubectl + args: + creates: /etc/bash_completion.d/kubectl -- name: Restore original .bashrc +- name: Add helm bash kompletion + tags: + - bash + - helm + - completion + shell: helm completion bash > /etc/bash_completion.d/helm + args: + creates: /etc/bash_completion.d/helm + +- name: Deploy /root/.bashrc_oas + tags: + - bash + copy: + dest: /root/.bashrc_oas + src: bashrc_oas + +- name: Source /root/.bashrc_oas from /root/.bashrc + tags: + - bash blockinfile: path: "/root/.bashrc" - state: absent + state: present create: true block: | # Source Openappstack addtions from .bashrc_oas -- GitLab