Skip to content
Snippets Groups Projects
Commit 0b2fb2f9 authored by Jenkins's avatar Jenkins Committed by Gerrit Code Review
Browse files

Merge "Optimize reconfigure action for vmtp"

parents 6340f06b 05e87404
No related branches found
No related tags found
No related merge requests found
--- ---
project_name: "vmtp" project_name: "vmtp"
vmtp_services:
vmtp:
container_name: "vmtp"
image: "{{ vmtp_image_full }}"
enabled: true
group: "vmtp"
volumes:
- "{{ node_config_directory }}/vmtp/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla"
#################### ####################
# Docker # Docker
#################### ####################
......
- name: Restart vmtp container
vars:
service_name: "vmtp"
service: "{{ vmtp_services[service_name] }}"
vmtp_container: "{{ check_vmtp_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
- vmtp_confs.changed | bool
or vmtp_container.changed | bool
--- ---
- name: Ensuring config directories exist - name: Ensuring config directories exist
file: file:
path: "{{ node_config_directory }}/vmtp" path: "{{ node_config_directory }}/{{ item.key }}"
state: "directory" state: "directory"
recurse: yes recurse: yes
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ vmtp_services }}"
- name: Register binary python path - name: Register binary python path
command: echo /usr/lib/python2.7/site-packages command: echo /usr/lib/python2.7/site-packages
...@@ -16,11 +20,35 @@ ...@@ -16,11 +20,35 @@
when: kolla_install_type != 'binary' when: kolla_install_type != 'binary'
- name: Copying over configuration file for vmtp - name: Copying over configuration file for vmtp
vars:
service: "{{ vmtp_services['vmtp'] }}"
merge_yaml: merge_yaml:
sources: sources:
- "{{ role_path }}/templates/{{ item }}.j2" - "{{ role_path }}/templates/{{ item }}.j2"
- "{{ node_custom_config }}/{{ item }}" - "{{ node_custom_config }}/{{ item }}"
- "{{ node_custom_config }}/vmtp/{{ item }}" - "{{ node_custom_config }}/vmtp/{{ item }}"
dest: "{{ python_path }}/vmtp/{{ item }}" dest: "{{ python_path }}/vmtp/{{ item }}"
register: vmtp_confs
when:
- inventory_hostname in groups[service.group]
- service.enabled | bool
with_items: with_items:
- "cfg.default.yaml" - "cfg.default.yaml"
notify:
- Restart vmtp container
- name: Check vmtp containers
kolla_docker:
action: "compare_container"
common_options: "{{ docker_common_options }}"
name: "{{ item.value.container_name }}"
image: "{{ item.value.image }}"
volumes: "{{ item.value.volumes }}"
register: check_vmtp_containers
when:
- action != "config"
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ vmtp_services }}"
notify:
- Restart vmtp container
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
- include: config.yml - include: config.yml
when: inventory_hostname in groups['vmtp'] when: inventory_hostname in groups['vmtp']
- include: start.yml - name: Flush handlers
when: inventory_hostname in groups['vmtp'] meta: flush_handlers
...@@ -3,5 +3,8 @@ ...@@ -3,5 +3,8 @@
kolla_docker: kolla_docker:
action: "pull_image" action: "pull_image"
common_options: "{{ docker_common_options }}" common_options: "{{ docker_common_options }}"
image: "{{ vmtp_image_full }}" image: "{{ item.value.image }}"
when: inventory_hostname in groups['vmtp'] when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ vmtp_services }}"
--- ---
- name: Ensure container is up - include: deploy.yml
kolla_docker:
name: "vmtp"
action: "get_container_state"
register: container_state
failed_when: container_state.Running == false
when: inventory_hostname in groups['vmtp']
- include: config.yml
- name: Check configuration
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['vmtp']
with_items:
- { name: vmtp, group: vmtp }
# 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: "vmtp"
action: "get_container_env"
register: container_envs
when: inventory_hostname in groups['vmtp']
- name: Remove the containers
kolla_docker:
name: "vmtp"
action: "remove_container"
register: remove_containers
when:
- config_strategy == "COPY_ONCE" or item[0]['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE'
- item[1]['rc'] == 1
- inventory_hostname in groups['vmtp']
with_together:
- "{{ container_envs.results }}"
- "{{ check_results.results }}"
- include: start.yml
when: remove_containers.changed
- name: Restart containers
kolla_docker:
name: "vmtp"
action: "restart_container"
when:
- config_strategy == 'COPY_ALWAYS'
- item[0]['KOLLA_CONFIG_STRATEGY'] != 'COPY_ONCE'
- item[1]['rc'] == 1
- inventory_hostname in groups['vmtp']
with_together:
- "{{ container_envs.results }}"
- "{{ check_results.results }}"
---
- name: Starting vmtp container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ vmtp_image_full }}"
name: "vmtp"
volumes:
- "{{ node_config_directory }}/vmtp/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "kolla_logs:/var/log/kolla"
--- ---
- include: config.yml - include: config.yml
- include: start.yml - name: Flush handlers
meta: flush_handlers
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment