Merge "Optimize reconfiguration for tempest"

This commit is contained in:
Jenkins 2017-01-26 14:16:51 +00:00 committed by Gerrit Code Review
commit 7ed9cb246f
8 changed files with 90 additions and 89 deletions

View File

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

View 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

View File

@ -1,18 +1,25 @@
---
- name: Ensuring config directories exist
file:
path: "{{ node_config_directory }}/{{ item }}"
path: "{{ node_config_directory }}/{{ item.key }}"
state: "directory"
recurse: yes
with_items:
- "tempest"
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ tempest_services }}"
- name: Copying over config.json files for services
template:
src: "{{ item }}.json.j2"
dest: "{{ node_config_directory }}/{{ item }}/config.json"
with_items:
- "tempest"
src: "{{ item.key }}.json.j2"
dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
register: tempest_config_jsons
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
merge_configs:
@ -21,9 +28,14 @@
sources:
- "{{ role_path }}/templates/tempest.conf.j2"
- "{{ node_custom_config }}/tempest.conf"
dest: "{{ node_config_directory }}/{{ item }}/tempest.conf"
with_items:
- "tempest"
dest: "{{ node_config_directory }}/{{ item.key }}/tempest.conf"
register: tempest_confs
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
local_action: stat path="{{ node_custom_config }}/tempest/policy.json"
@ -32,6 +44,28 @@
- name: Copying over existing policy.json
template:
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:
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

View File

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

View File

@ -3,4 +3,8 @@
kolla_docker:
action: "pull_image"
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 }}"

View File

@ -1,64 +1,2 @@
---
- name: Ensuring the containers up
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 }}"
- include: deploy.yml

View File

@ -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/"

View File

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