Merge "Optimize reconfiguration for multipathd"

This commit is contained in:
Zuul 2018-10-22 14:51:09 +00:00 committed by Gerrit Code Review
commit 3d6df2eaf4
7 changed files with 95 additions and 39 deletions

View File

@ -1,6 +1,27 @@
---
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
####################

View 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

View File

@ -1,31 +1,59 @@
---
- name: Ensuring config directories exist
file:
path: "{{ node_config_directory }}/{{ item }}"
path: "{{ node_config_directory }}/{{ item.key }}"
state: "directory"
owner: "{{ config_owner_user }}"
group: "{{ config_owner_group }}"
mode: "0770"
become: true
when: inventory_hostname in groups['multipathd']
with_items:
- "multipathd"
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ multipathd_services }}"
- name: Copying over config.json files for services
template:
src: "{{ item }}.json.j2"
dest: "{{ node_config_directory }}/{{ item }}/config.json"
src: "{{ item.key }}.json.j2"
dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
mode: "0660"
become: true
when: inventory_hostname in groups['multipathd']
with_items:
- "multipathd"
register: multipathd_config_jsons
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ multipathd_services }}"
notify:
- Restart multipathd container
- name: Copying over multipath.conf
template:
src: "{{ role_path }}/templates/multipath.conf.j2"
dest: "{{ node_config_directory }}/{{ item }}/multipath.conf"
src: "multipath.conf.j2"
dest: "{{ node_config_directory }}/{{ item.key }}/multipath.conf"
mode: "0660"
become: true
with_items:
- "multipathd"
register: multipathd_confs
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

View File

@ -1,4 +1,5 @@
---
- include_tasks: config.yml
- include_tasks: start.yml
- name: Flush handlers
meta: flush_handlers

View File

@ -4,5 +4,8 @@
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ multipathd_image_full }}"
when: inventory_hostname in groups['multipathd']
image: "{{ item.value.image }}"
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ multipathd_services }}"

View File

@ -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']

View File

@ -1,4 +1,5 @@
---
- include_tasks: config.yml
- include_tasks: start.yml
- name: Flush handlers
meta: flush_handlers