diff --git a/ansible/roles/blazar/tasks/config.yml b/ansible/roles/blazar/tasks/config.yml index 472de1b7bae50ba52aea23af79b4a9bd1b75a5e4..26a23ebd9af8444639da2d7cac35083b420e616c 100644 --- a/ansible/roles/blazar/tasks/config.yml +++ b/ansible/roles/blazar/tasks/config.yml @@ -9,6 +9,23 @@ - item.value.enabled | bool with_dict: "{{ blazar_services }}" +- name: Check if policies shall be overwritten + local_action: stat path="{{ item }}" + run_once: True + register: blazar_policy + with_first_found: + - files: "{{ supported_policy_format_list }}" + paths: + - "{{ node_custom_config }}/blazar/" + skip: true + +- name: Set blazar policy file + set_fact: + blazar_policy_file: "{{ blazar_policy.results.0.stat.path | basename }}" + blazar_policy_file_path: "{{ blazar_policy.results.0.stat.path }}" + when: + - blazar_policy.results + - name: Copying over config.json files for services template: src: "{{ item.key }}.json.j2" @@ -42,19 +59,14 @@ - Restart blazar-api container - Restart blazar-manager container -- name: Check if policies shall be overwritten - local_action: stat path="{{ node_custom_config }}/blazar/policy.json" - register: blazar_policy - -- name: Copying over existing policy.json +- name: Copying over existing policy file template: - src: "{{ node_custom_config }}/blazar/policy.json" - dest: "{{ node_config_directory }}/{{ item.key }}/policy.json" - register: blazar_policy_jsons + src: "{{ blazar_policy_file_path }}" + dest: "{{ node_config_directory }}/{{ item.key }}/{{ blazar_policy_file }}" + register: blazar_policy_overwriting when: - - blazar_policy.stat.exists + - blazar_policy_file is defined - inventory_hostname in groups[item.value.group] - - item.value.enabled | bool with_dict: "{{ blazar_services }}" notify: - Restart blazar-api container diff --git a/ansible/roles/blazar/templates/blazar-api.json.j2 b/ansible/roles/blazar/templates/blazar-api.json.j2 index 12468e54ba9770f8c5e5ede2da85d34710ca9a55..02a8e075913f94daa0f457a1f4c5b47b37a85f55 100644 --- a/ansible/roles/blazar/templates/blazar-api.json.j2 +++ b/ansible/roles/blazar/templates/blazar-api.json.j2 @@ -6,14 +6,13 @@ "dest": "/etc/blazar/blazar.conf", "owner": "blazar", "perm": "0600" - }, + }{% if blazar_policy_file is defined %}, { - "source": "{{ container_config_directory }}/policy.json", - "dest": "/etc/blazar/policy.json", + "source": "{{ container_config_directory }}/{{ blazar_policy_file }}", + "dest": "/etc/blazar/{{ blazar_policy_file }}", "owner": "blazar", - "perm": "0600", - "optional": true - } + "perm": "0600" + }{% endif %} ], "permissions": [ { diff --git a/ansible/roles/blazar/templates/blazar-manager.json.j2 b/ansible/roles/blazar/templates/blazar-manager.json.j2 index 6bd74e752bf5e8568d51bae283cc433481c2b133..8dda3afbd4a8c842ab71a5b8efd56f5ec7b956b0 100644 --- a/ansible/roles/blazar/templates/blazar-manager.json.j2 +++ b/ansible/roles/blazar/templates/blazar-manager.json.j2 @@ -6,14 +6,13 @@ "dest": "/etc/blazar/blazar.conf", "owner": "blazar", "perm": "0600" - }, + }{% if blazar_policy_file is defined %}, { - "source": "{{ container_config_directory }}/policy.json", - "dest": "/etc/blazar/policy.json", + "source": "{{ container_config_directory }}/{{ blazar_policy_file }}", + "dest": "/etc/blazar/{{ blazar_policy_file }}", "owner": "blazar", - "perm": "0600", - "optional": true - } + "perm": "0600" + }{% endif %} ], "permissions": [ { diff --git a/ansible/roles/blazar/templates/blazar.conf.j2 b/ansible/roles/blazar/templates/blazar.conf.j2 index e62171f9f73df58b7a1e64a34d9f9cf7a4b664d2..53380195ec71f53e87004eb4e019dc531d6ee4eb 100644 --- a/ansible/roles/blazar/templates/blazar.conf.j2 +++ b/ansible/roles/blazar/templates/blazar.conf.j2 @@ -56,3 +56,8 @@ topics = notifications {% else %} driver = noop {% endif %} + +{% if blazar_policy_file is defined %} +[oslo_policy] +policy_file = {{ blazar_policy_file }} +{% endif %}