Bug 1878122 - red hat openstack 16.1 tripleo-ansible-inventory produces malformed yaml
Summary: red hat openstack 16.1 tripleo-ansible-inventory produces malformed yaml
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: Red Hat OpenStack
Classification: Red Hat
Component: openstack-tripleo-common
Version: 16.1 (Train)
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ---
: ---
Assignee: Adriano Petrich
QA Contact: David Rosenfeld
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-09-11 11:54 UTC by Joachim von Thadden
Modified: 2020-11-10 20:01 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-09-22 13:24:56 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Ansible inventory as produced by tripleo-ansible-inventory on OSP16.1 (15.66 KB, text/plain)
2020-09-11 14:24 UTC, Joachim von Thadden
no flags Details

Description Joachim von Thadden 2020-09-11 11:54:15 UTC
Description of problem:
When I run 

/usr/bin/tripleo-ansible-inventory --stack overcloud --static-yaml-inventory inventory.yaml

this inventory is not usable by ansible as it is malformed:

overcloud_Controller:
  hosts:
    overcloud-controller-0: {ansible_host: 10.0.0.62, canonical_hostname: overcloud-controller-0.rhosp16.infra-as-code.org,
...

Since 16.0 is looked like this
overcloud_Controller:
  hosts:
    overcloud-controller-0:
      ansible_host: 10.0.0.62
      canonical_hostname: overcloud-controller-0.rhosp16.infra-as-code.org
...

As a result, using this inventory leads to
(undercloud) [stack@iac-director ~]$ ansible -i ansible-inventory.yaml overcloud_Controller -b -m shell -a "id"

overcloud_Controller | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname overcloud_controller: Name or service not known",
    "unreachable": true
}


Version-Release number of selected component (if applicable):
broken since 16.1, here it is
openstack-tripleo-validations-11.3.2-0.20200611115253.08f469d.el8ost.noarch

How reproducible:
always

Steps to Reproduce:
1. install 16.1
2. /usr/bin/tripleo-ansible-inventory --stack overcloud --static-yaml-inventory inventory.yaml
3. try to use this inventory

Actual results:
hosts are not found by ansible

Expected results:
hosts are found and correctly addressed

Additional info:

Comment 1 Joachim von Thadden 2020-09-11 11:55:02 UTC
This has probably a high severity as many tools rely on this process.

Comment 2 Cédric Jeanneret 2020-09-11 13:57:28 UTC
Hello Joachim,

Care to provide the full inventory file? That would help a bit.

Thanks!

Cheers,

C.

Comment 3 Joachim von Thadden 2020-09-11 14:24:19 UTC
Created attachment 1714571 [details]
Ansible inventory as produced by tripleo-ansible-inventory on OSP16.1

Sure. Find the broken 16.1 inventory attached.

Comment 4 Emilien Macchi 2020-09-11 18:11:59 UTC
(undercloud) [RedHat-8.2 - stack@undercloud ~]$ ansible -i /home/stack/inventory.yaml overcloud-0_Controller -b -m shell -a "id"
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details
[DEPRECATION WARNING]: Distribution redhat 8.2 on host oc0-controller-0 should use /usr/libexec/platform-python, but is using /usr/bin/python for backward compatibility with prior Ansible releases. A future Ansible release will default to using the 
discovered platform python for this host. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information. This feature will be removed in version 2.12. Deprecation warnings can be disabled by setting 
deprecation_warnings=False in ansible.cfg.
oc0-controller-0 | CHANGED | rc=0 >>
uid=0(root) gid=0(root) groups=0(root) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[DEPRECATION WARNING]: Distribution redhat 8.2 on host oc0-controller-2 should use /usr/libexec/platform-python, but is using /usr/bin/python for backward compatibility with prior Ansible releases. A future Ansible release will default to using the 
discovered platform python for this host. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information. This feature will be removed in version 2.12. Deprecation warnings can be disabled by setting 
deprecation_warnings=False in ansible.cfg.
oc0-controller-2 | CHANGED | rc=0 >>
uid=0(root) gid=0(root) groups=0(root) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[DEPRECATION WARNING]: Distribution redhat 8.2 on host oc0-controller-1 should use /usr/libexec/platform-python, but is using /usr/bin/python for backward compatibility with prior Ansible releases. A future Ansible release will default to using the 
discovered platform python for this host. See https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information. This feature will be removed in version 2.12. Deprecation warnings can be disabled by setting 
deprecation_warnings=False in ansible.cfg.
oc0-controller-1 | CHANGED | rc=0 >>
uid=0(root) gid=0(root) groups=0(root) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023


