Skip to content

Commit

Permalink
Merge pull request #579 from berndfinger/issue-555-sap_maintain_etc_h…
Browse files Browse the repository at this point in the history
…osts-new

sap_maintain_etc_hosts: Add support for Ansible 2.16.1
  • Loading branch information
ja9fuchs authored Jan 12, 2024
2 parents b845d11 + 351fa69 commit 884c772
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions roles/sap_maintain_etc_hosts/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#- name: Double check that list entries with state present do not have duplicate IP addresses
# ansible.builtin.assert:
# that:
# - {{ sap_maintain_etc_hosts_list | selectattr('state') }}
# - sap_maintain_etc_hosts_list | selectattr('state')
- name: Get list of hosts to be added with no state definition
ansible.builtin.set_fact:
__sap_maintain_etc_hosts_present: "{{ sap_maintain_etc_hosts_list | selectattr('state', 'undefined') | list }}"
Expand All @@ -25,18 +25,18 @@
- name: Ensure no duplicate IPs are in the list for adding to hosts
ansible.builtin.assert:
that:
"{{ (__sap_maintain_etc_hosts_present | map(attribute='node_ip') | length) ==
(__sap_maintain_etc_hosts_present | map(attribute='node_ip') | unique | length) }}"
msg: "You have defined duplicate ip addresses to create"
(__sap_maintain_etc_hosts_present | map(attribute='node_ip') | length) ==
(__sap_maintain_etc_hosts_present | map(attribute='node_ip') | unique | length)
msg: "You have defined duplicate ip addresses to be created!"
when:
- __sap_maintain_etc_hosts_present is defined

- name: Ensure no duplicate hostnames are in the list for adding to hosts
ansible.builtin.assert:
that:
"{{ (__sap_maintain_etc_hosts_present | map(attribute='node_name') | length) ==
(__sap_maintain_etc_hosts_present | map(attribute='node_name') | unique | length) }}"
msg: "You have defined duplicate hostnames to create"
(__sap_maintain_etc_hosts_present | map(attribute='node_name') | length) ==
(__sap_maintain_etc_hosts_present | map(attribute='node_name') | unique | length)
msg: "You have defined duplicate hostnames to be created!"
when:
- __sap_maintain_etc_hosts_present is defined

Expand Down

0 comments on commit 884c772

Please sign in to comment.