diff --git a/ansible/inventory/all-in-one b/ansible/inventory/all-in-one index 233966ef4f..cffa98214a 100644 --- a/ansible/inventory/all-in-one +++ b/ansible/inventory/all-in-one @@ -514,6 +514,9 @@ mistral [mistral-engine:children] mistral +[mistral-event-engine:children] +mistral + # Aodh [aodh-api:children] aodh diff --git a/ansible/inventory/multinode b/ansible/inventory/multinode index 7e6ff6d618..c4a6ac3433 100644 --- a/ansible/inventory/multinode +++ b/ansible/inventory/multinode @@ -530,6 +530,9 @@ mistral [mistral-engine:children] mistral +[mistral-event-engine:children] +mistral + # Ceilometer [ceilometer-central:children] ceilometer diff --git a/ansible/roles/mistral/defaults/main.yml b/ansible/roles/mistral/defaults/main.yml index 9eaafe843c..ad2e497f79 100644 --- a/ansible/roles/mistral/defaults/main.yml +++ b/ansible/roles/mistral/defaults/main.yml @@ -35,6 +35,17 @@ mistral_services: - "kolla_logs:/var/log/kolla/" - "{{ kolla_dev_repos_directory ~ '/mistral/mistral:/var/lib/kolla/venv/lib/python2.7/site-packages/mistral' if mistral_dev_mode | bool else '' }}" dimensions: "{{ mistral_engine_dimensions }}" + mistral-event-engine: + container_name: mistral_event_engine + group: mistral-event-engine + enabled: true + image: "{{ mistral_event_engine_image_full }}" + volumes: + - "{{ node_config_directory }}/mistral-event-engine/:{{ container_config_directory }}/:ro" + - "/etc/localtime:/etc/localtime:ro" + - "kolla_logs:/var/log/kolla/" + - "{{ kolla_dev_repos_directory ~ '/mistral/mistral:/var/lib/kolla/venv/lib/python2.7/site-packages/mistral' if mistral_dev_mode | bool else '' }}" + dimensions: "{{ mistral_event_engine_dimensions }}" mistral-executor: container_name: mistral_executor group: mistral-executor @@ -66,6 +77,10 @@ mistral_engine_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ mistral_engine_tag: "{{ mistral_tag }}" mistral_engine_image_full: "{{ mistral_engine_image }}:{{ mistral_engine_tag }}" +mistral_event_engine_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ mistral_install_type }}-mistral-event-engine" +mistral_event_engine_tag: "{{ mistral_tag }}" +mistral_event_engine_image_full: "{{ mistral_event_engine_image }}:{{ mistral_event_engine_tag }}" + mistral_executor_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ mistral_install_type }}-mistral-executor" mistral_executor_tag: "{{ mistral_tag }}" mistral_executor_image_full: "{{ mistral_executor_image }}:{{ mistral_executor_tag }}" @@ -75,6 +90,7 @@ mistral_api_tag: "{{ mistral_tag }}" mistral_api_image_full: "{{ mistral_api_image }}:{{ mistral_api_tag }}" mistral_engine_dimensions: "{{ default_container_dimensions }}" +mistral_event_engine_dimensions: "{{ default_container_dimensions }}" mistral_executor_dimensions: "{{ default_container_dimensions }}" mistral_api_dimensions: "{{ default_container_dimensions }}" diff --git a/ansible/roles/mistral/handlers/main.yml b/ansible/roles/mistral/handlers/main.yml index ee5b02b259..a5ab566546 100644 --- a/ansible/roles/mistral/handlers/main.yml +++ b/ansible/roles/mistral/handlers/main.yml @@ -49,6 +49,32 @@ or policy_overwriting.changed | bool or mistral_engine_container.changed | bool +- name: Restart mistral-event-engine container + vars: + service_name: "mistral-event-engine" + service: "{{ mistral_services[service_name] }}" + config_json: "{{ mistral_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}" + mistral_conf: "{{ mistral_confs.results|selectattr('item.key', 'equalto', service_name)|first }}" + policy_overwriting: "{{ mistral_policy_overwriting.results|selectattr('item.key', 'equalto', service_name)|first }}" + mistral_event_engine_container: "{{ check_mistral_containers.results|selectattr('item.key', 'equalto', service_name)|first }}" + become: true + 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 }}" + dimensions: "{{ service.dimensions }}" + when: + - kolla_action != "config" + - inventory_hostname in groups[service.group] + - service.enabled | bool + - config_json.changed | bool + or mistral_conf.changed | bool + or policy_overwriting.changed | bool + or mistral_event_definitions_confs.changed | bool + or mistral_event_engine_container.changed | bool + - name: Restart mistral-executor container vars: service_name: "mistral-executor" diff --git a/ansible/roles/mistral/tasks/config.yml b/ansible/roles/mistral/tasks/config.yml index 889cadb173..9345237a83 100644 --- a/ansible/roles/mistral/tasks/config.yml +++ b/ansible/roles/mistral/tasks/config.yml @@ -79,6 +79,24 @@ notify: - Restart {{ item.key }} container +- name: Copying over event_definitions.yaml + become: true + vars: + service: "{{ mistral_services['mistral-event-engine'] }}" + template: + src: "{{ item }}" + dest: "{{ node_config_directory }}/mistral-event-engine/event_definitions.yaml" + register: mistral_event_definitions_confs + when: + - inventory_hostname in groups[service.group] + - service.enabled | bool + with_first_found: + - "{{ node_custom_config }}/mistral/{{ inventory_hostname }}/event_definitions.yaml" + - "{{ node_custom_config }}/mistral/event_definitions.yaml" + - "{{ role_path }}/templates/event_definitions.yaml.j2" + notify: + - "Restart mistral-event-engine container" + - name: Check mistral containers become: true kolla_docker: diff --git a/ansible/roles/mistral/tasks/deploy.yml b/ansible/roles/mistral/tasks/deploy.yml index 22f74c1a36..a1359643af 100644 --- a/ansible/roles/mistral/tasks/deploy.yml +++ b/ansible/roles/mistral/tasks/deploy.yml @@ -5,6 +5,7 @@ - include_tasks: config.yml when: inventory_hostname in groups['mistral-api'] or inventory_hostname in groups['mistral-engine'] or + inventory_hostname in groups['mistral-event-engne'] or inventory_hostname in groups['mistral-executor'] - include_tasks: clone.yml diff --git a/ansible/roles/mistral/templates/event_definitions.yaml.j2 b/ansible/roles/mistral/templates/event_definitions.yaml.j2 new file mode 100644 index 0000000000..83626cbed3 --- /dev/null +++ b/ansible/roles/mistral/templates/event_definitions.yaml.j2 @@ -0,0 +1,6 @@ +- event_types: + - compute.instance.create.* + properties: + resource_id: <% $.payload.instance_id %> + project_id: <% $.context.project_id %> + user_id: <% $.context.user_id %> diff --git a/ansible/roles/mistral/templates/mistral-event-engine.json.j2 b/ansible/roles/mistral/templates/mistral-event-engine.json.j2 new file mode 100644 index 0000000000..6d45c2966f --- /dev/null +++ b/ansible/roles/mistral/templates/mistral-event-engine.json.j2 @@ -0,0 +1,30 @@ +{ + "command": "mistral-server --server event-engine --config-file /etc/mistral/mistral.conf", + "config_files": [ + { + "source": "{{ container_config_directory }}/mistral.conf", + "dest": "/etc/mistral/mistral.conf", + "owner": "mistral", + "perm": "0600" + }, + { + "source": "{{ container_config_directory }}/event_definitions.yaml", + "dest": "/etc/mistral/event_definitions.yaml", + "owner": "mistral", + "perm": "0600" + }{% if mistral_policy_file is defined %}, + { + "source": "{{ container_config_directory }}/{{ mistral_policy_file }}", + "dest": "/etc/mistral/{{ mistral_policy_file }}", + "owner": "mistral", + "perm": "0600" + }{% endif %} + ], + "permissions": [ + { + "path": "/var/log/kolla/mistral", + "owner": "mistral:mistral", + "recurse": true + } + ] +} diff --git a/ansible/roles/mistral/templates/mistral.conf.j2 b/ansible/roles/mistral/templates/mistral.conf.j2 index 624cff5b17..d3d9473d58 100644 --- a/ansible/roles/mistral/templates/mistral.conf.j2 +++ b/ansible/roles/mistral/templates/mistral.conf.j2 @@ -4,6 +4,8 @@ debug = {{ mistral_logging_debug }} log_dir = /var/log/kolla/mistral {% if service_name == 'mistral-engine' %} log_file = /var/log/kolla/mistral/mistral-engine.log +{% elif service_name == 'mistral-event-engine' %} +log_file = /var/log/kolla/mistral/mistral-event-engine.log {% elif service_name == 'mistral-executor' %} log_file = /var/log/kolla/mistral/mistral-executor.log {% endif %} @@ -22,6 +24,9 @@ api_workers = {{ openstack_service_workers }} {% elif service_name == 'mistral-engine' %} [engine] host = {{ api_interface_address }} +{% elif service_name == 'mistral-event-engine' %} +[event_engine] +host = {{ api_interface_address }} {% elif service_name == 'mistral-executor' %} [executor] host = {{ api_interface_address }} diff --git a/tests/templates/inventory.j2 b/tests/templates/inventory.j2 index d3e00d0c0d..445612e20b 100644 --- a/tests/templates/inventory.j2 +++ b/tests/templates/inventory.j2 @@ -476,6 +476,9 @@ mistral [mistral-engine:children] mistral +[mistral-event-engine:children] +mistral + # Aodh [aodh-api:children] aodh