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:
{% if "graphical_vt" in features.get(profile, []) %}
if [[ ! $DISPLAY && $XDG_VTNR -eq 1 ]]; then
+ [[ -f "$HOME/.bashrc_temp" ]] && rm -f $HOME/.bashrc_temp
exec startx $XDG_CONFIG_HOME/xinitrc > $XDG_STATE_HOME/xsession_errors 2>&1
fi
{% endif %}