It works for me just fine.
ansible-tripleo-ipa-0.2.1-0.20200611104546.c22fc8d.el8ost.noarch
ansible-tripleo-ipsec-9.2.1-0.20200311073016.0c8693c.el8ost.noarch
openstack-tripleo-puppet-elements-11.2.2-0.20200527003426.226ce95.el8ost.noarch
python3-tripleoclient-12.3.2-0.20200615103427.6f877f6.el8ost.noarch
python3-tripleo-common-11.3.3-0.20200611110657.f7715be.el8ost.noarch
openstack-tripleo-common-11.3.3-0.20200611110657.f7715be.el8ost.noarch
puppet-tripleo-11.5.0-0.20200616033428.8ff1c6a.el8ost.noarch
openstack-tripleo-image-elements-10.6.2-0.20200528043425.7dc0fa1.el8ost.noarch
openstack-tripleo-validations-11.3.2-0.20200611115253.08f469d.el8ost.noarch
openstack-tripleo-heat-templates-11.3.2-0.20200616081539.396affd.el8ost.noarch
tripleo-ansible-0.5.1-0.20200611113659.34b8fcc.el8ost.noarch
python3-tripleoclient-heat-installer-12.3.2-0.20200615103427.6f877f6.el8ost.noarch
ansible-role-tripleo-modify-image-1.2.1-0.20200527233426.bc21900.el8ost.noarch

Comment 5 Emilien Macchi 2020-09-11 18:14:18 UTC
(undercloud) [RedHat-8.2 - stack@undercloud ~]$ cat /etc/hosts
# BEGIN ANSIBLE MANAGED BLOCK
172.16.13.133 oc0-compute-0.mydomain.tld oc0-compute-0
172.16.11.215 oc0-compute-0.storage.mydomain.tld oc0-compute-0.storage
172.16.13.133 oc0-compute-0.internalapi.mydomain.tld oc0-compute-0.internalapi
172.16.14.38 oc0-compute-0.tenant.mydomain.tld oc0-compute-0.tenant
192.168.24.18 oc0-compute-0.ctlplane.mydomain.tld oc0-compute-0.ctlplane
172.16.13.62 oc0-controller-0.mydomain.tld oc0-controller-0
172.16.11.46 oc0-controller-0.storage.mydomain.tld oc0-controller-0.storage
172.16.12.163 oc0-controller-0.storagemgmt.mydomain.tld oc0-controller-0.storagemgmt
172.16.13.62 oc0-controller-0.internalapi.mydomain.tld oc0-controller-0.internalapi
172.16.14.238 oc0-controller-0.tenant.mydomain.tld oc0-controller-0.tenant
192.168.100.47 oc0-controller-0.external.mydomain.tld oc0-controller-0.external
192.168.24.9 oc0-controller-0.ctlplane.mydomain.tld oc0-controller-0.ctlplane
172.16.13.197 oc0-controller-1.mydomain.tld oc0-controller-1
172.16.11.38 oc0-controller-1.storage.mydomain.tld oc0-controller-1.storage
172.16.12.120 oc0-controller-1.storagemgmt.mydomain.tld oc0-controller-1.storagemgmt
172.16.13.197 oc0-controller-1.internalapi.mydomain.tld oc0-controller-1.internalapi
172.16.14.81 oc0-controller-1.tenant.mydomain.tld oc0-controller-1.tenant
192.168.100.73 oc0-controller-1.external.mydomain.tld oc0-controller-1.external
192.168.24.12 oc0-controller-1.ctlplane.mydomain.tld oc0-controller-1.ctlplane
172.16.13.85 oc0-controller-2.mydomain.tld oc0-controller-2
172.16.11.204 oc0-controller-2.storage.mydomain.tld oc0-controller-2.storage
172.16.12.60 oc0-controller-2.storagemgmt.mydomain.tld oc0-controller-2.storagemgmt
172.16.13.85 oc0-controller-2.internalapi.mydomain.tld oc0-controller-2.internalapi
172.16.14.93 oc0-controller-2.tenant.mydomain.tld oc0-controller-2.tenant
192.168.100.33 oc0-controller-2.external.mydomain.tld oc0-controller-2.external
192.168.24.19 oc0-controller-2.ctlplane.mydomain.tld oc0-controller-2.ctlplane

