Skip to content

Commit 3558a56

Browse files
committed
Flush handlers after registration
Otherwise the "refresh" handler runs while the Proxy is not yet registered, which doesn't work. To avoid double-restarts by the "restart" handler, only restart proxy if it's not freshly started
1 parent 22f6c18 commit 3558a56

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/roles/foreman_proxy/handlers/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
- name: Restart Foreman Proxy
33
ansible.builtin.systemd:
44
name: foreman-proxy
5-
state: restarted
5+
state: "{{ (_foreman_proxy_service is changed) | ternary('started', 'restarted') }}"
66

77
- name: Refresh Foreman Proxy
88
theforeman.foreman.smart_proxy_refresh:

src/roles/foreman_proxy/tasks/main.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,11 @@
6464
ansible.builtin.systemd:
6565
daemon_reload: true
6666

67-
- name: Flush handlers to restart services
68-
ansible.builtin.meta: flush_handlers
69-
7067
- name: Start the Foreman Proxy Service
7168
ansible.builtin.systemd:
7269
name: foreman-proxy
7370
state: started
71+
register: _foreman_proxy_service
7472

7573
- name: Register Foreman Proxy to Foreman
7674
theforeman.foreman.smart_proxy:
@@ -80,3 +78,6 @@
8078
username: "{{ foreman_initial_admin_username }}"
8179
password: "{{ foreman_initial_admin_password }}"
8280
validate_certs: false
81+
82+
- name: Flush handlers to restart services
83+
ansible.builtin.meta: flush_handlers

0 commit comments

Comments
 (0)