
The ansible loop construct assigns the same variable name 'item' to all loops by default. This can lead to potential name space collisions, as multiple loops, operating over different datastructures, can be nested within each other, and potentially modify each others data. Introduction of a named loop variable prevents this, unlikely though not impossible, event from happening. Signed-off-by: Jiri Podivin <jpodivin@redhat.com> Change-Id: I2a1cfe09d850af5c0ebd8cb9ac139d58790f5881
53 lines
1.6 KiB
YAML
53 lines
1.6 KiB
YAML
---
|
|
# Copyright 2020 Red Hat, Inc.
|
|
# All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
#
|
|
# The tasks in this file perform the registration process for a service.
|
|
#
|
|
# The following variable are required:
|
|
# - { required_service } : which is an ordered tuple of the form:
|
|
# -- { sub_host, service }
|
|
#
|
|
# An example of this is:
|
|
# { "controller-5.storagemgmt.example.com", "haproxy" }
|
|
#
|
|
# At this time, the final value in the tuple is unused.
|
|
|
|
- name: set variables
|
|
set_fact:
|
|
sub_host: "{{ required_service.0 }}"
|
|
service: "{{ required_service.1 }}"
|
|
|
|
- name: add sub_host
|
|
ipahost:
|
|
fqdn: "{{ sub_host }}"
|
|
force: true
|
|
state: present
|
|
become: true
|
|
|
|
- name: add service
|
|
ipaservice:
|
|
name: "{{ service }}/{{ sub_host }}"
|
|
force: true
|
|
state: present
|
|
become: true
|
|
|
|
- name: add host to managed_hosts if needed (shell)
|
|
shell: |
|
|
ipa service-add-host --hosts "{{ base_server_fqdn }}" "{{ service }}"/"{{ sub_host }}"
|
|
register: service_add_out
|
|
failed_when: service_add_out.failed and 'This entry is already a member' not in service_add_out.stdout
|
|
become: true
|