Merge "Optimize reconfiguration for kuryr"
This commit is contained in:
commit
ac6822e8ea
@ -1,6 +1,25 @@
|
||||
---
|
||||
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
|
||||
|
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
|
||||
vars:
|
||||
kuryr: "{{ kuryr_services['kuryr'] }}"
|
||||
kolla_docker:
|
||||
action: "start_container"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
@ -7,13 +9,11 @@
|
||||
environment:
|
||||
KOLLA_BOOTSTRAP:
|
||||
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
|
||||
image: "{{ kuryr_image_full }}"
|
||||
image: "{{ kuryr.image }}"
|
||||
labels:
|
||||
BOOTSTRAP:
|
||||
name: "bootstrap_kuryr"
|
||||
restart_policy: "never"
|
||||
volumes:
|
||||
- "{{ node_config_directory }}/kuryr/:{{ container_config_directory }}/:ro"
|
||||
- "/etc/localtime:/etc/localtime:ro"
|
||||
- "/run:/run:shared"
|
||||
- "/usr/lib/docker:/usr/lib/docker"
|
||||
volumes: "{{ kuryr.volumes }}"
|
||||
run_once: True
|
||||
delegate_to: "{{ groups[kuryr.group][0] }}"
|
||||
|
@ -1,28 +1,61 @@
|
||||
---
|
||||
- name: Ensuring config directories exist
|
||||
file:
|
||||
path: "{{ node_config_directory }}/{{ item }}"
|
||||
path: "{{ node_config_directory }}/{{ item.key }}"
|
||||
state: "directory"
|
||||
recurse: yes
|
||||
with_items:
|
||||
- "kuryr"
|
||||
when:
|
||||
- inventory_hostname in groups[item.value.group]
|
||||
- item.value.enabled | bool
|
||||
with_dict: "{{ kuryr_services }}"
|
||||
|
||||
- name: Copying over config.json files for services
|
||||
template:
|
||||
src: "{{ item }}.json.j2"
|
||||
dest: "{{ node_config_directory }}/{{ item }}/config.json"
|
||||
with_items:
|
||||
- "kuryr"
|
||||
src: "{{ item.key }}.json.j2"
|
||||
dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
|
||||
register: kuryr_config_jsons
|
||||
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
|
||||
template:
|
||||
src: "kuryr.conf.j2"
|
||||
dest: "{{ node_config_directory }}/kuryr/kuryr.conf"
|
||||
merge_configs:
|
||||
vars:
|
||||
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
|
||||
vars:
|
||||
service: "{{ kuryr_services['kuryr']}}"
|
||||
template:
|
||||
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
|
||||
local_action: stat path="{{ node_custom_config }}/kuryr/policy.json"
|
||||
@ -31,6 +64,29 @@
|
||||
- name: Copying over existing policy.json
|
||||
template:
|
||||
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:
|
||||
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: 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: start.yml
|
||||
- include: bootstrap.yml
|
||||
|
||||
- name: Flush handlers
|
||||
meta: flush_handlers
|
||||
|
Loading…
Reference in New Issue
Block a user