blob: e8c8fd0258a925d883dd15b77e1dcb565eb5a73d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
---
- name: Create XDG dirs
file:
path: "{{ item }}"
state: directory
loop:
- "$XDG_CONFIG_HOME"
- "$XDG_STATE_HOME"
- "$XDG_STATE_HOME/bash"
- "$XDG_DATA_HOME"
- "$XDG_CACHE_HOME"
- "$HOME/Downloads"
- name: Get gnupg runtime folder name
shell: 'GNUPGHOME=$XDG_CONFIG_HOME/gnupg gpgconf --list-dirs socketdir | sed -e "s@$XDG_RUNTIME_DIR/gnupg/@@"'
changed_when: false
register: gnupg_runtime_dir_cmd
check_mode: no
- name: Add user dirs
copy:
src: "user_dirs/{{ item }}"
dest: "$XDG_CONFIG_HOME/{{ item }}"
loop:
- user-dirs.dirs
- user-dirs.locale
- name: Change ansible git directory to permit pushes
git_config:
repo: .
scope: local
name: remote.origin.url
value: gitolite@git.immae.eu:perso/Immae/Config/Ansible
- name: Add pam_environment
register: pam_environment
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: $XDG_STATE_HOME/bash/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) | regex_replace('@{HOME}', '${HOME}') if item != '' and item.0 != '#' else '' }}"
dest: $XDG_STATE_HOME/bash/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:
msg: "\u26A0\uFE0F \u26A0\uFE0F You need to log out and back in to update your environment \u26A0\uFE0F \u26A0\uFE0F"
|