192.168.24.1 undercloud.ctlplane.mydomain.tld undercloud.ctlplane
192.168.24.20  overcloud0.ctlplane.mydomain.tld
172.16.11.237  overcloud0.storagecloud0.mydomain.tld
172.16.12.11  overcloud0.storagemgmtcloud0.mydomain.tld
172.16.13.208  overcloud0.internalapicloud0.mydomain.tld
192.168.100.31  overcloud0.mydomain.tld
# END ANSIBLE MANAGED BLOCK
127.0.0.1 undercloud.mydomain.tld localhost.mydomain.tld undercloud localhost
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

Comment 6 Alex Schultz 2020-09-22 13:24:56 UTC
The attached inventory is a valid yaml file.  This seems to be an issue with the way ansible is handling the group names out of the inventory. It looks like it lowercases the input so it then fails to match the group and assumes it's a host. This is not an inventory problem so I'd file an issue with ansible.

Comment 7 Uemit Seren 2020-11-10 20:01:47 UTC
We are running into a similar issue: 

When running the the tripleo-ansible-inventory without an overcloud the script generates following inventory:

Undercloud:
  hosts:
    undercloud: {}
  vars:
    ansible_connection: local
    ansible_host: localhost
    ansible_python_interpreter: /usr/bin/python3
    ansible_remote_tmp: /tmp/ansible-${USER}
    auth_url: https://10.100.72.4:13000
    cacert: /etc/pki/ca-trust/source/anchors/cm-local-ca.pem
    os_auth_token: XXXXX
    plan: overcloud
    plans: [overcloud]
    project_name: admin
    undercloud_service_list: [tripleo_nova_compute, tripleo_heat_engine, tripleo_ironic_conductor,
      tripleo_swift_container_server, tripleo_swift_object_server, tripleo_mistral_engine]
    undercloud_swift_url: https://10.100.72.4:13808/v1/AUTH_747d0549df934531807060de7d6079b9
    username: admin
overcloud:
  children:
    overcloud: {}


However this causes an error when running some ansible ad hoc tasks which causes the inventory parsing to fail and only the localhost to be added to the inventory (see below). It looks like ansible doesn't like that the overcloud group tries to add itself as children. 

[[dev]stack@uc environments]$ ansible -m ping -i ~/ansible_inventory.yaml all
[WARNING]:  * Failed to parse /home/stack/ansible_inventory.yaml with auto plugin: no root 'plugin' key found, '/home/stack/ansible_inventory.yaml' is not a valid YAML inventory plugin config file
[WARNING]:  * Failed to parse /home/stack/ansible_inventory.yaml with yaml plugin: can't add group to itself
[WARNING]:  * Failed to parse /home/stack/ansible_inventory.yaml with ini plugin: Invalid host pattern 'Undercloud:' supplied, ending in ':' is not allowed, this character is reserved to provide a port.
[WARNING]: Unable to parse /home/stack/ansible_inventory.yaml as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'


This will affect the pre-deployment and pre-introspection validation playbooks because they also generate this inventory file and then any tasks that are supposed to be run on the "all" host group are skipped/not executed.

Should I open a separate issue ?


Note You need to log in before you can comment on or make changes to this bug.