/home/zuul/src/opendev.org/openstack/openstack-ansible-nspawn_hosts/handlers/main.yml
---
# Copyright 2017, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

- name: Disable host dnsmasq service
  systemd:
    name: "dnsmasq.service"
    state: "stopped"
    enabled: false
    masked: true
    daemon_reload: true

- name: Remove rootfs archive
  file:
    path: "/tmp/{{ nspawn_hosts_container_image_url | basename }}"
    state: "absent"

- name: Enable network dnsmasq service
  systemd:
    name: "dnsmasq-{{ 'mv-' + item.value.bridge.split('br-')[-1] }}.service"
    state: "restarted"
    enabled: true
    daemon_reload: true
  when:
    - item.value.enable_dhcp | default(false) | bool
  with_dict: "{{ nspawn_combined_networks }}"

- name: Remove policy-rc
  file:
    path: "/usr/sbin/policy-rc.d"
    state: absent
  changed_when: false

- name: Restart systemd-journald
  systemd:
    name: "systemd-journald"
    state: restarted
    enabled: yes
    daemon_reload: true

- name: Reload systemd-daemon
  systemd:
    daemon_reload: true