diff options
author | Ismaël Bouya <ismael.bouya@fretlink.com> | 2018-11-08 09:47:54 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@fretlink.com> | 2018-11-08 09:47:54 +0100 |
commit | cf86d448f96ede049c04d8165931f92a82f35956 (patch) | |
tree | 915a6fd5f4748559abbe74bd9806f5a01eaada73 | |
parent | de1c634c1fda61e34522595b40c66af17681bd14 (diff) | |
download | Ansible-cf86d448f96ede049c04d8165931f92a82f35956.tar.gz Ansible-cf86d448f96ede049c04d8165931f92a82f35956.tar.zst Ansible-cf86d448f96ede049c04d8165931f92a82f35956.zip |
Put tasks in blocks
-rw-r--r-- | roles/contexts/fretlink/tasks/main.yml | 45 | ||||
-rw-r--r-- | roles/cron/tasks/main.yml | 52 | ||||
-rw-r--r-- | roles/gnupg/tasks/main.yml | 105 | ||||
-rw-r--r-- | roles/tools/tasks/main.yml | 18 |
4 files changed, 115 insertions, 105 deletions
diff --git a/roles/contexts/fretlink/tasks/main.yml b/roles/contexts/fretlink/tasks/main.yml index bbeae93..b1b163a 100644 --- a/roles/contexts/fretlink/tasks/main.yml +++ b/roles/contexts/fretlink/tasks/main.yml | |||
@@ -17,30 +17,33 @@ | |||
17 | file: | 17 | file: |
18 | path: $XDG_CONFIG_HOME/pm2 | 18 | path: $XDG_CONFIG_HOME/pm2 |
19 | state: directory | 19 | state: directory |
20 | - name: workdir scripts | 20 | - name: workdir |
21 | synchronize: | 21 | block: |
22 | recursive: yes | 22 | - name: workdir scripts |
23 | archive: no | 23 | synchronize: |
24 | checksum: yes | 24 | recursive: yes |
25 | src: workdir/ | 25 | archive: no |
26 | dest: /$HOME/workdir/ | 26 | checksum: yes |
27 | - name: chmod workdir script | 27 | src: workdir/ |
28 | file: | 28 | dest: /$HOME/workdir/ |
29 | path: $HOME/workdir/start | 29 | - name: chmod workdir script |
30 | mode: 0755 | 30 | file: |
31 | path: $HOME/workdir/start | ||
32 | mode: 0755 | ||
33 | - name: environment variables file | ||
34 | block: | ||
35 | - name: extract environment | ||
36 | shell: "pass show Travail/Fretlink/Environment" | ||
37 | register: fretlink_environment | ||
38 | changed_when: false | ||
39 | check_mode: no | ||
40 | - name: store environment | ||
41 | copy: | ||
42 | dest: $HOME/workdir/environment | ||
43 | content: "{{ fretlink_environment.stdout }}" | ||
31 | - name: enable remind service | 44 | - name: enable remind service |
32 | systemd: | 45 | systemd: |
33 | state: started | 46 | state: started |
34 | scope: user | 47 | scope: user |
35 | name: remind@work.service | 48 | name: remind@work.service |
36 | enabled: true | 49 | enabled: true |
37 | - name: extract environment | ||
38 | shell: "pass show Travail/Fretlink/Environment" | ||
39 | register: fretlink_environment | ||
40 | changed_when: false | ||
41 | check_mode: no | ||
42 | - name: store environment | ||
43 | copy: | ||
44 | dest: $HOME/workdir/environment | ||
45 | content: "{{ fretlink_environment.stdout }}" | ||
46 | backup: true | ||
diff --git a/roles/cron/tasks/main.yml b/roles/cron/tasks/main.yml index 0750993..b93c0b7 100644 --- a/roles/cron/tasks/main.yml +++ b/roles/cron/tasks/main.yml | |||
@@ -1,29 +1,31 @@ | |||
1 | --- | 1 | --- |
2 | - name: xdg runtime env | 2 | - name: environment variables |
3 | cron: | 3 | block: |
4 | name: XDG_RUNTIME_DIR | 4 | - name: xdg runtime env |
5 | env: true | 5 | cron: |
6 | job: "{{ lookup('env', 'XDG_RUNTIME_DIR') }}" | 6 | name: XDG_RUNTIME_DIR |
7 | - name: xdg current desktop env | 7 | env: true |
8 | cron: | 8 | job: "{{ lookup('env', 'XDG_RUNTIME_DIR') }}" |
9 | name: XDG_CURRENT_DESKTOP | 9 | - name: xdg current desktop env |
10 | env: true | 10 | cron: |
11 | job: LXDE | 11 | name: XDG_CURRENT_DESKTOP |
12 | - name: desktop session env | 12 | env: true |
13 | cron: | 13 | job: LXDE |
14 | name: DESKTOP_SESSION | 14 | - name: desktop session env |
15 | env: true | 15 | cron: |
16 | job: LXDE | 16 | name: DESKTOP_SESSION |
17 | - name: display env | 17 | env: true |
18 | cron: | 18 | job: LXDE |
19 | name: DISPLAY | 19 | - name: display env |
20 | env: true | 20 | cron: |
21 | job: ":0" | 21 | name: DISPLAY |
22 | - name: xauthority env | 22 | env: true |
23 | cron: | 23 | job: ":0" |
24 | name: XAUTHORITY | 24 | - name: xauthority env |
25 | env: true | 25 | cron: |
26 | job: "{{ lookup('env', 'XDG_RUNTIME_DIR') }}/Xauthority" | 26 | name: XAUTHORITY |
27 | env: true | ||
28 | job: "{{ lookup('env', 'XDG_RUNTIME_DIR') }}/Xauthority" | ||
27 | - name: change wallpaper | 29 | - name: change wallpaper |
28 | cron: | 30 | cron: |
29 | name: change wallpaper | 31 | name: change wallpaper |
diff --git a/roles/gnupg/tasks/main.yml b/roles/gnupg/tasks/main.yml index ef61fed..a2b9aa6 100644 --- a/roles/gnupg/tasks/main.yml +++ b/roles/gnupg/tasks/main.yml | |||
@@ -22,42 +22,43 @@ | |||
22 | ignore_errors: true | 22 | ignore_errors: true |
23 | register: gpgkeys | 23 | register: gpgkeys |
24 | check_mode: no | 24 | check_mode: no |
25 | - name: ask for gpg password | 25 | - name: Ask for gpg password |
26 | pause: | 26 | when: gpgkeys.stdout == "" |
27 | prompt: "Chose gpg password" | 27 | block: |
28 | echo: false | 28 | - name: Ask for gpg password |
29 | register: gpg_password | 29 | pause: |
30 | when: gpgkeys is defined and "stdout" in gpgkeys and gpgkeys.stdout == "" | 30 | prompt: "Chose gpg password" |
31 | - name: confirm gpg password | 31 | echo: false |
32 | pause: | 32 | register: gpg_password |
33 | prompt: "Confirm gpg password" | 33 | - name: Confirm gpg password |
34 | echo: false | 34 | pause: |
35 | register: gpg_password_confirm | 35 | prompt: "Confirm gpg password" |
36 | when: gpgkeys is defined and "stdout" in gpgkeys and gpgkeys.stdout == "" | 36 | echo: false |
37 | - name: check gpg password | 37 | register: gpg_password_confirm |
38 | assert: | 38 | - name: check gpg password |
39 | that: gpg_password_confirm.user_input == gpg_password.user_input | 39 | assert: |
40 | when: gpgkeys is defined and "stdout" in gpgkeys and gpgkeys.stdout == "" | 40 | that: gpg_password_confirm.user_input == gpg_password.user_input |
41 | - name: copy default template for gpg key generation | 41 | - name: Generate gpg key |
42 | template: | 42 | when: gpgkeys.stdout == "" |
43 | src: gen-key-script.j2 | 43 | block: |
44 | dest: "$XDG_CONFIG_HOME/gnupg/gen-key-script-{{ gpg_user }}" | 44 | - name: Copy default template for gpg key generation |
45 | mode: 0600 | 45 | template: |
46 | no_log: true | 46 | src: gen-key-script.j2 |
47 | when: gpgkeys is defined and "stdout" in gpgkeys and gpgkeys.stdout == "" | 47 | dest: "$XDG_CONFIG_HOME/gnupg/gen-key-script-{{ gpg_user }}" |
48 | - name: generate gpg key | 48 | mode: 0600 |
49 | command: "gpg --batch --gen-key $XDG_CONFIG_HOME/gnupg/gen-key-script-{{ gpg_user }}" | 49 | no_log: true |
50 | when: gpgkeys is defined and "stdout" in gpgkeys and gpgkeys.stdout == "" | 50 | - name: Generate gpg key |
51 | register: genkey | 51 | command: "gpg --batch --gen-key $XDG_CONFIG_HOME/gnupg/gen-key-script-{{ gpg_user }}" |
52 | - name: remove template file | 52 | register: genkey |
53 | file: | 53 | always: |
54 | path: "$XDG_CONFIG_HOME/gnupg/gen-key-script-{{ gpg_user }}" | 54 | - name: Remove template file |
55 | state: absent | 55 | file: |
56 | when: gpgkeys is defined and "stdout" in gpgkeys and gpgkeys.stdout == "" | 56 | path: "$XDG_CONFIG_HOME/gnupg/gen-key-script-{{ gpg_user }}" |
57 | state: absent | ||
57 | - name: get keygrip | 58 | - name: get keygrip |
58 | shell: "gpg -K --with-colons {{ gpg_useremail }} | grep '^grp' | cut -d':' -f10" | 59 | shell: "gpg -K --with-colons {{ gpg_useremail }} | grep '^grp' | cut -d':' -f10" |
59 | register: keygrip | 60 | register: keygrip |
60 | when: gpgkeys is defined and "stdout" in gpgkeys and gpgkeys.stdout == "" | 61 | when: gpgkeys.stdout == "" |
61 | notify: | 62 | notify: |
62 | - notify add key to immae@immae.eu | 63 | - notify add key to immae@immae.eu |
63 | - send key to immae@immae.eu | 64 | - send key to immae@immae.eu |
@@ -72,24 +73,26 @@ | |||
72 | when: keygrip is defined and "stdout" in keygrip and keygrip.stdout != "" | 73 | when: keygrip is defined and "stdout" in keygrip and keygrip.stdout != "" |
73 | notify: | 74 | notify: |
74 | - restart gpg-agent | 75 | - restart gpg-agent |
75 | - name: Add systemd overrides | 76 | - name: Override the gpg socket directory |
76 | template: | 77 | block: |
77 | src: "systemd/{{ item }}.conf.j2" | 78 | - name: Add systemd overrides |
78 | dest: "$XDG_CONFIG_HOME/systemd/user/{{ item }}.socket.d/override.conf" | 79 | template: |
79 | register: results | 80 | src: "systemd/{{ item }}.conf.j2" |
80 | loop: | 81 | dest: "$XDG_CONFIG_HOME/systemd/user/{{ item }}.socket.d/override.conf" |
81 | - dirmngr | 82 | register: results |
82 | - gpg-agent | 83 | loop: |
83 | - gpg-agent-browser | 84 | - dirmngr |
84 | - gpg-agent-extra | 85 | - gpg-agent |
85 | - gpg-agent-ssh | 86 | - gpg-agent-browser |
86 | - name: Restart systemd units | 87 | - gpg-agent-extra |
87 | systemd: | 88 | - gpg-agent-ssh |
88 | daemon_reload: true | 89 | - name: Restart systemd units |
89 | scope: user | 90 | systemd: |
90 | state: restarted | 91 | daemon_reload: true |
91 | name: "{{ item }}.socket" | 92 | scope: user |
92 | loop: "{{ results.results|selectattr('changed')|map(attribute='item')|list }}" | 93 | state: restarted |
94 | name: "{{ item }}.socket" | ||
95 | loop: "{{ results.results|selectattr('changed')|map(attribute='item')|list }}" | ||
93 | - name: clone password store | 96 | - name: clone password store |
94 | register: clone_password_store | 97 | register: clone_password_store |
95 | shell: "cd $(dirname $ANSIBLE_CONFIG ); git submodule update --init password_store" | 98 | shell: "cd $(dirname $ANSIBLE_CONFIG ); git submodule update --init password_store" |
diff --git a/roles/tools/tasks/main.yml b/roles/tools/tasks/main.yml index 748bd77..56298cb 100644 --- a/roles/tools/tasks/main.yml +++ b/roles/tools/tasks/main.yml | |||
@@ -9,14 +9,16 @@ | |||
9 | copy: | 9 | copy: |
10 | src: mplayer | 10 | src: mplayer |
11 | dest: $XDG_CONFIG_HOME/mplayer/config | 11 | dest: $XDG_CONFIG_HOME/mplayer/config |
12 | - name: psql config file | 12 | - name: postgresql |
13 | copy: | 13 | block: |
14 | src: psqlrc | 14 | - name: psql config file |
15 | dest: $XDG_CONFIG_HOME/psql/psqlrc | 15 | copy: |
16 | - name: psql history directory | 16 | src: psqlrc |
17 | file: | 17 | dest: $XDG_CONFIG_HOME/psql/psqlrc |
18 | path: $XDG_STATE_HOME/psql | 18 | - name: psql history directory |
19 | state: directory | 19 | file: |
20 | path: $XDG_STATE_HOME/psql | ||
21 | state: directory | ||
20 | - name: vim config file | 22 | - name: vim config file |
21 | copy: | 23 | copy: |
22 | src: vimrc | 24 | src: vimrc |