From c235f9bea368316f1c1a441ebf6877e05e7df21c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Sun, 4 Nov 2018 00:37:08 +0100 Subject: Add a temporary bashrc when updating pam_environment --- roles/init/tasks/main.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'roles/init/tasks') diff --git a/roles/init/tasks/main.yml b/roles/init/tasks/main.yml index d3f0f6b..1baec91 100644 --- a/roles/init/tasks/main.yml +++ b/roles/init/tasks/main.yml @@ -7,6 +7,24 @@ template: src: pam_environment.j2 dest: $XDG_CONFIG_HOME/pam_environment +- name: Remove old lines in bashrc_temp + lineinfile: + line: "{{ ('unset ' ~ item | regex_replace('=.*')) if item != '' and item.0 != '#' else '' }}" + dest: $HOME/.bashrc_temp + insertafter: EOF + create: true + state: present + loop: "{{ pam_environment.diff.0.before.split('\n')|difference(pam_environment.diff.0.after.split('\n')) | regex_replace('[\\\\t]*DEFAULT') }}" + when: pam_environment.changed +- name: Add new lines in bashrc_temp + lineinfile: + line: "{{ ('export ' ~ item) if item != '' and item.0 != '#' else '' }}" + dest: $HOME/.bashrc_temp + insertafter: EOF + create: true + state: present + loop: "{{ pam_environment.diff.0.after.split('\n')|difference(pam_environment.diff.0.before.split('\n')) | regex_replace('[\\\\t]*DEFAULT', '') }}" + when: pam_environment.changed - name: Signal the change when: pam_environment.changed debug: -- cgit v1.2.3