Move first start tasks into handlers

Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter 2018-02-12 08:12:01 -06:00
parent 7dbed8d797
commit 9d976cacb9
No known key found for this signature in database
GPG Key ID: 9443251A787B9FB3
2 changed files with 21 additions and 11 deletions

View File

@ -34,3 +34,18 @@
delay: 3
until: dbus_install | success
listen: check connection
- name: Restart new container (first boot only)
systemd:
name: "systemd-nspawn@{{ systemd_escape.stdout }}"
state: "restarted"
register: machinectl_first_boot
retries: 5
delay: 2
until: machinectl_first_boot | success
delegate_to: "{{ physical_host }}"
when:
- machinectl_container_image_status.rc != 0
notify:
- check connection
listen: Container first boot

View File

@ -86,6 +86,8 @@
delay: 2
until: machinectl_container_clone | success
delegate_to: "{{ physical_host }}"
notify:
- Container first boot
- name: Container directories
file:
@ -218,8 +220,11 @@
name: "systemd-nspawn@{{ systemd_escape.stdout }}"
state: "{{ (container_config_old | changed | default(false)) | ternary('restarted', 'started') }}"
enabled: "{{ (nspawn_systemd_version | int > 219) | ternary('true', 'false') }}"
register: machinectl_start
retries: 5
delay: 2
until: machinectl_start | success
delegate_to: "{{ physical_host }}"
register: container_start
notify:
- check connection
@ -233,13 +238,3 @@
file:
path: "/var/log/journal"
state: "directory"
- name: Restart new container (first run only)
systemd:
name: "systemd-nspawn@{{ systemd_escape.stdout }}"
state: "restarted"
delegate_to: "{{ physical_host }}"
when:
- machinectl_container_image_status.rc != 0
notify:
- check connection