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: I904dca21103b91978ab03db1a3c6d3a30d406aa7
This commit is contained in:
parent
902360bec3
commit
9d89b0fdb0
|
@ -41,7 +41,7 @@
|
|||
|
||||
- import_tasks: db_setup.yml
|
||||
when:
|
||||
- inventory_hostname == groups['cloudkitty_all'][0]
|
||||
- _cloudkitty_is_first_play_host
|
||||
vars:
|
||||
_oslodb_setup_host: "{{ cloudkitty_db_setup_host }}"
|
||||
_oslodb_ansible_python_interpreter: "{{ cloudkitty_db_setup_python_interpreter }}"
|
||||
|
@ -58,7 +58,7 @@
|
|||
|
||||
- import_tasks: mq_setup.yml
|
||||
when:
|
||||
- inventory_hostname == groups['cloudkitty_all'][0]
|
||||
- _cloudkitty_is_first_play_host
|
||||
vars:
|
||||
_oslomsg_rpc_setup_host: "{{ cloudkitty_oslomsg_rpc_setup_host }}"
|
||||
_oslomsg_rpc_userid: "{{ cloudkitty_oslomsg_rpc_userid }}"
|
||||
|
@ -138,13 +138,13 @@
|
|||
- name: "{{ cloudkitty_service_name }}"
|
||||
type: "rating"
|
||||
description: "OpenStack Rating Service"
|
||||
when: inventory_hostname == groups['cloudkitty_all'][0]
|
||||
when: _cloudkitty_is_first_play_host
|
||||
tags:
|
||||
- cloudkitty-config
|
||||
|
||||
- import_tasks: cloudkitty_db_sync.yml
|
||||
when:
|
||||
- inventory_hostname == groups['cloudkitty_all'][0]
|
||||
- _cloudkitty_is_first_play_host
|
||||
tags:
|
||||
- cloudkitty-config
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
_cloudkitty_is_first_play_host: "{{ (cloudkitty_services['cloudkitty-api']['group'] in group_names and inventory_hostname == ((groups[cloudkitty_services['cloudkitty-api']['group']] | intersect(ansible_play_hosts)) | list)[0]) | 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