kolla-ansible/ansible/roles/horizon/tasks/config.yml
Duong Ha-Quang 2d3866c6a4 Specify 'become' for only necessary tasks (default roles)
Add become to only neccesary tasks in roles:
- glance
- heat
- horizon
- keystone
- neutron
- nova
- openvswitch

Gate is also updated to use 'become' feature

Change-Id: I2f3f27306e9f384148e1ad4d54d8da2ebef34d00
Partial-Implements: blueprint ansible-specific-task-become
2017-10-31 02:55:31 +00:00

134 lines
4.6 KiB
YAML

---
- name: Ensuring config directories exist
become: true
file:
path: "{{ node_config_directory }}/{{ item.key }}"
state: "directory"
owner: "{{ config_owner_user }}"
group: "{{ config_owner_group }}"
mode: "0770"
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ horizon_services }}"
- name: Copying over config.json files for services
become: true
vars:
horizon: "{{ horizon_services['horizon'] }}"
template:
src: "horizon.json.j2"
dest: "{{ node_config_directory }}/horizon/config.json"
mode: "0660"
register: horizon_config_json
when:
- horizon.enabled | bool
- inventory_hostname in groups[horizon.group]
notify:
- Restart horizon container
- name: Copying over horizon.conf
become: true
vars:
horizon: "{{ horizon_services['horizon'] }}"
template:
src: "{{ item }}"
dest: "{{ node_config_directory }}/horizon/horizon.conf"
mode: "0660"
register: horizon_conf
with_first_found:
- "{{ node_custom_config }}/horizon/{{ inventory_hostname }}/horizon.conf"
- "{{ node_custom_config }}/horizon/horizon.conf"
- "horizon.conf.j2"
when:
- horizon.enabled | bool
- inventory_hostname in groups[horizon.group]
notify:
- Restart horizon container
- name: Copying over local_settings
become: true
vars:
horizon: "{{ horizon_services['horizon'] }}"
template:
src: "{{ item }}"
dest: "{{ node_config_directory }}/horizon/local_settings"
mode: "0660"
with_first_found:
- "{{ node_custom_config }}/horizon/{{ inventory_hostname }}/local_settings"
- "{{ node_custom_config }}/horizon/local_settings"
- "local_settings.j2"
register: horizon_local_settings
when:
- horizon.enabled | bool
- inventory_hostname in groups[horizon.group]
notify:
- Restart horizon container
- name: Check if policies shall be overwritten
local_action: stat path="{{ node_custom_config }}/horizon/{{ item.name }}_policy.json"
run_once: True
register: custom_policy
when: item.enabled | bool
with_items:
- { name: "ceilometer", enabled: "{{ enable_ceilometer }}" }
- { name: "cinder", enabled: "{{ enable_cinder }}" }
- { name: "cloudkitty", enabled: "{{ enable_horizon_cloudkitty }}" }
- { name: "designate", enabled: "{{ enable_horizon_designate }}" }
- { name: "freezer", enabled: "{{ enable_horizon_freezer }}" }
- { name: "glance", enabled: "{{ enable_glance }}" }
- { name: "heat", enabled: "{{ enable_heat }}" }
- { name: "ironic", enabled: "{{ enable_horizon_ironic }}" }
- { name: "keystone", enabled: "{{ enable_keystone }}" }
- { name: "karbor", enabled: "{{ enable_horizon_karbor }}" }
- { name: "magnum", enabled: "{{ enable_horizon_magnum }}" }
- { name: "manila", enabled: "{{ enable_horizon_manila }}" }
- { name: "mistral", enabled: "{{ enable_horizon_mistral }}" }
- { name: "murano", enabled: "{{ enable_horizon_murano }}" }
- { name: "neutron", enabled: "{{ enable_neutron }}" }
- { name: "nova", enabled: "{{ enable_nova }}" }
- { name: "sahara", enabled: "{{ enable_horizon_sahara }}" }
- { name: "searchlight", enabled: "{{ enable_horizon_searchlight }}" }
- { name: "senlin", enabled: "{{ enable_horizon_senlin }}" }
- { name: "solum", enabled: "{{ enable_horizon_solum }}" }
- { name: "tacker", enabled: "{{ enable_horizon_tacker }}" }
- { name: "trove", enabled: "{{ enable_horizon_trove }}" }
- { name: "watcher", enabled: "{{ enable_horizon_watcher }}" }
- name: Copying over existing policy.json
become: true
vars:
horizon: "{{ horizon_services['horizon'] }}"
template:
src: "{{ node_custom_config }}/horizon/{{ item.item.name }}_policy.json"
dest: "{{ node_config_directory }}/horizon/{{ item.item.name }}_policy.json"
mode: "0660"
register: policy_jsons
when:
- horizon.enabled | bool
- inventory_hostname in groups[horizon.group]
- item.item.enabled | bool
- item.stat.exists
with_items: "{{ custom_policy.results }}"
notify:
- Restart horizon container
- name: Check horizon container
vars:
horizon: "{{ horizon_services['horizon'] }}"
kolla_docker:
action: "compare_container"
common_options: "{{ docker_common_options }}"
name: "{{ horizon.container_name }}"
image: "{{ horizon.image }}"
environment: "{{ horizon.environment }}"
volumes: "{{ horizon.volumes }}"
register: check_horizon_container
when:
- action != "config"
- inventory_hostname in groups[horizon.group]
- horizon.enabled | bool
notify:
- Restart horizon container