summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@fretlink.com>2018-11-04 00:37:08 +0100
committerIsmaël Bouya <ismael.bouya@fretlink.com>2018-11-04 00:37:08 +0100
commitc235f9bea368316f1c1a441ebf6877e05e7df21c (patch)
tree61d93da1efd55132b186bb8ff7639b9a8e317131
parent397c4fed757d201af627636822981e85e84ea572 (diff)
downloadAnsible-c235f9bea368316f1c1a441ebf6877e05e7df21c.tar.gz
Ansible-c235f9bea368316f1c1a441ebf6877e05e7df21c.tar.zst
Ansible-c235f9bea368316f1c1a441ebf6877e05e7df21c.zip
Add a temporary bashrc when updating pam_environment
-rw-r--r--roles/init/tasks/main.yml18
-rw-r--r--roles/shell/bash/templates/bash_profile.j21
-rw-r--r--roles/shell/bash/templates/bashrc.j22
3 files changed, 21 insertions, 0 deletions
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 @@
7 template: 7 template:
8 src: pam_environment.j2 8 src: pam_environment.j2
9 dest: $XDG_CONFIG_HOME/pam_environment 9 dest: $XDG_CONFIG_HOME/pam_environment
10- name: Remove old lines in bashrc_temp
11 lineinfile:
12 line: "{{ ('unset ' ~ item | regex_replace('=.*')) if item != '' and item.0 != '#' else '' }}"
13 dest: $HOME/.bashrc_temp
14 insertafter: EOF
15 create: true
16 state: present
17 loop: "{{ pam_environment.diff.0.before.split('\n')|difference(pam_environment.diff.0.after.split('\n')) | regex_replace('[\\\\t]*DEFAULT') }}"
18 when: pam_environment.changed
19- name: Add new lines in bashrc_temp
20 lineinfile:
21 line: "{{ ('export ' ~ item) if item != '' and item.0 != '#' else '' }}"
22 dest: $HOME/.bashrc_temp
23 insertafter: EOF
24 create: true
25 state: present
26 loop: "{{ pam_environment.diff.0.after.split('\n')|difference(pam_environment.diff.0.before.split('\n')) | regex_replace('[\\\\t]*DEFAULT', '') }}"
27 when: pam_environment.changed
10- name: Signal the change 28- name: Signal the change
11 when: pam_environment.changed 29 when: pam_environment.changed
12 debug: 30 debug:
diff --git a/roles/shell/bash/templates/bash_profile.j2 b/roles/shell/bash/templates/bash_profile.j2
index 06210fa..9b9e86c 100644
--- a/roles/shell/bash/templates/bash_profile.j2
+++ b/roles/shell/bash/templates/bash_profile.j2
@@ -4,6 +4,7 @@
4{% if "graphical_vt" in features.get(profile, []) %} 4{% if "graphical_vt" in features.get(profile, []) %}
5 5
6if [[ ! $DISPLAY && $XDG_VTNR -eq 1 ]]; then 6if [[ ! $DISPLAY && $XDG_VTNR -eq 1 ]]; then
7 [[ -f "$HOME/.bashrc_temp" ]] && rm -f $HOME/.bashrc_temp
7 exec startx $XDG_CONFIG_HOME/xinitrc > $XDG_STATE_HOME/xsession_errors 2>&1 8 exec startx $XDG_CONFIG_HOME/xinitrc > $XDG_STATE_HOME/xsession_errors 2>&1
8fi 9fi
9{% endif %} 10{% endif %}
diff --git a/roles/shell/bash/templates/bashrc.j2 b/roles/shell/bash/templates/bashrc.j2
index 2285d2b..99ed55f 100644
--- a/roles/shell/bash/templates/bashrc.j2
+++ b/roles/shell/bash/templates/bashrc.j2
@@ -2,6 +2,8 @@
2# ~/.bashrc 2# ~/.bashrc
3# 3#
4 4
5[[ -f "$HOME/.bashrc_temp" ]] && . $HOME/.bashrc_temp
6
5if [ -n "$HOME/.local/bin" ]; then 7if [ -n "$HOME/.local/bin" ]; then
6 PATH="$HOME/.local/bin:$PATH" 8 PATH="$HOME/.local/bin:$PATH"
7fi 9fi