Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Director migration and kickstart handlers #340

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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