/home/zuul/src/opendev.org/openstack/openstack-ansible-openstack_hosts/tasks/openstack_hosts_ca_certificates.yml
---
# Copyright 2019, BBC
#
# 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: Copy CA certificates
  copy:
    src: "{{ item.src }}"
    dest: "{{ openstack_host_ca_location }}/{{ item.name }}"
  register: openstack_host_ca_cert_copy
  loop: "{{ openstack_host_ca_certificates | flatten(levels=1) }}"

- name: Update CA store - Ubuntu/OpenSUSE
  command: update-ca-certificates
  when:
    - (ansible_pkg_mgr == 'apt') or (ansible_pkg_mgr == 'zypper') or (ansible_pkg_mgr == 'portage')
    - openstack_host_ca_cert_copy is changed

- name: Update CA store - Centos
  command: update-ca-trust
  when:
    - ansible_pkg_mgr == 'yum'
    - openstack_host_ca_cert_copy is changed