From e65f4ec7cd8b1f079e09555e72c02022d305033d Mon Sep 17 00:00:00 2001 From: Mohamed El Gindi Date: Thu, 14 Feb 2019 08:52:33 -0800 Subject: [PATCH] Karbor providers managed from deployment node Karbor provider configs can be injected/managed from 'node_custom_config' var openstack-infra.conf will still be created if no custom providers present Closes-Bug #1814464 Change-Id: I500daae80596cb7b7342fd8d4affa8f901b24a13 --- ansible/roles/karbor/handlers/main.yml | 1 + ansible/roles/karbor/tasks/config.yml | 24 +++++++++++++++++-- .../templates/karbor-protection.json.j2 | 4 ++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/ansible/roles/karbor/handlers/main.yml b/ansible/roles/karbor/handlers/main.yml index 40a1f4e74a..9dcd077400 100644 --- a/ansible/roles/karbor/handlers/main.yml +++ b/ansible/roles/karbor/handlers/main.yml @@ -43,6 +43,7 @@ - service.enabled | bool - config_json.changed | bool or karbor_conf.changed | bool + or providers_conf.changed or openstack_infra_conf.changed | bool or karbor_protection_container.changed | bool diff --git a/ansible/roles/karbor/tasks/config.yml b/ansible/roles/karbor/tasks/config.yml index dc84ef1517..be84f3c0db 100644 --- a/ansible/roles/karbor/tasks/config.yml +++ b/ansible/roles/karbor/tasks/config.yml @@ -51,12 +51,32 @@ - Restart karbor-protection container - Restart karbor-operationengine container +- name: Copying over provider configs + vars: + service_name: 'karbor-protection' + service: "{{ karbor_services[service_name] }}" + copy: + src: "{{ item }}" + dest: "{{ node_config_directory }}/{{ service_name }}/providers.d/" + mode: "0660" + become: true + with_fileglob: + - "{{ node_custom_config }}/karbor/{{ service_name }}/providers.d/*" + register: providers_conf + when: + - inventory_hostname in groups[service.group] + - service.enabled | bool + notify: + - Restart karbor-protection container + - name: Copying over openstack-infra.conf vars: service_name: 'karbor-protection' service: "{{ karbor_services[service_name] }}" - template: - src: "providers.d/openstack-infra.conf.j2" + merge_configs: + sources: + - "{{ role_path }}/templates/providers.d/openstack-infra.conf.j2" + - "{{ node_custom_config }}/karbor/{{ service_name }}/providers.d/openstack-infra.conf" dest: "{{ node_config_directory }}/{{ service_name }}/providers.d/openstack-infra.conf" mode: "0660" become: true diff --git a/ansible/roles/karbor/templates/karbor-protection.json.j2 b/ansible/roles/karbor/templates/karbor-protection.json.j2 index 304aece619..e83b0eb722 100644 --- a/ansible/roles/karbor/templates/karbor-protection.json.j2 +++ b/ansible/roles/karbor/templates/karbor-protection.json.j2 @@ -8,8 +8,8 @@ "perm": "0600" }, { - "source": "{{ container_config_directory }}/providers.d/openstack-infra.conf", - "dest": "/etc/karbor/providers.d/openstack-infra.conf", + "source": "{{ container_config_directory }}/providers.d/*", + "dest": "/etc/karbor/providers.d/", "owner": "karbor", "perm": "0600" }