Skip to content

Commit

Permalink
Merge pull request #340 from Icinga/fix/319-director-kickstart
Browse files Browse the repository at this point in the history
Add Director migration and kickstart handlers
  • Loading branch information
Donien authored Nov 11, 2024
2 parents 3ed3687 + ba43151 commit 4ee41f7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
11 changes: 11 additions & 0 deletions roles/icingaweb2/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---

- name: Module Director | Apply pending migrations
ansible.builtin.command:
cmd: icingacli director migration run
listen: "run_director_migrations"

- name: Module Director | Run kickstart if required
ansible.builtin.command:
cmd: icingacli director kickstart run
listen: "run_director_kickstart"
15 changes: 3 additions & 12 deletions roles/icingaweb2/tasks/modules/director.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,16 @@
register: _pending
changed_when: _pending.rc|int == 0
failed_when: _pending.stdout|length > 0
when: icingaweb2_modules['director']['import_schema'] is defined and icingaweb2_modules.director.import_schema and icingaweb2_modules['director']['config'] is defined

- name: Module Director | Apply pending migrations # noqa: command-instead-of-shell
ansible.builtin.shell:
cmd: icingacli director migration run
when: icingaweb2_modules['director']['import_schema'] is defined and icingaweb2_modules.director.import_schema and icingaweb2_modules['director']['config'] is defined and _pending.rc|int == 0
notify: "run_director_migrations"

- name: Module Director | Check if kickstart is required # noqa: command-instead-of-shell
ansible.builtin.shell:
cmd: icingacli director kickstart required
register: _required
changed_when: _required.rc|int == 0
changed_when: (_required.rc|int == 0) or (".icinga_host' doesn't exist" in _required.stderr)
failed_when: _required.rc|int >= 2
when: icingaweb2_modules['director']['run_kickstart'] is defined and icingaweb2_modules.director.run_kickstart and icingaweb2_modules['director']['kickstart'] is defined

- name: Module Director | Run kickstart if required # noqa: command-instead-of-shell
ansible.builtin.shell:
cmd: icingacli director kickstart run
when: icingaweb2_modules['director']['run_kickstart'] is defined and icingaweb2_modules.director.run_kickstart and icingaweb2_modules['director']['kickstart'] is defined and _required.rc|int == 0
notify: "run_director_kickstart"

- name: Module Director | Ensure installation from source is complete
when: icingaweb2_modules['director']['source'] == 'git'
Expand Down

0 comments on commit 4ee41f7

Please sign in to comment.