---
# NOTE(mgoddard): In the Rocky release, Kolla Ansible enabled the chrony
# container by default. Running this alongside the NTP daemon on the host is
# likely to cause issues, so we should explicitly disable it. Kolla Ansible
# won't automatically stop the container, so we do it here if it is disabled.
# See https://storyboard.openstack.org/#!/story/2005272.

- name: Stop the chrony container
  hosts: overcloud
  vars:
    # kolla_overcloud_inventory_top_level_group_map looks like:
    # kolla_overcloud_inventory_top_level_group_map:
    #  control:
    #    groups:
    #      - controllers
    overcloud_nodes_in_kolla_inventory: >-
      {{ kolla_overcloud_inventory_top_level_group_map.values() |
      map(attribute='groups') | flatten | unique | join(':') }}
  tags:
    - stop-chrony
  tasks:
    - name: Stop the chrony container
      docker_container:
        name: chrony
        state: absent
      when:
        - not kolla_enable_chrony | bool
        - inventory_hostname in query('inventory_hostnames', overcloud_nodes_in_kolla_inventory)
