Format the ansible host if it is an IP address

The ansible host parsed from inventory can be offered as an IP
address. And an IPv6 address can be represented in multiple formats.
This commit converts an ansible host to the recommended format, if it
is an IP address, to ensure the following tasks get the correct IP
address in string.

Test:
1. Set ansible_host to localhost in inventory, added debug task to
print the ansible_host value after conversion, and verified the format
is expected.
2. Set ansible_host to an IPv6 address containing upper case letters
(e.g. 2620:10A:A001:A103::1135, added debug task to print ansible_host
value after conversion, and verified the format is expected.
3. Bring up a DC with one AIOSX subcloud using the dev load containing
the changes in this commit.
4. Add an IPv6 AIOSX subcloud with its in a DC system DC1 with upper
case letters in its bootstrap address, remotely install it under
another DC system DC2, migrate it back to DC1 with upper case
letters in its bootstrap address again.

Closes-Bug: 1931459
Signed-off-by: Yuxing Jiang <yuxing.jiang@windriver.com>
Change-Id: I0d3be2cba7cf40ba79ae4148717feccb0a2b7bb9
This commit is contained in:
Yuxing Jiang
2021-06-10 09:38:07 -05:00
parent 4a840d7f64
commit 214830a42c

View File

@@ -29,6 +29,11 @@
set_fact:
ansible_port: "{{ ansible_port | default(22) }}"
- name: Format the ansible host if it is an IP address
set_fact:
ansible_host: "{{ ansible_host | ipaddr }}"
when: ansible_host | ipaddr
- name: Update SSH known hosts
lineinfile:
path: ~/.ssh/known_hosts