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: I69c08fd522c1c80356000b1cf2a48a9b63327b3c
This commit is contained in:
parent
c293c91eeb
commit
acce40d693
|
@ -27,7 +27,7 @@
|
|||
|
||||
- import_tasks: db_setup.yml
|
||||
when:
|
||||
- inventory_hostname == (groups['gnocchi_all'] | intersect(ansible_play_hosts))[0]
|
||||
- _gnocchi_is_first_play_host
|
||||
vars:
|
||||
_oslodb_setup_host: "{{ gnocchi_db_setup_host }}"
|
||||
_oslodb_databases:
|
||||
|
@ -115,13 +115,13 @@
|
|||
type: "{{ gnocchi_service_type }}"
|
||||
description: "{{ gnocchi_service_description }}"
|
||||
when:
|
||||
- inventory_hostname == (groups['gnocchi_all'] | intersect(ansible_play_hosts))[0]
|
||||
- _gnocchi_is_first_play_host
|
||||
- not gnocchi_identity_only | bool
|
||||
tags:
|
||||
- gnocchi-config
|
||||
|
||||
- import_tasks: gnocchi_identity_setup.yml
|
||||
when: inventory_hostname == (groups['gnocchi_all'] | intersect(ansible_play_hosts))[0]
|
||||
when: _gnocchi_is_first_play_host
|
||||
tags:
|
||||
- gnocchi-config
|
||||
|
||||
|
@ -139,7 +139,7 @@
|
|||
# Similarly, when using Ceph, must occur after Ceph setup.
|
||||
- import_tasks: gnocchi_db_sync.yml
|
||||
when:
|
||||
- inventory_hostname == (groups['gnocchi_all'] | intersect(ansible_play_hosts))[0]
|
||||
- _gnocchi_is_first_play_host
|
||||
- not gnocchi_identity_only | bool
|
||||
tags:
|
||||
- gnocchi-config
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
_gnocchi_is_first_play_host: "{{ (gnocchi_services['gnocchi-api']['group'] in group_names and inventory_hostname == (groups[gnocchi_services['gnocchi-api']['group']] | intersect(ansible_play_hosts)) | first) | bool }}"
|
||||
|
||||
# These vars find a file on the deployment node, if it exists - otherwise the result is empty.
|
||||
gnocchi_api_paste_user_content: "{{ lookup('pipe', 'cat ' ~ gnocchi_api_paste_default_file_path ~ ' 2>/dev/null || true') }}"
|
||||
gnocchi_policy_user_content: "{{ lookup('pipe', 'cat ' ~ gnocchi_policy_default_file_path ~ ' 2>/dev/null || true') }}"
|
||||
|
|
Loading…
Reference in New Issue