summaryrefslogtreecommitdiffstats
path: root/roles/bash/tasks/main.yml
blob: 816972ceec89b42e50a53868d92bd52b06b140f3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
---
- 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