Optimize reconfiguration for tempest
Change-Id: I75e3a3b32a5ad0bc613a90130fa5bcc65605ca68 Partially-implements: blueprint better-reconfigure
This commit is contained in:
parent
7ee53a563a
commit
82d56e94cd
@ -1,6 +1,17 @@
|
|||||||
---
|
---
|
||||||
project_name: "tempest"
|
project_name: "tempest"
|
||||||
|
|
||||||
|
tempest_services:
|
||||||
|
tempest:
|
||||||
|
container_name: "tempest"
|
||||||
|
image: "{{ tempest_image_full }}"
|
||||||
|
enabled: true
|
||||||
|
group: "tempest"
|
||||||
|
volumes:
|
||||||
|
- "{{ node_config_directory }}/tempest/:{{ container_config_directory }}/:ro"
|
||||||
|
- "/etc/localtime:/etc/localtime:ro"
|
||||||
|
- "kolla_logs:/var/log/kolla/"
|
||||||
|
|
||||||
|
|
||||||
########
|
########
|
||||||
# Docker
|
# Docker
|
||||||
|
23
ansible/roles/tempest/handlers/main.yml
Normal file
23
ansible/roles/tempest/handlers/main.yml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
- name: Restart tempest container
|
||||||
|
vars:
|
||||||
|
service_name: "tempest"
|
||||||
|
service: "{{ tempest_services[service_name] }}"
|
||||||
|
config_json: "{{ tempest_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||||
|
tempest_conf: "{{ tempest_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||||
|
policy_json: "{{ tempest_policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||||
|
tempest_container: "{{ check_tempest_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 }}"
|
||||||
|
privileged: "{{ service.privileged | default(False) }}"
|
||||||
|
volumes: "{{ service.volumes|reject('equalto', '')|list }}"
|
||||||
|
when:
|
||||||
|
- action != "config"
|
||||||
|
- inventory_hostname in groups[service.group]
|
||||||
|
- service.enabled | bool
|
||||||
|
- config_json.changed | bool
|
||||||
|
or tempest_conf.changed | bool
|
||||||
|
or policy_json.changed | bool
|
||||||
|
or tempest_container.changed | bool
|
@ -1,18 +1,25 @@
|
|||||||
---
|
---
|
||||||
- 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"
|
||||||
recurse: yes
|
recurse: yes
|
||||||
with_items:
|
when:
|
||||||
- "tempest"
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- item.value.enabled | bool
|
||||||
|
with_dict: "{{ tempest_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"
|
||||||
with_items:
|
register: tempest_config_jsons
|
||||||
- "tempest"
|
when:
|
||||||
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- item.value.enabled | bool
|
||||||
|
with_dict: "{{ tempest_services }}"
|
||||||
|
notify:
|
||||||
|
- Restart tempest container
|
||||||
|
|
||||||
- name: Copying over tempest.conf
|
- name: Copying over tempest.conf
|
||||||
merge_configs:
|
merge_configs:
|
||||||
@ -21,9 +28,14 @@
|
|||||||
sources:
|
sources:
|
||||||
- "{{ role_path }}/templates/tempest.conf.j2"
|
- "{{ role_path }}/templates/tempest.conf.j2"
|
||||||
- "{{ node_custom_config }}/tempest.conf"
|
- "{{ node_custom_config }}/tempest.conf"
|
||||||
dest: "{{ node_config_directory }}/{{ item }}/tempest.conf"
|
dest: "{{ node_config_directory }}/{{ item.key }}/tempest.conf"
|
||||||
with_items:
|
register: tempest_confs
|
||||||
- "tempest"
|
when:
|
||||||
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- item.value.enabled | bool
|
||||||
|
with_dict: "{{ tempest_services }}"
|
||||||
|
notify:
|
||||||
|
- Restart tempest container
|
||||||
|
|
||||||
- name: Check if policies shall be overwritten
|
- name: Check if policies shall be overwritten
|
||||||
local_action: stat path="{{ node_custom_config }}/tempest/policy.json"
|
local_action: stat path="{{ node_custom_config }}/tempest/policy.json"
|
||||||
@ -32,6 +44,28 @@
|
|||||||
- name: Copying over existing policy.json
|
- name: Copying over existing policy.json
|
||||||
template:
|
template:
|
||||||
src: "{{ node_custom_config }}/tempest/policy.json"
|
src: "{{ node_custom_config }}/tempest/policy.json"
|
||||||
dest: "{{ node_config_directory }}/tempest/policy.json"
|
dest: "{{ node_config_directory }}/{{ item.key }}/policy.json"
|
||||||
|
register: tempest_policy_jsons
|
||||||
when:
|
when:
|
||||||
tempest_policy.stat.exists
|
- tempest_policy.stat.exists
|
||||||
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- item.value.enabled | bool
|
||||||
|
with_dict: "{{ tempest_services }}"
|
||||||
|
notify:
|
||||||
|
- Restart tempest container
|
||||||
|
|
||||||
|
- name: Check tempest 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_tempest_containers
|
||||||
|
when:
|
||||||
|
- action != "config"
|
||||||
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- item.value.enabled | bool
|
||||||
|
with_dict: "{{ tempest_services }}"
|
||||||
|
notify:
|
||||||
|
- Restart tempest container
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
---
|
---
|
||||||
- include: config.yml
|
- include: config.yml
|
||||||
|
|
||||||
- include: start.yml
|
- name: Flush handlers
|
||||||
|
meta: flush_handlers
|
||||||
|
@ -3,4 +3,8 @@
|
|||||||
kolla_docker:
|
kolla_docker:
|
||||||
action: "pull_image"
|
action: "pull_image"
|
||||||
common_options: "{{ docker_common_options }}"
|
common_options: "{{ docker_common_options }}"
|
||||||
image: "{{ tempest_image_full }}"
|
image: "{{ item.value.image }}"
|
||||||
|
when:
|
||||||
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- item.value.enabled | bool
|
||||||
|
with_dict: "{{ tempest_services }}"
|
||||||
|
@ -1,64 +1,2 @@
|
|||||||
---
|
---
|
||||||
- name: Ensuring the containers up
|
- include: deploy.yml
|
||||||
kolla_docker:
|
|
||||||
name: "{{ item.name }}"
|
|
||||||
action: "get_container_state"
|
|
||||||
register: container_state
|
|
||||||
failed_when: container_state.Running == false
|
|
||||||
when: inventory_hostname in groups[item.group]
|
|
||||||
with_items:
|
|
||||||
- { name: tempest, group: tempest }
|
|
||||||
|
|
||||||
- include: config.yml
|
|
||||||
|
|
||||||
- name: Check the configs
|
|
||||||
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[item.group]
|
|
||||||
with_items:
|
|
||||||
- { name: tempest, group: tempest }
|
|
||||||
|
|
||||||
# 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: "{{ item.name }}"
|
|
||||||
action: "get_container_env"
|
|
||||||
register: container_envs
|
|
||||||
when: inventory_hostname in groups[item.group]
|
|
||||||
with_items:
|
|
||||||
- { name: tempest, group: tempest }
|
|
||||||
|
|
||||||
- name: Remove the containers
|
|
||||||
kolla_docker:
|
|
||||||
name: "{{ item[0]['name'] }}"
|
|
||||||
action: "remove_container"
|
|
||||||
register: remove_containers
|
|
||||||
when:
|
|
||||||
- config_strategy == "COPY_ONCE" or item[1]['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE'
|
|
||||||
- item[2]['rc'] == 1
|
|
||||||
- inventory_hostname in groups[item[0]['group']]
|
|
||||||
with_together:
|
|
||||||
- [{ name: tempest, group: tempest }]
|
|
||||||
- "{{ container_envs.results }}"
|
|
||||||
- "{{ check_results.results }}"
|
|
||||||
|
|
||||||
- include: start.yml
|
|
||||||
when: remove_containers.changed
|
|
||||||
|
|
||||||
- name: Restart containers
|
|
||||||
kolla_docker:
|
|
||||||
name: "{{ item[0]['name'] }}"
|
|
||||||
action: "restart_container"
|
|
||||||
when:
|
|
||||||
- config_strategy == 'COPY_ALWAYS'
|
|
||||||
- item[1]['KOLLA_CONFIG_STRATEGY'] != 'COPY_ONCE'
|
|
||||||
- item[2]['rc'] == 1
|
|
||||||
- inventory_hostname in groups[item[0]['group']]
|
|
||||||
with_together:
|
|
||||||
- [{ name: tempest, group: tempest }]
|
|
||||||
- "{{ container_envs.results }}"
|
|
||||||
- "{{ check_results.results }}"
|
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Starting tempest container
|
|
||||||
kolla_docker:
|
|
||||||
action: "start_container"
|
|
||||||
common_options: "{{ docker_common_options }}"
|
|
||||||
image: "{{ tempest_image_full }}"
|
|
||||||
name: "tempest"
|
|
||||||
volumes:
|
|
||||||
- "{{ node_config_directory }}/tempest/:{{ container_config_directory }}/:ro"
|
|
||||||
- "/etc/localtime:/etc/localtime:ro"
|
|
||||||
- "kolla_logs:/var/log/kolla/"
|
|
@ -1,4 +1,5 @@
|
|||||||
---
|
---
|
||||||
- include: config.yml
|
- include: config.yml
|
||||||
|
|
||||||
- include: start.yml
|
- name: Flush handlers
|
||||||
|
meta: flush_handlers
|
||||||
|
Loading…
Reference in New Issue
Block a user