Optimize reconfigure action for manila
Change-Id: Ia4dcc5eddd2b18a4b9b36d9bd809c405d4f92b27 Co-Authored-By: caoyuan <cao.yuan@99cloud.net> Co-Authored-By: Francisco Edigleison Barbosa <barbosaedigleison@gmail.com> Partially-implements: blueprint better-reconfigure
This commit is contained in:
parent
463e5a2f1c
commit
035ab8b79b
@ -1,7 +1,50 @@
|
||||
---
|
||||
project_name: "manila"
|
||||
|
||||
####################
|
||||
manila_services:
|
||||
manila-api:
|
||||
container_name: "manila_api"
|
||||
group: "manila-api"
|
||||
image: "{{ manila_api_image_full }}"
|
||||
enabled: True
|
||||
volumes:
|
||||
- "{{ node_config_directory }}/manila-api/:{{ container_config_directory }}/:ro"
|
||||
- "/etc/localtime:/etc/localtime:ro"
|
||||
- "kolla_logs:/var/log/kolla/"
|
||||
manila-scheduler:
|
||||
container_name: "manila_scheduler"
|
||||
group: "manila-scheduler"
|
||||
image: "{{ manila_scheduler_image_full }}"
|
||||
enabled: True
|
||||
volumes:
|
||||
- "{{ node_config_directory }}/manila-scheduler/:{{ container_config_directory }}/:ro"
|
||||
- "/etc/localtime:/etc/localtime:ro"
|
||||
- "kolla_logs:/var/log/kolla/"
|
||||
manila-share:
|
||||
container_name: "manila_share"
|
||||
group: "manila-share"
|
||||
image: "{{ manila_share_image_full }}"
|
||||
enabled: True
|
||||
privileged: True
|
||||
volumes:
|
||||
- "{{ node_config_directory }}/manila-share/:{{ container_config_directory }}/:ro"
|
||||
- "/etc/localtime:/etc/localtime:ro"
|
||||
- "/run/:/run/:shared"
|
||||
- "kolla_logs:/var/log/kolla/"
|
||||
manila-data:
|
||||
container_name: "manila_data"
|
||||
group: "manila-data"
|
||||
image: "{{ manila_data_image_full }}"
|
||||
enabled: True
|
||||
privileged: True
|
||||
volumes:
|
||||
- "{{ node_config_directory }}/manila-data/:{{ container_config_directory }}/:ro"
|
||||
- "/etc/localtime:/etc/localtime:ro"
|
||||
- "/run/:/run/:shared"
|
||||
- "kolla_logs:/var/log/kolla/"
|
||||
|
||||
|
||||
#####################
|
||||
## Database
|
||||
#####################
|
||||
manila_database_name: "manila"
|
||||
@ -28,6 +71,7 @@ manila_data_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ doc
|
||||
manila_data_tag: "{{ openstack_release }}"
|
||||
manila_data_image_full: "{{ manila_data_image }}:{{ manila_data_tag }}"
|
||||
|
||||
|
||||
#####################
|
||||
## OpenStack
|
||||
#####################
|
||||
@ -46,6 +90,7 @@ manila_service_instance_password: "manila"
|
||||
|
||||
openstack_manila_auth: "{{ openstack_auth }}"
|
||||
|
||||
|
||||
####################
|
||||
# Manila
|
||||
####################
|
||||
|
93
ansible/roles/manila/handlers/main.yml
Normal file
93
ansible/roles/manila/handlers/main.yml
Normal file
@ -0,0 +1,93 @@
|
||||
---
|
||||
- name: Restart manila-api container
|
||||
vars:
|
||||
service_name: "manila-api"
|
||||
service: "{{ manila_services[service_name] }}"
|
||||
config_json: "{{ manila_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||
manila_conf: "{{ manila_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||
policy_json: "{{ policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||
manila_api_container: "{{ check_manila_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||
kolla_docker:
|
||||
action: "recreate_or_restart_container"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
name: "{{ service.container_name }}"
|
||||
image: "{{ service.image }}"
|
||||
volumes: "{{ service.volumes|reject('equalto', '')|list }}"
|
||||
when:
|
||||
- action != "config"
|
||||
- inventory_hostname in groups[service.group]
|
||||
- service.enabled | bool
|
||||
- config_json.changed | bool
|
||||
or manila_conf.changed | bool
|
||||
or policy_json.changed | bool
|
||||
or manila_api_container.changed | bool
|
||||
|
||||
- name: Restart manila-data container
|
||||
vars:
|
||||
service_name: "manila-data"
|
||||
service: "{{ manila_services[service_name] }}"
|
||||
config_json: "{{ manila_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||
manila_conf: "{{ manila_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||
policy_json: "{{ policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||
manila_data_container: "{{ check_manila_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||
kolla_docker:
|
||||
action: "recreate_or_restart_container"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
name: "{{ service.container_name }}"
|
||||
image: "{{ service.image }}"
|
||||
privileged: "{{ service.privileged | default(False) }}"
|
||||
volumes: "{{ service.volumes|reject('equalto', '')|list }}"
|
||||
when:
|
||||
- action != "config"
|
||||
- inventory_hostname in groups[service.group]
|
||||
- service.enabled | bool
|
||||
- config_json.changed | bool
|
||||
or manila_conf.changed | bool
|
||||
or policy_json.changed | bool
|
||||
or manila_data_container.changed | bool
|
||||
|
||||
- name: Restart manila-scheduler container
|
||||
vars:
|
||||
service_name: "manila-scheduler"
|
||||
service: "{{ manila_services[service_name] }}"
|
||||
config_json: "{{ manila_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||
manila_conf: "{{ manila_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||
policy_json: "{{ policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||
manila_scheduler_container: "{{ check_manila_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||
kolla_docker:
|
||||
action: "recreate_or_restart_container"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
name: "{{ service.container_name }}"
|
||||
image: "{{ service.image }}"
|
||||
volumes: "{{ service.volumes|reject('equalto', '')|list }}"
|
||||
when:
|
||||
- action != "config"
|
||||
- inventory_hostname in groups[service.group]
|
||||
- service.enabled | bool
|
||||
- config_json.changed | bool
|
||||
or manila_conf.changed | bool
|
||||
or policy_json.changed | bool
|
||||
or manila_scheduler_container.changed | bool
|
||||
|
||||
- name: Restart manila-share container
|
||||
vars:
|
||||
service_name: "manila-share"
|
||||
service: "{{ manila_services[service_name] }}"
|
||||
config_json: "{{ manila_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||
policy_json: "{{ policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||
manila_share_container: "{{ check_manila_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||
kolla_docker:
|
||||
action: "recreate_or_restart_container"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
name: "{{ service.container_name }}"
|
||||
image: "{{ service.image }}"
|
||||
privileged: "{{ service.privileged | default(False) }}"
|
||||
volumes: "{{ service.volumes|reject('equalto', '')|list }}"
|
||||
when:
|
||||
- action != "config"
|
||||
- inventory_hostname in groups[service.group]
|
||||
- service.enabled | bool
|
||||
- config_json.changed | bool
|
||||
or manila_conf_share.changed | bool
|
||||
or policy_json.changed | bool
|
||||
or manila_share_container.changed | bool
|
@ -1,5 +1,7 @@
|
||||
---
|
||||
- name: Running Manila bootstrap container
|
||||
vars:
|
||||
manila_api: "{{ manila_services['manila-api'] }}"
|
||||
kolla_docker:
|
||||
action: "start_container"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
@ -7,14 +9,11 @@
|
||||
environment:
|
||||
KOLLA_BOOTSTRAP:
|
||||
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
|
||||
image: "{{ manila_api_image_full }}"
|
||||
image: "{{ manila_api.image }}"
|
||||
labels:
|
||||
BOOTSTRAP:
|
||||
name: "bootstrap_manila"
|
||||
restart_policy: "never"
|
||||
volumes:
|
||||
- "{{ node_config_directory }}/manila-api/:{{ container_config_directory }}/:ro"
|
||||
- "kolla_logs:/var/log/kolla/"
|
||||
- "/etc/localtime:/etc/localtime:ro"
|
||||
volumes: "{{ manila_api.volumes }}"
|
||||
run_once: True
|
||||
delegate_to: "{{ groups['manila-api'][0] }}"
|
||||
delegate_to: "{{ groups[manila_api.group][0] }}"
|
||||
|
@ -1,44 +1,53 @@
|
||||
---
|
||||
- name: Ensuring config directories exist
|
||||
file:
|
||||
path: "{{ node_config_directory }}/{{ item }}"
|
||||
path: "{{ node_config_directory }}/{{ item.key }}"
|
||||
state: "directory"
|
||||
recurse: yes
|
||||
with_items:
|
||||
- "manila-api"
|
||||
- "manila-data"
|
||||
- "manila-scheduler"
|
||||
- "manila-share"
|
||||
when:
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- item.value.enabled | bool
|
||||
with_dict: "{{ manila_services }}"
|
||||
|
||||
- name: Copying over config.json files for services
|
||||
template:
|
||||
src: "{{ item }}.json.j2"
|
||||
dest: "{{ node_config_directory }}/{{ item }}/config.json"
|
||||
with_items:
|
||||
- "manila-api"
|
||||
- "manila-data"
|
||||
- "manila-scheduler"
|
||||
- "manila-share"
|
||||
src: "{{ item.key }}.json.j2"
|
||||
dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
|
||||
register: manila_config_jsons
|
||||
when:
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- item.value.enabled | bool
|
||||
with_dict: "{{ manila_services }}"
|
||||
notify:
|
||||
- "Restart {{ item.key }} container"
|
||||
|
||||
- name: Copying over manila.conf
|
||||
merge_configs:
|
||||
vars:
|
||||
service_name: "{{ item }}"
|
||||
service_name: "{{ item.key }}"
|
||||
sources:
|
||||
- "{{ role_path }}/templates/manila.conf.j2"
|
||||
- "{{ node_custom_config }}/global.conf"
|
||||
- "{{ node_custom_config }}/database.conf"
|
||||
- "{{ node_custom_config }}/messaging.conf"
|
||||
- "{{ node_custom_config }}/manila.conf"
|
||||
- "{{ node_custom_config }}/manila/{{ item }}.conf"
|
||||
- "{{ node_custom_config }}/manila/{{ item.key }}.conf"
|
||||
- "{{ node_custom_config }}/manila/{{ inventory_hostname }}/manila.conf"
|
||||
dest: "{{ node_config_directory }}/{{ item }}/manila.conf"
|
||||
with_items:
|
||||
- "manila-api"
|
||||
- "manila-data"
|
||||
- "manila-scheduler"
|
||||
dest: "{{ node_config_directory }}/{{ item.key }}/manila.conf"
|
||||
register: manila_confs
|
||||
when:
|
||||
- item.key in [ "manila-api", "manila-data", "manila-scheduler" ]
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- item.value.enabled | bool
|
||||
with_dict: "{{ manila_services }}"
|
||||
notify:
|
||||
- Restart manila-api container
|
||||
- Restart manila-data container
|
||||
- Restart manila-scheduler container
|
||||
|
||||
- name: Copying over manila-share.conf
|
||||
vars:
|
||||
service: "{{ manila_services['manila-share'] }}"
|
||||
merge_configs:
|
||||
vars:
|
||||
service_name: "{{ item }}"
|
||||
@ -53,8 +62,14 @@
|
||||
- "{{ node_custom_config }}/manila/{{ item }}.conf"
|
||||
- "{{ node_custom_config }}/manila/{{ inventory_hostname }}/manila.conf"
|
||||
dest: "{{ node_config_directory }}/{{ item }}/manila.conf"
|
||||
register: manila_conf_share
|
||||
when:
|
||||
- inventory_hostname in groups[service.group]
|
||||
- service.enabled | bool
|
||||
with_items:
|
||||
- "manila-share"
|
||||
notify:
|
||||
- Restart manila-share container
|
||||
|
||||
- name: Check if policies shall be overwritten
|
||||
local_action: stat path="{{ node_custom_config }}/manila/policy.json"
|
||||
@ -63,11 +78,29 @@
|
||||
- name: Copying over existing policy.json
|
||||
template:
|
||||
src: "{{ node_custom_config }}/manila/policy.json"
|
||||
dest: "{{ node_config_directory }}/{{ item }}/policy.json"
|
||||
with_items:
|
||||
- "manila-api"
|
||||
- "manila-data"
|
||||
- "manila-scheduler"
|
||||
- "manila-share"
|
||||
dest: "{{ node_config_directory }}/{{ item.key }}/policy.json"
|
||||
register: policy_jsons
|
||||
when:
|
||||
manila_policy.stat.exists
|
||||
- manila_policy.stat.exists
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- item.value.enabled | bool
|
||||
with_dict: "{{ manila_services }}"
|
||||
notify:
|
||||
- "Restart {{ item.key }} container"
|
||||
|
||||
- name: Check manila containers
|
||||
kolla_docker:
|
||||
action: "compare_container"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
name: "{{ item.value.container_name }}"
|
||||
image: "{{ item.value.image }}"
|
||||
privileged: "{{ item.value.privileged|default(False) }}"
|
||||
volumes: "{{ item.value.volumes|reject('equalto', '')|list }}"
|
||||
register: check_manila_containers
|
||||
when:
|
||||
- action != "config"
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- item.value.enabled | bool
|
||||
with_dict: "{{ manila_services }}"
|
||||
notify:
|
||||
- "Restart {{ item.key }} container"
|
||||
|
@ -11,8 +11,5 @@
|
||||
- include: bootstrap.yml
|
||||
when: inventory_hostname in groups['manila-api']
|
||||
|
||||
- include: start.yml
|
||||
when: inventory_hostname in groups['manila-api'] or
|
||||
inventory_hostname in groups['manila-data'] or
|
||||
inventory_hostname in groups['manila-share'] or
|
||||
inventory_hostname in groups['manila-scheduler']
|
||||
- name: Flush handlers
|
||||
meta: flush_handlers
|
||||
|
@ -1,28 +1,10 @@
|
||||
---
|
||||
- name: Pulling manila-api image
|
||||
- name: Pulling manila images
|
||||
kolla_docker:
|
||||
action: "pull_image"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
image: "{{ manila_api_image_full }}"
|
||||
when: inventory_hostname in groups['manila-api']
|
||||
|
||||
- name: Pulling manila-scheduler image
|
||||
kolla_docker:
|
||||
action: "pull_image"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
image: "{{ manila_scheduler_image_full }}"
|
||||
when: inventory_hostname in groups['manila-scheduler']
|
||||
|
||||
- name: Pulling manila-share image
|
||||
kolla_docker:
|
||||
action: "pull_image"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
image: "{{ manila_share_image_full }}"
|
||||
when: inventory_hostname in groups['manila-share']
|
||||
|
||||
- name: Pulling manila-data image
|
||||
kolla_docker:
|
||||
action: "pull_image"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
image: "{{ manila_data_image_full }}"
|
||||
when: inventory_hostname in groups['manila-data']
|
||||
image: "{{ item.value.image }}"
|
||||
when:
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- item.value.enabled | bool
|
||||
with_dict: "{{ manila_services }}"
|
||||
|
@ -1,79 +1,2 @@
|
||||
---
|
||||
- name: Ensuring the containers up
|
||||
kolla_docker:
|
||||
name: "{{ item.name }}"
|
||||
action: "get_container_state"
|
||||
register: container_state
|
||||
failed_when: container_state.Running == false
|
||||
when: inventory_hostname in groups[item.group]
|
||||
with_items:
|
||||
- { name: manila_api, group: manila-api }
|
||||
- { name: manila_data, group: manila-data }
|
||||
- { name: manila_scheduler, group: manila-scheduler }
|
||||
- { name: manila_share, group: manila-share }
|
||||
|
||||
- include: config.yml
|
||||
|
||||
- name: Check the configs
|
||||
command: docker exec {{ item.name }} /usr/local/bin/kolla_set_configs --check
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
register: check_results
|
||||
when: inventory_hostname in groups[item.group]
|
||||
with_items:
|
||||
- { name: manila_api, group: manila-api }
|
||||
- { name: manila_data, group: manila-data }
|
||||
- { name: manila_scheduler, group: manila-scheduler }
|
||||
- { name: manila_share, group: manila-share }
|
||||
|
||||
# NOTE(jeffrey4l): when config_strategy == 'COPY_ALWAYS'
|
||||
# and container env['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE',
|
||||
# just remove the container and start again
|
||||
- name: Containers config strategy
|
||||
kolla_docker:
|
||||
name: "{{ item.name }}"
|
||||
action: "get_container_env"
|
||||
register: container_envs
|
||||
when: inventory_hostname in groups[item.group]
|
||||
with_items:
|
||||
- { name: manila_api, group: manila-api }
|
||||
- { name: manila_data, group: manila-data }
|
||||
- { name: manila_scheduler, group: manila-scheduler }
|
||||
- { name: manila_share, group: manila-share }
|
||||
|
||||
- name: Remove the containers
|
||||
kolla_docker:
|
||||
name: "{{ item[0]['name'] }}"
|
||||
action: "remove_container"
|
||||
register: remove_containers
|
||||
when:
|
||||
- inventory_hostname in groups[item[0]['group']]
|
||||
- config_strategy == "COPY_ONCE" or item[1]['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE'
|
||||
- item[2]['rc'] == 1
|
||||
with_together:
|
||||
- [{ name: manila_api, group: manila-api },
|
||||
{ name: manila_data, group: manila-data },
|
||||
{ name: manila_scheduler, group: manila-scheduler },
|
||||
{ name: manila_share, group: manila-share }]
|
||||
- "{{ container_envs.results }}"
|
||||
- "{{ check_results.results }}"
|
||||
|
||||
- include: start.yml
|
||||
when: remove_containers.changed
|
||||
|
||||
- name: Restart containers
|
||||
kolla_docker:
|
||||
name: "{{ item[0]['name'] }}"
|
||||
action: "restart_container"
|
||||
when:
|
||||
- inventory_hostname in groups[item[0]['group']]
|
||||
- config_strategy == 'COPY_ALWAYS'
|
||||
- item[1]['KOLLA_CONFIG_STRATEGY'] != 'COPY_ONCE'
|
||||
- item[2]['rc'] == 1
|
||||
with_together:
|
||||
- [{ name: manila_api, group: manila-api },
|
||||
{ name: manila_data, group: manila-data },
|
||||
{ name: manila_scheduler, group: manila-scheduler },
|
||||
{ name: manila_share, group: manila-share }]
|
||||
- "{{ container_envs.results }}"
|
||||
- "{{ check_results.results }}"
|
||||
- include: deploy.yml
|
||||
|
@ -1,52 +0,0 @@
|
||||
---
|
||||
- name: Starting manila-api container
|
||||
kolla_docker:
|
||||
action: "start_container"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
name: "manila_api"
|
||||
image: "{{ manila_api_image_full }}"
|
||||
volumes:
|
||||
- "{{ node_config_directory }}/manila-api/:{{ container_config_directory }}/:ro"
|
||||
- "/etc/localtime:/etc/localtime:ro"
|
||||
- "kolla_logs:/var/log/kolla/"
|
||||
when: inventory_hostname in groups['manila-api']
|
||||
|
||||
- name: Starting manila-scheduler container
|
||||
kolla_docker:
|
||||
action: "start_container"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
name: "manila_scheduler"
|
||||
image: "{{ manila_scheduler_image_full }}"
|
||||
volumes:
|
||||
- "{{ node_config_directory }}/manila-scheduler/:{{ container_config_directory }}/:ro"
|
||||
- "/etc/localtime:/etc/localtime:ro"
|
||||
- "kolla_logs:/var/log/kolla/"
|
||||
when: inventory_hostname in groups['manila-scheduler']
|
||||
|
||||
- name: Starting manila-share container
|
||||
kolla_docker:
|
||||
action: "start_container"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
name: "manila_share"
|
||||
image: "{{ manila_share_image_full }}"
|
||||
privileged: True
|
||||
volumes:
|
||||
- "{{ node_config_directory }}/manila-share/:{{ container_config_directory }}/:ro"
|
||||
- "/etc/localtime:/etc/localtime:ro"
|
||||
- "/run/:/run/:shared"
|
||||
- "kolla_logs:/var/log/kolla/"
|
||||
when: inventory_hostname in groups['manila-share']
|
||||
|
||||
- name: Starting manila-data container
|
||||
kolla_docker:
|
||||
action: "start_container"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
name: "manila_data"
|
||||
image: "{{ manila_data_image_full }}"
|
||||
privileged: True
|
||||
volumes:
|
||||
- "{{ node_config_directory }}/manila-data/:{{ container_config_directory }}/:ro"
|
||||
- "/etc/localtime:/etc/localtime:ro"
|
||||
- "/run/:/run/:shared"
|
||||
- "kolla_logs:/var/log/kolla/"
|
||||
when: inventory_hostname in groups['manila-data']
|
@ -3,4 +3,5 @@
|
||||
|
||||
- include: bootstrap_service.yml
|
||||
|
||||
- include: start.yml
|
||||
- name: Flush handlers
|
||||
meta: flush_handlers
|
||||
|
Loading…
Reference in New Issue
Block a user