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: Ib8c8ddf5adc71f42b401b034807c4e716f515202
This commit is contained in:
parent
086ad74db3
commit
99f3fed9fd
|
@ -42,8 +42,7 @@
|
|||
|
||||
- import_tasks: db_setup.yml
|
||||
when:
|
||||
- "mistral_services['mistral-api']['group'] in group_names"
|
||||
- "inventory_hostname == ((groups[mistral_services['mistral-api']['group']]| intersect(ansible_play_hosts)) | list)[0]"
|
||||
- "_mistral_is_first_play_host"
|
||||
vars:
|
||||
_oslodb_setup_host: "{{ mistral_db_setup_host }}"
|
||||
_oslodb_ansible_python_interpreter: "{{ mistral_db_setup_python_interpreter }}"
|
||||
|
@ -60,8 +59,7 @@
|
|||
|
||||
- import_tasks: mq_setup.yml
|
||||
when:
|
||||
- "mistral_services['mistral-api']['group'] in group_names"
|
||||
- "inventory_hostname == ((groups[mistral_services['mistral-api']['group']]| intersect(ansible_play_hosts)) | list)[0]"
|
||||
- "_mistral_is_first_play_host"
|
||||
vars:
|
||||
_oslomsg_rpc_setup_host: "{{ mistral_oslomsg_rpc_setup_host }}"
|
||||
_oslomsg_rpc_userid: "{{ mistral_oslomsg_rpc_userid }}"
|
||||
|
@ -87,8 +85,7 @@
|
|||
|
||||
- import_tasks: mistral_db_sync.yml
|
||||
when:
|
||||
- "mistral_services['mistral-api']['group'] in group_names"
|
||||
- "inventory_hostname == ((groups[mistral_services['mistral-api']['group']]| intersect(ansible_play_hosts)) | list)[0]"
|
||||
- "_mistral_is_first_play_host"
|
||||
tags:
|
||||
- mistral-config
|
||||
|
||||
|
@ -162,8 +159,7 @@
|
|||
type: "{{ mistral_service_type }}"
|
||||
description: "{{ mistral_service_description }}"
|
||||
when:
|
||||
- "mistral_services['mistral-api']['group'] in group_names"
|
||||
- "inventory_hostname == ((groups[mistral_services['mistral-api']['group']]| intersect(ansible_play_hosts)) | list)[0]"
|
||||
- "_mistral_is_first_play_host"
|
||||
tags:
|
||||
- mistral-config
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
_mistral_is_first_play_host: "{{ (mistral_services['mistral-api']['group'] in group_names and inventory_hostname == (groups[mistral_services['mistral-api']['group']] | intersect(ansible_play_hosts)) | first) | bool }}"
|
||||
|
||||
#
|
||||
# Compile a list of the services on a host based on whether
|
||||
# the host is in the host group and the service is enabled.
|
||||
|
|
Loading…
Reference in New Issue