Skip to content

Commit ba43151

Browse files
committed
Add Director migration and kickstart handlers
This adds handlers to the 'icingaweb2' role to take care of Icinga Director schema migrations and its kickstart. Running multiple roles in order should also run their handlers in order. This way the Icinga 2 API should be up and operational for the Director to use for kickstart. Fixes #319
1 parent 3ed3687 commit ba43151

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

roles/icingaweb2/handlers/main.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
3+
- name: Module Director | Apply pending migrations
4+
ansible.builtin.command:
5+
cmd: icingacli director migration run
6+
listen: "run_director_migrations"
7+
8+
- name: Module Director | Run kickstart if required
9+
ansible.builtin.command:
10+
cmd: icingacli director kickstart run
11+
listen: "run_director_kickstart"

roles/icingaweb2/tasks/modules/director.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,16 @@
2525
register: _pending
2626
changed_when: _pending.rc|int == 0
2727
failed_when: _pending.stdout|length > 0
28-
when: icingaweb2_modules['director']['import_schema'] is defined and icingaweb2_modules.director.import_schema and icingaweb2_modules['director']['config'] is defined
29-
30-
- name: Module Director | Apply pending migrations # noqa: command-instead-of-shell
31-
ansible.builtin.shell:
32-
cmd: icingacli director migration run
33-
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
28+
notify: "run_director_migrations"
3429

3530
- name: Module Director | Check if kickstart is required # noqa: command-instead-of-shell
3631
ansible.builtin.shell:
3732
cmd: icingacli director kickstart required
3833
register: _required
39-
changed_when: _required.rc|int == 0
34+
changed_when: (_required.rc|int == 0) or (".icinga_host' doesn't exist" in _required.stderr)
4035
failed_when: _required.rc|int >= 2
4136
when: icingaweb2_modules['director']['run_kickstart'] is defined and icingaweb2_modules.director.run_kickstart and icingaweb2_modules['director']['kickstart'] is defined
42-
43-
- name: Module Director | Run kickstart if required # noqa: command-instead-of-shell
44-
ansible.builtin.shell:
45-
cmd: icingacli director kickstart run
46-
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
37+
notify: "run_director_kickstart"
4738

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

0 commit comments

Comments
 (0)