Merge "Add policy.yaml support for blazar role"

This commit is contained in:
Zuul 2018-02-21 09:16:25 +00:00 committed by Gerrit Code Review
commit b3a8632d5e
4 changed files with 37 additions and 22 deletions

View File

@ -9,6 +9,23 @@
- item.value.enabled | bool - item.value.enabled | bool
with_dict: "{{ blazar_services }}" 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 - name: Copying over config.json files for services
template: template:
src: "{{ item.key }}.json.j2" src: "{{ item.key }}.json.j2"
@ -42,19 +59,14 @@
- Restart blazar-api container - Restart blazar-api container
- Restart blazar-manager container - Restart blazar-manager container
- name: Check if policies shall be overwritten - name: Copying over existing policy file
local_action: stat path="{{ node_custom_config }}/blazar/policy.json"
register: blazar_policy
- name: Copying over existing policy.json
template: template:
src: "{{ node_custom_config }}/blazar/policy.json" src: "{{ blazar_policy_file_path }}"
dest: "{{ node_config_directory }}/{{ item.key }}/policy.json" dest: "{{ node_config_directory }}/{{ item.key }}/{{ blazar_policy_file }}"
register: blazar_policy_jsons register: blazar_policy_overwriting
when: when:
- blazar_policy.stat.exists - blazar_policy_file is defined
- inventory_hostname in groups[item.value.group] - inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ blazar_services }}" with_dict: "{{ blazar_services }}"
notify: notify:
- Restart blazar-api container - Restart blazar-api container

View File

@ -6,14 +6,13 @@
"dest": "/etc/blazar/blazar.conf", "dest": "/etc/blazar/blazar.conf",
"owner": "blazar", "owner": "blazar",
"perm": "0600" "perm": "0600"
}, }{% if blazar_policy_file is defined %},
{ {
"source": "{{ container_config_directory }}/policy.json", "source": "{{ container_config_directory }}/{{ blazar_policy_file }}",
"dest": "/etc/blazar/policy.json", "dest": "/etc/blazar/{{ blazar_policy_file }}",
"owner": "blazar", "owner": "blazar",
"perm": "0600", "perm": "0600"
"optional": true }{% endif %}
}
], ],
"permissions": [ "permissions": [
{ {

View File

@ -6,14 +6,13 @@
"dest": "/etc/blazar/blazar.conf", "dest": "/etc/blazar/blazar.conf",
"owner": "blazar", "owner": "blazar",
"perm": "0600" "perm": "0600"
}, }{% if blazar_policy_file is defined %},
{ {
"source": "{{ container_config_directory }}/policy.json", "source": "{{ container_config_directory }}/{{ blazar_policy_file }}",
"dest": "/etc/blazar/policy.json", "dest": "/etc/blazar/{{ blazar_policy_file }}",
"owner": "blazar", "owner": "blazar",
"perm": "0600", "perm": "0600"
"optional": true }{% endif %}
}
], ],
"permissions": [ "permissions": [
{ {

View File

@ -56,3 +56,8 @@ topics = notifications
{% else %} {% else %}
driver = noop driver = noop
{% endif %} {% endif %}
{% if blazar_policy_file is defined %}
[oslo_policy]
policy_file = {{ blazar_policy_file }}
{% endif %}