Skip to content

Commit

Permalink
Merge branch 'dev' into issue-662
Browse files Browse the repository at this point in the history
  • Loading branch information
berndfinger authored Mar 4, 2024
2 parents 5ec64dd + da5312f commit ee67845
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions roles/sap_maintain_etc_hosts/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@
# the role creates a default value from ansible_facts

sap_maintain_etc_hosts_list: "{{ sap_hana_cluster_nodes | default(sap_ha_pacemaker_cluster_cluster_nodes) | default(omit) }}"

# regex patterns for IP address validation:
sap_maintain_etc_hosts_regexp_ipv4: '^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$'
sap_maintain_etc_hosts_regexp_ipv6: '^(?:[a-fA-F0-9]{0,4}:){7}[a-fA-F0-9]{0,4}$'
12 changes: 12 additions & 0 deletions roles/sap_maintain_etc_hosts/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,15 @@ argument_specs:
state: absent
- node_name: host2
state: absent

sap_maintain_etc_hosts_regexp_ipv4:
default: '^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$'
description:
- regex pattern for IPv4 address validation
type: str

sap_maintain_etc_hosts_regexp_ipv6:
default: '^(?:[a-fA-F0-9]{0,4}:){7}[a-fA-F0-9]{0,4}$'
description:
- regex pattern for IPv6 address validation
type: str
3 changes: 2 additions & 1 deletion roles/sap_maintain_etc_hosts/tasks/update_host_absent.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
- name: Verify that variable node_ip is in the correct format
ansible.builtin.assert:
that: thishost.node_ip is ansible.utils.ip
that: thishost.node_ip | regex_search(sap_maintain_etc_hosts_regexp_ipv4) or
thishost.node_ip | regex_search(sap_maintain_etc_hosts_regexp_ipv6)
msg: "Variable 'node_ip' is not an IP address. Please use the correct format"
when: thisnode.node_ip is defined

Expand Down
3 changes: 2 additions & 1 deletion roles/sap_maintain_etc_hosts/tasks/update_host_present.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
- name: Verify that variable node_ip is using the correct IP address format
ansible.builtin.assert:
that: thishost.node_ip is ansible.utils.ip
that: thishost.node_ip | regex_search(sap_maintain_etc_hosts_regexp_ipv4) or
thishost.node_ip | regex_search(sap_maintain_etc_hosts_regexp_ipv6)
msg: |
"The IP address of this host does not have a correct format.
Configure the IP address appropriately in of the following variables:
Expand Down

0 comments on commit ee67845

Please sign in to comment.