]> git.immae.eu Git - perso/Immae/Config/Ansible.git/commitdiff
Put tasks in blocks
authorIsmaël Bouya <ismael.bouya@fretlink.com>
Thu, 8 Nov 2018 08:47:54 +0000 (09:47 +0100)
committerIsmaël Bouya <ismael.bouya@fretlink.com>
Thu, 8 Nov 2018 08:47:54 +0000 (09:47 +0100)
roles/contexts/fretlink/tasks/main.yml
roles/cron/tasks/main.yml
roles/gnupg/tasks/main.yml
roles/tools/tasks/main.yml

index bbeae933ef3305a899fc184396c9ff7481d4c308..b1b163a5912f911a980424f7a9bc36d1d4f57257 100644 (file)
   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
index 0750993d05c478dc548cde436452a46b81037b48..b93c0b77764d36d869d900f0f792ff8857f4c56a 100644 (file)
@@ -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
index ef61fede378775b84065dc3f758b60b3ab743449..a2b9aa6bd13553e5b3e9beaf40d2792bb2f6505d 100644 (file)
   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
   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"
index 748bd77d181812437560b63e1791c8d5a97a2242..56298cbed129f2acb60174245e333c9f1458c6b8 100644 (file)
@@ -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