Merge "Optimize reconfiguration for kuryr"
This commit is contained in:
commit
ac6822e8ea
@ -1,6 +1,25 @@
|
|||||||
---
|
---
|
||||||
project_name: "kuryr"
|
project_name: "kuryr"
|
||||||
|
|
||||||
|
# NOTE(huikang, apuimedo): when you request a driver in a docker operation, such
|
||||||
|
# as docker network create, docker searches /usr/lib/docker or /etc/docker
|
||||||
|
# subdirs for network/storage plugin specs or json definitions. so it's either
|
||||||
|
# have ansible place the file there, or volume mount it and let the container
|
||||||
|
# place the file there
|
||||||
|
|
||||||
|
kuryr_services:
|
||||||
|
kuryr:
|
||||||
|
container_name: kuryr
|
||||||
|
group: compute
|
||||||
|
enabled: True
|
||||||
|
image: "{{ kuryr_image_full }}"
|
||||||
|
privileged: True
|
||||||
|
volumes:
|
||||||
|
- "{{ node_config_directory }}/kuryr/:{{ container_config_directory }}/:ro"
|
||||||
|
- "/etc/localtime:/etc/localtime:ro"
|
||||||
|
- "/run:/run:shared"
|
||||||
|
- "/usr/lib/docker:/usr/lib/docker"
|
||||||
|
|
||||||
|
|
||||||
####################
|
####################
|
||||||
# Docker
|
# Docker
|
||||||
|
25
ansible/roles/kuryr/handlers/main.yml
Normal file
25
ansible/roles/kuryr/handlers/main.yml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
---
|
||||||
|
- name: Restart kuryr container
|
||||||
|
vars:
|
||||||
|
service_name: "kuryr"
|
||||||
|
service: "{{ kuryr_services[service_name] }}"
|
||||||
|
config_json: "{{ kuryr_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||||
|
kuryr_conf: "{{ kuryr_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||||
|
policy_json: "{{ kuryr_policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
|
||||||
|
kuryr_container: "{{ check_kuryr_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 }}"
|
||||||
|
when:
|
||||||
|
- action != "config"
|
||||||
|
- inventory_hostname in groups[service.group]
|
||||||
|
- service.enabled | bool
|
||||||
|
- config_json.changed | bool
|
||||||
|
or kuryr_conf.changed | bool
|
||||||
|
or kuryr_spec.changed | bool
|
||||||
|
or policy_json.changed | bool
|
||||||
|
or kuryr_container.changed | bool
|
@ -1,5 +1,7 @@
|
|||||||
---
|
---
|
||||||
- name: Running Kuryr bootstrap container
|
- name: Running Kuryr bootstrap container
|
||||||
|
vars:
|
||||||
|
kuryr: "{{ kuryr_services['kuryr'] }}"
|
||||||
kolla_docker:
|
kolla_docker:
|
||||||
action: "start_container"
|
action: "start_container"
|
||||||
common_options: "{{ docker_common_options }}"
|
common_options: "{{ docker_common_options }}"
|
||||||
@ -7,13 +9,11 @@
|
|||||||
environment:
|
environment:
|
||||||
KOLLA_BOOTSTRAP:
|
KOLLA_BOOTSTRAP:
|
||||||
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
|
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
|
||||||
image: "{{ kuryr_image_full }}"
|
image: "{{ kuryr.image }}"
|
||||||
labels:
|
labels:
|
||||||
BOOTSTRAP:
|
BOOTSTRAP:
|
||||||
name: "bootstrap_kuryr"
|
name: "bootstrap_kuryr"
|
||||||
restart_policy: "never"
|
restart_policy: "never"
|
||||||
volumes:
|
volumes: "{{ kuryr.volumes }}"
|
||||||
- "{{ node_config_directory }}/kuryr/:{{ container_config_directory }}/:ro"
|
run_once: True
|
||||||
- "/etc/localtime:/etc/localtime:ro"
|
delegate_to: "{{ groups[kuryr.group][0] }}"
|
||||||
- "/run:/run:shared"
|
|
||||||
- "/usr/lib/docker:/usr/lib/docker"
|
|
||||||
|
@ -1,28 +1,61 @@
|
|||||||
---
|
---
|
||||||
- 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:
|
||||||
- "kuryr"
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- item.value.enabled | bool
|
||||||
|
with_dict: "{{ kuryr_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: kuryr_config_jsons
|
||||||
- "kuryr"
|
when:
|
||||||
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- item.value.enabled | bool
|
||||||
|
with_dict: "{{ kuryr_services }}"
|
||||||
|
notify:
|
||||||
|
- Restart kuryr container
|
||||||
|
|
||||||
- name: Copying over kuryr.conf
|
- name: Copying over kuryr.conf
|
||||||
template:
|
merge_configs:
|
||||||
src: "kuryr.conf.j2"
|
vars:
|
||||||
dest: "{{ node_config_directory }}/kuryr/kuryr.conf"
|
service_name: "{{ item.key }}"
|
||||||
|
sources:
|
||||||
|
- "{{ role_path }}/templates/kuryr.conf.j2"
|
||||||
|
- "{{ node_custom_config }}/global.conf"
|
||||||
|
- "{{ node_custom_config }}/database.conf"
|
||||||
|
- "{{ node_custom_config }}/messaging.conf"
|
||||||
|
- "{{ node_custom_config }}/kuryr.conf"
|
||||||
|
- "{{ node_custom_config }}/kuryr/{{ item.key }}.conf"
|
||||||
|
- "{{ node_custom_config }}/kuryr/{{ inventory_hostname }}/{{ item.key }}.conf"
|
||||||
|
dest: "{{ node_config_directory }}/{{ item.key }}/kuryr.conf"
|
||||||
|
register: kuryr_confs
|
||||||
|
when:
|
||||||
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- item.value.enabled | bool
|
||||||
|
with_dict: "{{ kuryr_services }}"
|
||||||
|
notify:
|
||||||
|
- Restart kuryr container
|
||||||
|
|
||||||
- name: Copying over kuryr.spec
|
- name: Copying over kuryr.spec
|
||||||
|
vars:
|
||||||
|
service: "{{ kuryr_services['kuryr']}}"
|
||||||
template:
|
template:
|
||||||
src: "kuryr.spec.j2"
|
src: "kuryr.spec.j2"
|
||||||
dest: "{{ node_config_directory }}/kuryr/kuryr.spec"
|
dest: "{{ node_config_directory }}/{{ item }}/kuryr.spec"
|
||||||
|
register: kuryr_spec
|
||||||
|
when:
|
||||||
|
- inventory_hostname in groups[service.group]
|
||||||
|
- service.enabled | bool
|
||||||
|
with_items:
|
||||||
|
- "kuryr"
|
||||||
|
notify:
|
||||||
|
- Restart kuryr container
|
||||||
|
|
||||||
- name: Check if policies shall be overwritten
|
- name: Check if policies shall be overwritten
|
||||||
local_action: stat path="{{ node_custom_config }}/kuryr/policy.json"
|
local_action: stat path="{{ node_custom_config }}/kuryr/policy.json"
|
||||||
@ -31,6 +64,29 @@
|
|||||||
- name: Copying over existing policy.json
|
- name: Copying over existing policy.json
|
||||||
template:
|
template:
|
||||||
src: "{{ node_custom_config }}/kuryr/policy.json"
|
src: "{{ node_custom_config }}/kuryr/policy.json"
|
||||||
dest: "{{ node_config_directory }}/kuryr/policy.json"
|
dest: "{{ node_config_directory }}/{{ item.key }}/policy.json"
|
||||||
|
register: kuryr_policy_jsons
|
||||||
when:
|
when:
|
||||||
kuryr_policy.stat.exists
|
- kuryr_policy.stat.exists
|
||||||
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- item.value.enabled | bool
|
||||||
|
with_dict: "{{ kuryr_services }}"
|
||||||
|
notify:
|
||||||
|
- Restart kuryr container
|
||||||
|
|
||||||
|
- name: Check kuryr containers
|
||||||
|
kolla_docker:
|
||||||
|
action: "compare_container"
|
||||||
|
common_options: "{{ docker_common_options }}"
|
||||||
|
name: "{{ item.value.container_name }}"
|
||||||
|
image: "{{ item.value.image }}"
|
||||||
|
privileged: "{{ item.value.privileged|default(False) }}"
|
||||||
|
volumes: "{{ item.value.volumes }}"
|
||||||
|
register: check_kuryr_containers
|
||||||
|
when:
|
||||||
|
- action != "config"
|
||||||
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- item.value.enabled | bool
|
||||||
|
with_dict: "{{ kuryr_services }}"
|
||||||
|
notify:
|
||||||
|
- Restart kuryr container
|
||||||
|
@ -5,4 +5,5 @@
|
|||||||
|
|
||||||
- include: bootstrap.yml
|
- include: bootstrap.yml
|
||||||
|
|
||||||
- include: start.yml
|
- name: Flush handlers
|
||||||
|
meta: flush_handlers
|
||||||
|
2
ansible/roles/kuryr/tasks/reconfigure.yml
Normal file
2
ansible/roles/kuryr/tasks/reconfigure.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
- include: deploy.yml
|
@ -1,19 +0,0 @@
|
|||||||
---
|
|
||||||
# NOTE(huikang, apuimedo): when you request a driver in a docker operation, such
|
|
||||||
# as docker network create, docker searches /usr/lib/docker or /etc/docker
|
|
||||||
# subdirs for network/storage plugin specs or json definitions. so it's either
|
|
||||||
# have ansible place the file there, or volume mount it and let the container
|
|
||||||
# place the file there
|
|
||||||
- name: Starting kuryr container
|
|
||||||
kolla_docker:
|
|
||||||
action: "start_container"
|
|
||||||
common_options: "{{ docker_common_options }}"
|
|
||||||
image: "{{ kuryr_image_full }}"
|
|
||||||
name: "kuryr"
|
|
||||||
privileged: True
|
|
||||||
volumes:
|
|
||||||
- "{{ node_config_directory }}/kuryr/:{{ container_config_directory }}/:ro"
|
|
||||||
- "/etc/localtime:/etc/localtime:ro"
|
|
||||||
- "/run:/run:shared"
|
|
||||||
- "/usr/lib/docker:/usr/lib/docker"
|
|
||||||
when: inventory_hostname in groups['compute']
|
|
@ -1,4 +1,7 @@
|
|||||||
---
|
---
|
||||||
- include: config.yml
|
- include: config.yml
|
||||||
|
|
||||||
- include: start.yml
|
- include: bootstrap.yml
|
||||||
|
|
||||||
|
- name: Flush handlers
|
||||||
|
meta: flush_handlers
|
||||||
|
Loading…
Reference in New Issue
Block a user