From aff75cfeca685fd3db07b587617cec31e51a66e2 Mon Sep 17 00:00:00 2001 From: Maxim Likhachev Date: Tue, 10 Dec 2019 14:59:56 +0300 Subject: [PATCH] Check if default shell is configured --- roles/macos/tasks/main.yml | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/roles/macos/tasks/main.yml b/roles/macos/tasks/main.yml index d4e1c7c..4128e58 100644 --- a/roles/macos/tasks/main.yml +++ b/roles/macos/tasks/main.yml @@ -19,14 +19,21 @@ name: "{{ apps_brew_cask }}" ignore_errors: yes -- name: Add Bash to /etc/shells - become: true - lineinfile: - path: /etc/shells - line: /usr/local/bin/bash - -- name: Set Bash as default shell - command: chsh -s /usr/local/bin/bash +- name: Get default shell + shell: dscl . -read ~/ UserShell | cut -d ' ' -f 2- + register: current_shell + +- name: Configure {{ default_shell.name }} as a default shell + when: current_shell.stdout != default_shell.path + block: + - name: Add {{ default_shell.name }} to /etc/shells + become: true + lineinfile: + path: /etc/shells + line: "{{ default_shell.path }}" + + - name: Set Bash as default shell + command: chsh -s {{ default_shell.path }} - include: install-dmg.yml become: true