diff --git a/roles/config/tasks/async.yml b/roles/config/tasks/async.yml new file mode 100644 index 00000000..80a12988 --- /dev/null +++ b/roles/config/tasks/async.yml @@ -0,0 +1,15 @@ +--- +- name: Doom Emacs | Check if installed + ansible.builtin.stat: + path: "~/.config/emacs/bin/doom" + register: doom_emacs + tags: config + +- name: Doom Emacs | Update if present - aync + ansible.builtin.shell: + cmd: "~/.config/emacs/bin/doom sync" + when: doom_emacs.stat.exists + async: 600 + poll: 0 + register: async_doom_emacs + tags: config diff --git a/roles/config/tasks/async_check.yml b/roles/config/tasks/async_check.yml new file mode 100644 index 00000000..888bc180 --- /dev/null +++ b/roles/config/tasks/async_check.yml @@ -0,0 +1,13 @@ +--- +- name: Doom Emacs | Check on async job + async_status: + jid: "{{ async_doom_emacs.ansible_job_id }}" + register: job_result + until: job_result.finished + retries: 60 + delay: 10 + +- name: Doom Emacs | Cleanup async job + async_status: + jid: "{{ async_doom_emacs.ansible_job_id }}" + mode: cleanup diff --git a/roles/config/tasks/main.yml b/roles/config/tasks/main.yml index b9f47fe0..fcb9b03d 100644 --- a/roles/config/tasks/main.yml +++ b/roles/config/tasks/main.yml @@ -112,6 +112,12 @@ mode: "0755" tags: config +# Start async tasks early +- name: Import Tasks from async.yml + ansible.builtin.import_tasks: + file: async.yml + tags: config + - name: Reload system systemd services ansible.builtin.systemd_service: daemon_reload: true @@ -303,19 +309,13 @@ cmd: "update-desktop-database ~/.local/share/applications/" tags: config -- name: Doom Emacs | Check if installed - ansible.builtin.stat: - path: "~/.config/emacs/bin/doom" - register: doom_emacs - tags: config - -- name: Doom Emacs | Update if present - ansible.builtin.shell: - cmd: "~/.config/emacs/bin/doom sync" - when: doom_emacs.stat.exists - tags: config - - name: Import Tasks from plasma.yml ansible.builtin.import_tasks: file: plasma.yml tags: config + +# Async task callbacks +- name: Import Tasks from async_check.yml + ansible.builtin.import_tasks: + file: async_check.yml + tags: config