Define condition for the first play host one time
We use the same condition, which defines against what host some "service" tasks should run against, several times. It's hard to keep it the same across the role and ansible spending additional resources to evaluate it each time, so it's simpler and better for the maintenance to set a boolean variable which will say for all tasks, that we want to run only against signle host, if they should run or not now. Change-Id: I78d44704a0224b2c73832a607e84ea8d9499f8c2
This commit is contained in:
committed by
Dmitriy Rabotyagov (noonedeadpunk)
parent
980a319ec3
commit
a9f5d97672
@@ -71,8 +71,7 @@
|
||||
|
||||
- import_tasks: db_setup.yml
|
||||
when:
|
||||
- "nova_services['nova-conductor']['group'] in group_names"
|
||||
- "inventory_hostname == ((groups[nova_services['nova-conductor']['group']] | intersect(ansible_play_hosts)) | list)[0]"
|
||||
- _nova_is_first_play_host
|
||||
vars:
|
||||
_oslodb_setup_host: "{{ nova_db_setup_host }}"
|
||||
_oslodb_ansible_python_interpreter: "{{ nova_db_setup_python_interpreter }}"
|
||||
@@ -97,8 +96,7 @@
|
||||
|
||||
- import_tasks: mq_setup.yml
|
||||
when:
|
||||
- "nova_services['nova-conductor']['group'] in group_names"
|
||||
- "inventory_hostname == ((groups[nova_services['nova-conductor']['group']] | intersect(ansible_play_hosts)) | list)[0]"
|
||||
- _nova_is_first_play_host
|
||||
vars:
|
||||
_oslomsg_rpc_setup_host: "{{ nova_oslomsg_rpc_setup_host }}"
|
||||
_oslomsg_rpc_userid: "{{ nova_oslomsg_rpc_userid }}"
|
||||
@@ -172,15 +170,13 @@
|
||||
type: "{{ nova_service_type }}"
|
||||
description: "{{ nova_service_description }}"
|
||||
when:
|
||||
- "nova_services['nova-conductor']['group'] in group_names"
|
||||
- "inventory_hostname == ((groups['nova_conductor'] | intersect(ansible_play_hosts)) | list)[0]"
|
||||
- _nova_is_first_play_host
|
||||
tags:
|
||||
- nova-config
|
||||
|
||||
- import_tasks: nova_db_setup.yml
|
||||
when:
|
||||
- "nova_services['nova-conductor']['group'] in group_names"
|
||||
- "inventory_hostname == ((groups['nova_conductor'] | intersect(ansible_play_hosts)) | list)[0]"
|
||||
- _nova_is_first_play_host
|
||||
tags:
|
||||
- nova-config
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
_nova_is_first_play_host: "{{ (nova_services['nova-conductor']['group'] in group_names and inventory_hostname == (groups[nova_services['nova-conductor']['group']] | intersect(ansible_play_hosts)) | first) | bool }}"
|
||||
|
||||
nova_venv_packages: |-
|
||||
{%- set pkg_list = nova_pip_packages | union(nova_user_pip_packages) %}
|
||||
{%- if nova_oslomsg_amqp1_enabled | bool %}
|
||||
|
||||
Reference in New Issue
Block a user