--- - name: "Ensure bash is installed" become: true ansible.builtin.package: name: "bash" state: "present" - name: "Ensure .bash(rc|_profile) and .profile exists" # This is used by different setup scripts adding their init in one of these ansible.builtin.file: path: "{{ item }}" state: "touch" mode: "0644" modification_time: "preserve" access_time: "preserve" loop: - "{{ ansible_facts['env']['HOME'] }}/.bashrc" - "{{ ansible_facts['env']['HOME'] }}/.bash_profile" - "{{ ansible_facts['env']['HOME'] }}/.profile" - name: "Ensure bash-completion is installed" become: true ansible.builtin.package: name: "bash-completion" state: "present" - name: "Add bash-completion to shell profile" ansible.builtin.blockinfile: path: "{{ ansible_facts['env']['HOME'] }}/.bashrc" state: "present" prepend_newline: true append_newline: true marker: "# ==== {mark} ANSIBLE BASH-COMPLETION CONFIG" block: | if [ -f "/usr/share/bash-completion/bash_completion" ]; then source "/usr/share/bash-completion/bash_completion" fi