Optimize reconfigure action for iscsi

Complete the reconfigure optimise action for iscsi

Co-Authored-By: caoyuan <cao.yuan@99cloud.net>
Co-Authored-By: mgoddard <mark@stackhpc.com>

Change-Id: I6a1f24bc13bdea148857de9e6f4df79ff97bc9bc
Partially-implements: blueprint better-reconfigure
Closes-Bug: #1772215
This commit is contained in:
ZhijunWei 2018-05-19 23:19:53 +00:00 committed by caoyuan
parent 23c555d9c5
commit 1989cfe103
10 changed files with 139 additions and 121 deletions

View File

@ -1,6 +1,47 @@
---
project_name: "iscsi"
iscsi_services:
iscsid:
container_name: iscsid
group: iscsid
enabled: "{{ enable_iscsid_for_cinder or enable_iscsid_for_ironic }}"
image: "{{ iscsid_image_full }}"
ipc_mode: "host"
privileged: True
volumes:
- "{{ node_config_directory }}/iscsid/:{{ 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"
dimensions: "{{ iscsid_dimensions }}"
tgtd:
container_name: tgtd
group: tgtd
enabled: "{{ enable_tgtd }}"
image: "{{ tgtd_image_full }}"
ipc_mode: "host"
privileged: True
volumes:
- "{{ node_config_directory }}/tgtd/:{{ 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"
dimensions: "{{ tgtd_dimensions }}"
####################
# Docker
####################
@ -14,3 +55,18 @@ iscsid_image_full: "{{ iscsid_image }}:{{ iscsid_tag }}"
tgtd_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ iscsi_install_type }}-tgtd"
tgtd_tag: "{{ iscsi_tag }}"
tgtd_image_full: "{{ tgtd_image }}:{{ tgtd_tag }}"
iscsid_dimensions: "{{ default_container_dimensions }}"
tgtd_dimensions: "{{ default_container_dimensions }}"
enable_iscsid_for_cinder: >-
{{ (inventory_hostname in groups['compute']
or inventory_hostname in groups['cinder-volume'])
and enable_cinder | bool
and enable_cinder_backend_iscsi | bool }}
enable_iscsid_for_ironic: >-
{{ inventory_hostname in groups['ironic-conductor'] and enable_ironic | bool }}
enable_tgtd: >-
{{ enable_cinder | bool and
enable_cinder_backend_lvm | bool and
cinder_iscsi_helper == "tgtadm" }}

View File

@ -0,0 +1,34 @@
---
- name: Restart iscsid container
vars:
service_name: "iscsid"
service: "{{ iscsi_services[service_name] }}"
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 }}"
dimensions: "{{ service.dimensions }}"
when:
- kolla_action != "config"
- name: Restart tgtd container
vars:
service_name: "tgtd"
service: "{{ iscsi_services[service_name] }}"
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 }}"
dimensions: "{{ service.dimensions }}"
when:
- kolla_action != "config"

View File

