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: I4abb67271bd635c8cde5d4d65451e5fa0091868b
This commit is contained in:
parent
5e4c9582f1
commit
569c8cfb00
@ -135,8 +135,7 @@
|
||||
|
||||
- import_tasks: mq_setup.yml
|
||||
when:
|
||||
- "swift_services['swift-proxy-server']['group'] in group_names"
|
||||
- "inventory_hostname == ((groups[swift_services['swift-proxy-server']['group']]| intersect(ansible_play_hosts)) | list)[0]"
|
||||
- _swift_proxy_is_first_play_host
|
||||
vars:
|
||||
_oslomsg_configure_notify: "{{ swift_ceilometer_enabled | bool }}"
|
||||
_oslomsg_notify_setup_host: "{{ swift_oslomsg_notify_setup_host }}"
|
||||
@ -184,7 +183,7 @@
|
||||
when:
|
||||
- "swift_do_setup | bool"
|
||||
- '"keystoneauth" in swift_middleware_list'
|
||||
- "inventory_hostname == ((groups['swift_all'] | intersect(ansible_play_hosts)) | list)[0]"
|
||||
- _swift_proxy_is_first_play_host
|
||||
tags:
|
||||
- swift-config
|
||||
|
||||
|
@ -48,4 +48,4 @@
|
||||
delegate_to: "{{ item }}"
|
||||
with_items: "{{ groups['swift_proxy'] }}"
|
||||
when:
|
||||
- "inventory_hostname == ((groups['swift_proxy'] | intersect(ansible_play_hosts)) | list)[0]"
|
||||
- _swift_proxy_is_first_play_host
|
||||
|
@ -16,14 +16,14 @@
|
||||
- include_tasks: swift_rings_md5sum.yml
|
||||
|
||||
- include_tasks: swift_rings_check.yml
|
||||
when: inventory_hostname == groups['swift_hosts'][0]
|
||||
when: _swift_is_first_play_host
|
||||
|
||||
- include_tasks: swift_rings_build.yml
|
||||
when: inventory_hostname == groups['swift_hosts'][0]
|
||||
when: _swift_is_first_play_host
|
||||
|
||||
- include_tasks: swift_rings_distribute.yml
|
||||
|
||||
- include_tasks: swift_rings_md5sum.yml
|
||||
|
||||
- include_tasks: swift_rings_post_distribution_check.yml
|
||||
when: inventory_hostname == groups['swift_hosts'][0]
|
||||
when: _swift_is_first_play_host
|
||||
|
@ -13,6 +13,9 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
_swift_proxy_is_first_play_host: "{{ (swift_services['swift-proxy-server']['group'] in group_names and inventory_hostname == (groups[swift_services['swift-proxy-server']['group']] | intersect(ansible_play_hosts)) | first) | bool }}"
|
||||
_swift_is_first_play_host: "{{ ('swift_hosts' in group_names and inventory_hostname == (groups['swift_hosts'] | intersect(ansible_play_hosts)) | first) | bool }}"
|
||||
|
||||
filtered_swift_services: |-
|
||||
{% set services = [] %}
|
||||
{% for key,value in swift_services.items() %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user