/home/zuul/src/opendev.org/openstack/openstack-ansible-repo_server/tasks/repo_sync_manager.yml
---
# Copyright 2014, 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: Deploy lsyncd configuration file
  template:
    src: "{{ item.src }}"
    dest: "{{ item.dest }}"
  with_items:
    - { src: "lsyncd.lua.j2", dest: "{{ repo_lsyncd_config_file }}" }
    - { src: "lsyncd.defaults.j2", dest: "{{ repo_lsyncd_defaults_file }}" }
  notify:
    - reload lsyncd
    - cleanup apt-cacher-ng service
  when:
    - groups['repo_all'] | length > 1
  tags:
    - repo-lsyncd
    - repo-config

# TODO(odyssey4me):
# Remove this task in T. It is only present for the
# Q->R upgrade or for R->S upgrades for environments which
# were installed prior to R's release.
# It is implemented as a handler to prevent the service
# being removed before lsync has restarted with the new
# config. This task in particular cater for when lsync
# is not used because there is only one repo container.
- name: Remove apt-cacher-ng service
  command: "true"
  when:
    - groups['repo_all'] | length == 1
  notify:
    - cleanup apt-cacher-ng service
  tags:
    - skip_ansible_lint