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: I63e9f830f086763f3dcb90cd54dbdebcfc679b1c
This commit is contained in:
parent
32031f6c13
commit
59621889cc
@ -41,8 +41,7 @@
|
|||||||
|
|
||||||
- import_tasks: db_setup.yml
|
- import_tasks: db_setup.yml
|
||||||
when:
|
when:
|
||||||
- "designate_services['designate-api']['group'] in group_names"
|
- "_designate_is_first_play_host"
|
||||||
- "inventory_hostname == ((groups[designate_services['designate-api']['group']]| intersect(ansible_play_hosts)) | list)[0]"
|
|
||||||
vars:
|
vars:
|
||||||
_oslodb_setup_host: "{{ designate_db_setup_host }}"
|
_oslodb_setup_host: "{{ designate_db_setup_host }}"
|
||||||
_oslodb_databases:
|
_oslodb_databases:
|
||||||
@ -56,8 +55,7 @@
|
|||||||
|
|
||||||
- import_tasks: mq_setup.yml
|
- import_tasks: mq_setup.yml
|
||||||
when:
|
when:
|
||||||
- "designate_services['designate-api']['group'] in group_names"
|
- "_designate_is_first_play_host"
|
||||||
- "inventory_hostname == ((groups[designate_services['designate-api']['group']]| intersect(ansible_play_hosts)) | list)[0]"
|
|
||||||
vars:
|
vars:
|
||||||
_oslomsg_rpc_setup_host: "{{ designate_oslomsg_rpc_setup_host }}"
|
_oslomsg_rpc_setup_host: "{{ designate_oslomsg_rpc_setup_host }}"
|
||||||
_oslomsg_rpc_userid: "{{ designate_oslomsg_rpc_userid }}"
|
_oslomsg_rpc_userid: "{{ designate_oslomsg_rpc_userid }}"
|
||||||
@ -110,7 +108,7 @@
|
|||||||
meta: flush_handlers
|
meta: flush_handlers
|
||||||
|
|
||||||
- import_tasks: designate_db_sync.yml
|
- import_tasks: designate_db_sync.yml
|
||||||
when: inventory_hostname == groups['designate_all'][0]
|
when: _designate_is_first_play_host
|
||||||
tags:
|
tags:
|
||||||
- designate-install
|
- designate-install
|
||||||
|
|
||||||
@ -140,7 +138,7 @@
|
|||||||
- name: "{{ designate_service_name }}"
|
- name: "{{ designate_service_name }}"
|
||||||
type: "{{ designate_service_type }}"
|
type: "{{ designate_service_type }}"
|
||||||
description: "{{ designate_service_description }}"
|
description: "{{ designate_service_description }}"
|
||||||
when: inventory_hostname == groups['designate_all'][0]
|
when: _designate_is_first_play_host
|
||||||
tags:
|
tags:
|
||||||
- designate-install
|
- designate-install
|
||||||
|
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
_designate_is_first_play_host: "{{ (designate_services['designate-api']['group'] in group_names and inventory_hostname == (groups[designate_services['designate-api']['group']] | intersect(ansible_play_hosts)) | first) | bool }}"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Compile a list of the services on a host based on whether
|
# Compile a list of the services on a host based on whether
|
||||||
# the host is in the host group and the service is enabled.
|
# the host is in the host group and the service is enabled.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user