Skip to content

Commit

Permalink
Adjust task to use bash installed by brew
Browse files Browse the repository at this point in the history
  • Loading branch information
greylabel committed Jul 12, 2024
1 parent 5ea914c commit 2e294a6
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions tasks/post-provision.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
---
- name: Check if Homebrew bash is installed.
ansible.builtin.command: "{{ homebrew_prefix }}/bin/bash --version"
register: homebrew_bash_version
failed_when: homebrew_bash_version.rc != 0
changed_when: false

- name: Check if Homebrew bash is present in /etc/shells.
ansible.builtin.command: fgrep "{{ homebrew_prefix }}/bin/bash" /etc/shells
register: homebrew_bash_installed
when: homebrew_bash_version.rc == 0
register: homebrew_bash_present
failed_when: homebrew_bash_present.rc >= 2
changed_when: false

- name: Add Homebrew bash to /etc/shells.
ansible.builtin.command: echo "{{ homebrew_prefix }}/bin/bash" | sudo tee -a /etc/shells
when: not homebrew_bash_installed.stdout
ansible.builtin.shell: |
set -o pipefail
echo "{{ homebrew_prefix }}/bin/bash" | tee -a /etc/shells
when: homebrew_bash_present.rc == 1
register: homebrew_bash_added
become: true

- name: Change default shell to Homebrew bash.
ansible.builtin.user:
name: "{{ ansible_user_id }}"
shell: "{{ homebrew_prefix }}/bin/bash"
when: homebrew_bash_installed.stdout
when: homebrew_bash_present.rc == 1

0 comments on commit 2e294a6

Please sign in to comment.