@ -5,55 +5,50 @@
vars:
modules:
- name: configfs
when: ( ( inventory_hostname in groups['compute'] or inventory_hostname in groups['cinder-volume'] ) and enable_cinder | bool and enable_cinder_backend_iscsi | bool )
or ( inventory_hostname in groups['ironic-conductor'] and enable_ironic | bool )
when:
- inventory_hostname in groups[iscsi_services.iscsid.group]
- iscsi_services.iscsid.enabled | bool
- name: Ensuring config directories exist
file:
path: "{{ node_config_directory }}/{{ item }}"
state: "directory"
owner: "{{ config_owner_user }}"
group: "{{ config_owner_group }}"
mode: "0770"
become: true
when: ( ( inventory_hostname in groups['compute'] or inventory_hostname in groups['cinder-volume'] ) and enable_cinder | bool and enable_cinder_backend_iscsi | bool )
or ( inventory_hostname in groups['ironic-conductor'] and enable_ironic | bool )
with_items:
- "iscsid"
- name: Copying over config.json files for services
template:
src: "{{ item }}.json.j2"
dest: "{{ node_config_directory }}/{{ item }}/config.json"
mode: "0660"
become: true
when: ( ( inventory_hostname in groups['compute'] or inventory_hostname in groups['cinder-volume'] ) and enable_cinder | bool and enable_cinder_backend_iscsi | bool )
or ( inventory_hostname in groups['ironic-conductor'] and enable_ironic | bool )
with_items:
- "iscsid"
- 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:
- enable_cinder_backend_lvm | bool
- inventory_hostname in groups['tgtd']
with_items:
- "tgtd"
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ iscsi_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:
- enable_cinder_backend_lvm | bool
- inventory_hostname in groups['tgtd']
with_items:
- "tgtd"
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ iscsi_services }}"
notify:
- "Restart {{ item.key }} container"
- name: Check iscsi 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 }}"
dimensions: "{{ item.value.dimensions }}"
when:
- kolla_action != "config"
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ iscsi_services }}"
notify:
- "Restart {{ item.key }} container"

View File

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

View File

@ -14,4 +14,5 @@
state: stopped
when:
- container_facts['iscsid'] is not defined
- inventory_hostname in groups['iscsid']
- inventory_hostname in groups[iscsi_services.iscsid.group]
- iscsi_services.iscsid.enabled | bool

View File

@ -1,16 +1,10 @@
---
- name: Pulling iscsid image
become: true
- name: Pulling iscsi images
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ iscsid_image_full }}"
when: inventory_hostname in groups['iscsid']
- name: Pulling tgtd image
become: true
kolla_docker:
action: "pull_image"
common_options: "{{ docker_common_options }}"
image: "{{ tgtd_image_full }}"
when: inventory_hostname in groups['tgtd']
image: "{{ item.value.image }}"
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ iscsi_services }}"

View File

@ -1 +1,2 @@
---
- include_tasks: deploy.yml

View File

@ -1,49 +0,0 @@
---
- name: Starting iscsid container
become: true
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ iscsid_image_full }}"
name: "iscsid"
ipc_mode: "host"
privileged: True
volumes:
- "{{ node_config_directory }}/iscsid/:{{ 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['compute'] or inventory_hostname in groups['cinder-volume'] ) and enable_cinder | bool and enable_cinder_backend_iscsi | bool )
or ( inventory_hostname in groups['ironic-conductor'] and enable_ironic | bool )
- name: Starting tgtd container
become: true
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ tgtd_image_full }}"
name: "tgtd"
ipc_mode: "host"
privileged: True
volumes:
- "{{ node_config_directory }}/tgtd/:{{ 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['tgtd']
- enable_cinder | bool
- enable_cinder_backend_lvm | bool
- cinder_iscsi_helper == "tgtadm"

View File

@ -1,19 +1,6 @@
---
- name: Stopping iscsid container
kolla_docker:
action: "stop_container"
common_options: "{{ docker_common_options }}"
name: "iscsid"
when: ( ( inventory_hostname in groups['compute'] or inventory_hostname in groups['cinder-volume'] ) and enable_cinder | bool and enable_cinder_backend_iscsi | bool )
or ( inventory_hostname in groups['ironic-conductor'] and enable_ironic | bool and 'iscsid' not in skip_stop_containers)
- name: Stopping tgtd container
kolla_docker:
action: "stop_container"
common_options: "{{ docker_common_options }}"
name: "tgtd"
when:
- inventory_hostname in groups['tgtd']
- enable_cinder | bool
- enable_cinder_backend_lvm | bool
- "'tgtd' not in skip_stop_containers"
- import_role:
role: service-stop
vars:
project_services: "{{ iscsi_services }}"
service_name: "{{ project_name }}"

View File

@ -1,4 +1,2 @@
---
- include_tasks: config.yml
- include_tasks: start.yml
- include_tasks: deploy.yml