From: Ismaƫl Bouya Date: Thu, 8 Nov 2018 08:47:54 +0000 (+0100) Subject: Put tasks in blocks X-Git-Tag: v1.0~34 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=cf86d448f96ede049c04d8165931f92a82f35956;p=perso%2FImmae%2FConfig%2FAnsible.git Put tasks in blocks --- 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 @@ file: path: $XDG_CONFIG_HOME/pm2 state: directory -- name: workdir scripts - synchronize: - recursive: yes - archive: no - checksum: yes - src: workdir/ - dest: /$HOME/workdir/ -- name: chmod workdir script - file: - path: $HOME/workdir/start - mode: 0755 +- name: workdir + block: + - name: workdir scripts + synchronize: + recursive: yes + archive: no + checksum: yes + src: workdir/ + dest: /$HOME/workdir/ + - name: chmod workdir script + file: + path: $HOME/workdir/start + mode: 0755 + - name: environment variables file + block: + - name: extract environment + shell: "pass show Travail/Fretlink/Environment" + register: fretlink_environment + changed_when: false + check_mode: no + - name: store environment + copy: + dest: $HOME/workdir/environment + content: "{{ fretlink_environment.stdout }}" - name: enable remind service systemd: state: started scope: user name: remind@work.service enabled: true -- name: extract environment - shell: "pass show Travail/Fretlink/Environment" - register: fretlink_environment - changed_when: false - check_mode: no -- name: store environment - copy: - dest: $HOME/workdir/environment - content: "{{ fretlink_environment.stdout }}" - 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 @@ --- -- name: xdg runtime env - cron: - name: XDG_RUNTIME_DIR - env: true - job: "{{ lookup('env', 'XDG_RUNTIME_DIR') }}" -- name: xdg current desktop env - cron: - name: XDG_CURRENT_DESKTOP - env: true - job: LXDE -- name: desktop session env - cron: - name: DESKTOP_SESSION - env: true - job: LXDE -- name: display env - cron: - name: DISPLAY - env: true - job: ":0" -- name: xauthority env - cron: - name: XAUTHORITY - env: true - job: "{{ lookup('env', 'XDG_RUNTIME_DIR') }}/Xauthority" +- name: environment variables + block: + - name: xdg runtime env + cron: + name: XDG_RUNTIME_DIR + env: true + job: "{{ lookup('env', 'XDG_RUNTIME_DIR') }}" + - name: xdg current desktop env + cron: + name: XDG_CURRENT_DESKTOP + env: true + job: LXDE + - name: desktop session env + cron: + name: DESKTOP_SESSION + env: true + job: LXDE + - name: display env + cron: + name: DISPLAY + env: true + job: ":0" + - name: xauthority env + cron: + name: XAUTHORITY + env: true + job: "{{ lookup('env', 'XDG_RUNTIME_DIR') }}/Xauthority" - name: change wallpaper cron: 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 @@ ignore_errors: true register: gpgkeys check_mode: no -- name: ask for gpg password - pause: - prompt: "Chose gpg password" - echo: false - register: gpg_password - when: gpgkeys is defined and "stdout" in gpgkeys and gpgkeys.stdout == "" -- name: confirm gpg password - pause: - prompt: "Confirm gpg password" - echo: false - register: gpg_password_confirm - when: gpgkeys is defined and "stdout" in gpgkeys and gpgkeys.stdout == "" -- name: check gpg password - assert: - that: gpg_password_confirm.user_input == gpg_password.user_input - when: gpgkeys is defined and "stdout" in gpgkeys and gpgkeys.stdout == "" -- name: copy default template for gpg key generation - template: - src: gen-key-script.j2 - dest: "$XDG_CONFIG_HOME/gnupg/gen-key-script-{{ gpg_user }}" - mode: 0600 - no_log: true - when: gpgkeys is defined and "stdout" in gpgkeys and gpgkeys.stdout == "" -- name: generate gpg key - command: "gpg --batch --gen-key $XDG_CONFIG_HOME/gnupg/gen-key-script-{{ gpg_user }}" - when: gpgkeys is defined and "stdout" in gpgkeys and gpgkeys.stdout == "" - register: genkey -- name: remove template file - file: - path: "$XDG_CONFIG_HOME/gnupg/gen-key-script-{{ gpg_user }}" - state: absent - when: gpgkeys is defined and "stdout" in gpgkeys and gpgkeys.stdout == "" +- name: Ask for gpg password + when: gpgkeys.stdout == "" + block: + - name: Ask for gpg password + pause: + prompt: "Chose gpg password" + echo: false + register: gpg_password + - name: Confirm gpg password + pause: + prompt: "Confirm gpg password" + echo: false + register: gpg_password_confirm + - name: check gpg password + assert: + that: gpg_password_confirm.user_input == gpg_password.user_input +- name: Generate gpg key + when: gpgkeys.stdout == "" + block: + - name: Copy default template for gpg key generation + template: + src: gen-key-script.j2 + dest: "$XDG_CONFIG_HOME/gnupg/gen-key-script-{{ gpg_user }}" + mode: 0600 + no_log: true + - name: Generate gpg key + command: "gpg --batch --gen-key $XDG_CONFIG_HOME/gnupg/gen-key-script-{{ gpg_user }}" + register: genkey + always: + - name: Remove template file + file: + path: "$XDG_CONFIG_HOME/gnupg/gen-key-script-{{ gpg_user }}" + state: absent - name: get keygrip shell: "gpg -K --with-colons {{ gpg_useremail }} | grep '^grp' | cut -d':' -f10" register: keygrip - when: gpgkeys is defined and "stdout" in gpgkeys and gpgkeys.stdout == "" + when: gpgkeys.stdout == "" notify: - notify add key to immae@immae.eu - send key to immae@immae.eu @@ -72,24 +73,26 @@ when: keygrip is defined and "stdout" in keygrip and keygrip.stdout != "" notify: - restart gpg-agent -- name: Add systemd overrides - template: - src: "systemd/{{ item }}.conf.j2" - dest: "$XDG_CONFIG_HOME/systemd/user/{{ item }}.socket.d/override.conf" - register: results - loop: - - dirmngr - - gpg-agent - - gpg-agent-browser - - gpg-agent-extra - - gpg-agent-ssh -- name: Restart systemd units - systemd: - daemon_reload: true - scope: user - state: restarted - name: "{{ item }}.socket" - loop: "{{ results.results|selectattr('changed')|map(attribute='item')|list }}" +- name: Override the gpg socket directory + block: + - name: Add systemd overrides + template: + src: "systemd/{{ item }}.conf.j2" + dest: "$XDG_CONFIG_HOME/systemd/user/{{ item }}.socket.d/override.conf" + register: results + loop: + - dirmngr + - gpg-agent + - gpg-agent-browser + - gpg-agent-extra + - gpg-agent-ssh + - name: Restart systemd units + systemd: + daemon_reload: true + scope: user + state: restarted + name: "{{ item }}.socket" + loop: "{{ results.results|selectattr('changed')|map(attribute='item')|list }}" - name: clone password store register: clone_password_store 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 @@ copy: src: mplayer dest: $XDG_CONFIG_HOME/mplayer/config -- name: psql config file - copy: - src: psqlrc - dest: $XDG_CONFIG_HOME/psql/psqlrc -- name: psql history directory - file: - path: $XDG_STATE_HOME/psql - state: directory +- name: postgresql + block: + - name: psql config file + copy: + src: psqlrc + dest: $XDG_CONFIG_HOME/psql/psqlrc + - name: psql history directory + file: + path: $XDG_STATE_HOME/psql + state: directory - name: vim config file copy: src: vimrc