Merge "Optimize reconfigure action for vmtp"
This commit is contained in:
commit
0b2fb2f9a5
@ -1,6 +1,18 @@
|
||||
---
|
||||
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
|
||||
####################
|
||||
|
17
ansible/roles/vmtp/handlers/main.yml
Normal file
17
ansible/roles/vmtp/handlers/main.yml
Normal file
@ -0,0 +1,17 @@
|
||||
- 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
|
@ -1,9 +1,13 @@
|
||||
---
|
||||
- name: Ensuring config directories exist
|
||||
file:
|
||||
path: "{{ node_config_directory }}/vmtp"
|
||||
path: "{{ node_config_directory }}/{{ item.key }}"
|
||||
state: "directory"
|
||||
recurse: yes
|
||||
when:
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- item.value.enabled | bool
|
||||
with_dict: "{{ vmtp_services }}"
|
||||
|
||||
- name: Register binary python path
|
||||
command: echo /usr/lib/python2.7/site-packages
|
||||
@ -16,11 +20,35 @@
|
||||
when: kolla_install_type != 'binary'
|
||||
|
||||
- name: Copying over configuration file for vmtp
|
||||
vars:
|
||||
service: "{{ vmtp_services['vmtp'] }}"
|
||||
merge_yaml:
|
||||
sources:
|
||||
- "{{ role_path }}/templates/{{ item }}.j2"
|
||||
- "{{ node_custom_config }}/{{ item }}"
|
||||
- "{{ node_custom_config }}/vmtp/{{ item }}"
|
||||
dest: "{{ python_path }}/vmtp/{{ item }}"
|
||||
register: vmtp_confs
|
||||
when:
|
||||
- inventory_hostname in groups[service.group]
|
||||
- service.enabled | bool
|
||||
with_items:
|
||||
- "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 @@
|
||||
- include: config.yml
|
||||
when: inventory_hostname in groups['vmtp']
|
||||
|
||||
- include: start.yml
|
||||
when: inventory_hostname in groups['vmtp']
|
||||
- name: Flush handlers
|
||||
meta: flush_handlers
|
||||
|
@ -3,5 +3,8 @@
|
||||
kolla_docker:
|
||||
action: "pull_image"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
image: "{{ vmtp_image_full }}"
|
||||
when: inventory_hostname in groups['vmtp']
|
||||
image: "{{ item.value.image }}"
|
||||
when:
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- item.value.enabled | bool
|
||||
with_dict: "{{ vmtp_services }}"
|
||||
|
@ -1,58 +1,2 @@
|
||||
---
|
||||
- name: Ensure container is up
|
||||
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 }}"
|
||||
- include: deploy.yml
|
||||
|
@ -1,11 +0,0 @@
|
||||
---
|
||||
- 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"
|
@ -1,4 +1,5 @@
|
||||
---
|
||||
- include: config.yml
|
||||
|
||||
- include: start.yml
|
||||
- name: Flush handlers
|
||||
meta: flush_handlers
|
||||
|
Loading…
Reference in New Issue
Block a user