From fecf0b6685f2928a45a8d33b7487902f5de85061 Mon Sep 17 00:00:00 2001 From: ninjabong Date: Mon, 8 Sep 2014 19:03:17 -0400 Subject: [PATCH 1/2] better handling of dotfiles for ~/.common_env --- tasks/main.yml | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index b50c1ee..20d05dd 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -15,4 +15,26 @@ mode=0544 with_nested: - "{{ affected_users }}" - - [ '.bash_profile', '.bash_login', '.zshrc', '.zshenv' ] + - [ '.bash_profile', '.bash_login', '.zshrc', '.zshenv', '.profile' ] + register: dotfiles_done + +# ensure .profile is present at minimum, or update if it exists, when the above fails +- name: create .profile or update if it exists with homebrew_cask_opts + lineinfile: dest=/Users/{{ item[0] }}/.profile + regexp="^export HOMEBREW_CASK_OPTS" + line="export HOMEBREW_CASK_OPTS=\"--appdir=/Applications\"" + create=yes + with_nested: + - "{{ affected_users }}" + when: dotfiles_done|failed + +- name: source this common env from the new .profile + ignore_errors: True + lineinfile: dest=/Users/{{ item[0] }}/.profile + regexp='source ~/\.common_env' + line='source ~/.common_env' + owner={{ item[0] }} + mode=0544 + with_nested: + - "{{ affected_users }}" + when: dotfiles_done|failed From 2827845ef4558ea21831a68b7f7e415f2eaed193 Mon Sep 17 00:00:00 2001 From: ninjabong Date: Tue, 9 Sep 2014 01:16:30 -0400 Subject: [PATCH 2/2] fixed tasks/main.yml, man what a brainfart --- tasks/main.yml | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 20d05dd..ef5b4e4 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -6,7 +6,7 @@ mode=0544 with_items: affected_users -- name: source this common env from every known dotfile +- name: source the common env from every known dotfile ignore_errors: True lineinfile: dest=/Users/{{ item[0] }}/{{ item[1] }} regexp='source ~/\.common_env' @@ -19,22 +19,13 @@ register: dotfiles_done # ensure .profile is present at minimum, or update if it exists, when the above fails -- name: create .profile or update if it exists with homebrew_cask_opts - lineinfile: dest=/Users/{{ item[0] }}/.profile - regexp="^export HOMEBREW_CASK_OPTS" - line="export HOMEBREW_CASK_OPTS=\"--appdir=/Applications\"" - create=yes - with_nested: - - "{{ affected_users }}" - when: dotfiles_done|failed - -- name: source this common env from the new .profile +- name: create and source the common env from a new .profile ignore_errors: True - lineinfile: dest=/Users/{{ item[0] }}/.profile + lineinfile: dest=/Users/{{ item }}/.profile regexp='source ~/\.common_env' line='source ~/.common_env' - owner={{ item[0] }} + owner={{ item }} mode=0544 - with_nested: - - "{{ affected_users }}" + create=yes + with_items: affected_users when: dotfiles_done|failed