diff --git a/tasks/main.yml b/tasks/main.yml index aab5ac6..6047e41 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -28,7 +28,7 @@ - always - import_tasks: db_setup.yml - when: inventory_hostname == groups['adjutant_all'][0] + when: _adjutant_is_first_play_host vars: _oslodb_setup_host: "{{ adjutant_galera_setup_host }}" _oslodb_ansible_python_interpreter: "{{ adjutant_galera_setup_python_interpreter }}" @@ -70,7 +70,7 @@ - adjutant-config - import_tasks: adjutant_db_sync.yml - when: inventory_hostname == groups['adjutant_all'][0] + when: _adjutant_is_first_play_host tags: - adjutant-config @@ -102,7 +102,7 @@ - interface: "admin" url: "{{ adjutant_service_adminurl }}" service: "{{ adjutant_service_name }}" - when: inventory_hostname == groups['adjutant_all'][0] + when: _adjutant_is_first_play_host tags: - adjutant-config diff --git a/vars/main.yml b/vars/main.yml index 0798161..b931bc9 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +_adjutant_is_first_play_host: "{{ (adjutant_services['adjutant-api']['group'] in group_names and inventory_hostname == (groups[adjutant_services['adjutant-api']['group']] | intersect(ansible_play_hosts)) | first) | bool }}" + filtered_adjutant_services: |- {% set services = [] %} {% for key, value in adjutant_services.items() %}