Optimize reconfiguration for multipathd
Change-Id: I288fa5ea202376d481de6966150e7e050e390f03 Partially-implements: blueprint better-reconfigure Co-Authored-By: caoyuan <cao.yuan@99cloud.net> Closes-Bug: #1796219
This commit is contained in:
parent
a4d9188208
commit
13f8aef9f8
@ -1,6 +1,27 @@
|
|||||||
---
|
---
|
||||||
project_name: "multipathd"
|
project_name: "multipathd"
|
||||||
|
|
||||||
|
multipathd_services:
|
||||||
|
multipathd:
|
||||||
|
container_name: multipathd
|
||||||
|
group: multipathd
|
||||||
|
enabled: true
|
||||||
|
ipc_mode: "host"
|
||||||
|
privileged: True
|
||||||
|
image: "{{ multipathd_image_full }}"
|
||||||
|
volumes:
|
||||||
|
- "{{ node_config_directory }}/multipathd/:{{ container_config_directory }}/:ro"
|
||||||
|
- "kolla_logs:/var/log/kolla/"
|
||||||
|
- "/etc/localtime:/etc/localtime:ro"
|
||||||
|
- "/dev/:/dev/"
|
||||||
|
- "/run/:/run/:shared"
|
||||||
|
- "/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||||
|
- "/lib/modules:/lib/modules:ro"
|
||||||
|
- "/sys/kernel/config:/configfs"
|
||||||
|
- "cinder:/var/lib/cinder"
|
||||||
|
- "iscsi_info:/etc/iscsi"
|
||||||
|
|
||||||
|
|
||||||
####################
|
####################
|
||||||
# Docker
|
# Docker
|
||||||
####################
|
####################
|
||||||
|
24
ansible/roles/multipathd/handlers/main.yml
Normal file
24
ansible/roles/multipathd/handlers/main.yml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
- name: Restart multipathd container
|
||||||
|
vars:
|
||||||
|
service_name: "multipathd"
|
||||||
|
service: "{{ multipathd_services[service_name] }}"
|
||||||
|
config_json: "{{ multipathd_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||||
|
multipathd_conf: "{{ multipathd_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||||
|
multipathd_container: "{{ check_multipathd_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||||
|
become: true
|
||||||
|
kolla_docker:
|
||||||
|
action: "recreate_or_restart_container"
|
||||||
|
common_options: "{{ docker_common_options }}"
|
||||||
|
name: "{{ service.container_name }}"
|
||||||
|
image: "{{ service.image }}"
|
||||||
|
ipc_mode: "{{ service.ipc_mode }}"
|
||||||
|
privileged: "{{ service.privileged }}"
|
||||||
|
volumes: "{{ service.volumes|reject('equalto', '')|list }}"
|
||||||
|
when:
|
||||||
|
- kolla_action != "config"
|
||||||
|
- inventory_hostname in groups[service.group]
|
||||||
|
- service.enabled | bool
|
||||||
|
- config_json.changed | bool
|
||||||
|
or multipathd_conf.changed | bool
|
||||||
|
or multipathd_container.changed | bool
|
@ -1,31 +1,59 @@
|
|||||||
---
|
---
|
||||||
- name: Ensuring config directories exist
|
- name: Ensuring config directories exist
|
||||||
file:
|
file:
|
||||||
path: "{{ node_config_directory }}/{{ item }}"
|
path: "{{ node_config_directory }}/{{ item.key }}"
|
||||||
state: "directory"
|
state: "directory"
|
||||||
owner: "{{ config_owner_user }}"
|
owner: "{{ config_owner_user }}"
|
||||||
group: "{{ config_owner_group }}"
|
group: "{{ config_owner_group }}"
|
||||||
mode: "0770"
|
mode: "0770"
|
||||||
become: true
|
become: true
|
||||||
when: inventory_hostname in groups['multipathd']
|
when:
|
||||||
with_items:
|
- inventory_hostname in groups[item.value.group]
|
||||||
- "multipathd"
|
- item.value.enabled | bool
|
||||||
|
with_dict: "{{ multipathd_services }}"
|
||||||
|
|
||||||
- name: Copying over config.json files for services
|
- name: Copying over config.json files for services
|
||||||
template:
|
template:
|
||||||
src: "{{ item }}.json.j2"
|
src: "{{ item.key }}.json.j2"
|
||||||
dest: "{{ node_config_directory }}/{{ item }}/config.json"
|
dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
|
||||||
mode: "0660"
|
mode: "0660"
|
||||||
become: true
|
become: true
|
||||||
when: inventory_hostname in groups['multipathd']
|
register: multipathd_config_jsons
|
||||||
with_items:
|
when:
|
||||||
- "multipathd"
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- item.value.enabled | bool
|
||||||
|
with_dict: "{{ multipathd_services }}"
|
||||||
|
notify:
|
||||||
|
- Restart multipathd container
|
||||||
|
|
||||||
- name: Copying over multipath.conf
|
- name: Copying over multipath.conf
|
||||||
template:
|
template:
|
||||||
src: "{{ role_path }}/templates/multipath.conf.j2"
|
src: "multipath.conf.j2"
|
||||||
dest: "{{ node_config_directory }}/{{ item }}/multipath.conf"
|
dest: "{{ node_config_directory }}/{{ item.key }}/multipath.conf"
|
||||||
mode: "0660"
|
mode: "0660"
|
||||||
become: true
|
become: true
|
||||||
with_items:
|
register: multipathd_confs
|
||||||
- "multipathd"
|
when:
|
||||||
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- item.value.enabled | bool
|
||||||
|
with_dict: "{{ multipathd_services }}"
|
||||||
|
notify:
|
||||||
|
- Restart multipathd container
|
||||||
|
|
||||||
|
- name: Check multipathd containers
|
||||||
|
kolla_docker:
|
||||||
|
action: "compare_container"
|
||||||
|
common_options: "{{ docker_common_options }}"
|
||||||
|
name: "{{ item.value.container_name }}"
|
||||||
|
image: "{{ item.value.image }}"
|
||||||
|
ipc_mode: "{{ item.value.ipc_mode }}"
|
||||||
|
privileged: "{{ item.value.privileged | default(False) }}"
|
||||||
|
volumes: "{{ item.value.volumes }}"
|
||||||
|
register: check_multipathd_containers
|
||||||
|
when:
|
||||||
|
- kolla_action != "config"
|
||||||
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- item.value.enabled | bool
|
||||||
|
with_dict: "{{ multipathd_services }}"
|
||||||
|
notify:
|
||||||
|
- Restart multipathd container
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
---
|
---
|
||||||
- include_tasks: config.yml
|
- include_tasks: config.yml
|
||||||
|
|
||||||
- include_tasks: start.yml
|
- name: Flush handlers
|
||||||
|
meta: flush_handlers
|
||||||
|
@ -4,5 +4,8 @@
|
|||||||
kolla_docker:
|
kolla_docker:
|
||||||
action: "pull_image"
|
action: "pull_image"
|
||||||
common_options: "{{ docker_common_options }}"
|
common_options: "{{ docker_common_options }}"
|
||||||
image: "{{ multipathd_image_full }}"
|
image: "{{ item.value.image }}"
|
||||||
when: inventory_hostname in groups['multipathd']
|
when:
|
||||||
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- item.value.enabled | bool
|
||||||
|
with_dict: "{{ multipathd_services }}"
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Starting multipathd container
|
|
||||||
become: true
|
|
||||||
kolla_docker:
|
|
||||||
action: "start_container"
|
|
||||||
common_options: "{{ docker_common_options }}"
|
|
||||||
image: "{{ multipathd_image_full }}"
|
|
||||||
name: "multipathd"
|
|
||||||
ipc_mode: "host"
|
|
||||||
privileged: True
|
|
||||||
volumes:
|
|
||||||
- "{{ node_config_directory }}/multipathd/:{{ container_config_directory }}/:ro"
|
|
||||||
- "kolla_logs:/var/log/kolla/"
|
|
||||||
- "/etc/localtime:/etc/localtime:ro"
|
|
||||||
- "/dev/:/dev/"
|
|
||||||
- "/run/:/run/:shared"
|
|
||||||
- "/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
|
||||||
- "/lib/modules:/lib/modules:ro"
|
|
||||||
- "/sys/kernel/config:/configfs"
|
|
||||||
- "cinder:/var/lib/cinder"
|
|
||||||
- "iscsi_info:/etc/iscsi"
|
|
||||||
when: inventory_hostname in groups['multipathd']
|
|
@ -1,4 +1,5 @@
|
|||||||
---
|
---
|
||||||
- include_tasks: config.yml
|
- include_tasks: config.yml
|
||||||
|
|
||||||
- include_tasks: start.yml
|
- name: Flush handlers
|
||||||
|
meta: flush_handlers
|
||||||
|
Loading…
Reference in New Issue
Block a user