Bug 1897117 - tripleo-ansible-inventory.yaml without overcloud generates invalid ansible inventory
Summary: tripleo-ansible-inventory.yaml without overcloud generates invalid ansible in...
Keywords:
Status: CLOSED DUPLICATE of bug 1887444
Alias: None
Product: Red Hat OpenStack
Classification: Red Hat
Component: openstack-tripleo-validations
Version: 16.1 (Train)
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: z4
: ---
Assignee: mathieu bultel
QA Contact: nlevinki
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-11-12 11:06 UTC by Uemit Seren
Modified: 2020-11-19 22:33 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-11-19 10:10:14 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Uemit Seren 2020-11-12 11:06:16 UTC
Description of problem:

The tripleo-ansible-inventory script generates an invalid ansible inventory when it's executed without an overcloud. It will generate 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:

 overcloud:
  children:
    overcloud: {}

[[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.


Version-Release number of selected component (if applicable):

OSP16.1

How reproducible:


Steps to Reproduce:
1. Install director
2. Run tripleo-ansible-inventory --os-cloud=undercloud --static-yaml-inventory  ~/ansible_inventory.yaml
3. Run ad hoc tasks: ansible -i ~/ansible_inventory.yaml -m ping all
4. or run any tripleo validation: openstack tripleo validator run --group pre-deployment

Actual results:

Invalid ansible inventory and only implicit localhost in inventory

Expected results:

Valid ansible inventory with an empty overcloud group and the Undercloud group

Additional info:

If "overcloud: {}" is removed from the overcloud group's children section, ansible will be able to parse the inventory

Comment 1 Cristian Muresanu 2020-11-17 22:42:21 UTC
Hi,

CU hitting the same error while running validation:

~~~
(undercloud) [stack@director ~]$ openstack tripleo validator run --validation undercloud-neutron-sanity-check
[WARNING]:  * Failed to parse /home/stack/tripleo-ansible-inventory.yaml with auto plugin: no root 'plugin' key found, '/home/stack/tripleo-ansible-inventory.yaml' is not a valid YAML inventory plugin config file

[WARNING]:  * Failed to parse /home/stack/tripleo-ansible-inventory.yaml with yaml plugin: can't add group to itself

[WARNING]:  * Failed to parse /home/stack/tripleo-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/tripleo-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'

Monday 16 November 2020  12:49:33 -0500 (0:00:00.037)       0:00:00.037 ******* 

Monday 16 November 2020  12:49:33 -0500 (0:00:00.106)       0:00:00.144 ******* 

Monday 16 November 2020  12:49:33 -0500 (0:00:00.507)       0:00:00.652 ******* 

Monday 16 November 2020  12:49:34 -0500 (0:00:00.357)       0:00:01.010 ******* 

Monday 16 November 2020  12:49:34 -0500 (0:00:00.056)       0:00:01.066 ******* 

Monday 16 November 2020  12:49:34 -0500 (0:00:00.408)       0:00:01.474 ******* 

Monday 16 November 2020  12:49:36 -0500 (0:00:01.863)       0:00:03.338 ******* 

Monday 16 November 2020  12:49:36 -0500 (0:00:00.055)       0:00:03.394 ******* 

Monday 16 November 2020  12:49:36 -0500 (0:00:00.055)       0:00:03.449 ******* 

Monday 16 November 2020  12:49:36 -0500 (0:00:00.056)       0:00:03.505 ******* 

Monday 16 November 2020  12:49:36 -0500 (0:00:00.056)       0:00:03.561 ******* 



Monday 16 November 2020  12:49:37 -0500 (0:00:00.163)       0:00:03.725 ******* 
=============================================================================== 

neutron_sanity_check : Run neutron-sanity-check ------------------------- 1.86s
neutron_sanity_check : Get the path of tripleo undercloud config file --- 0.51s

neutron_sanity_check : Check if wanted container exists ----------------- 0.41s
neutron_sanity_check : Get the Container CLI from the undercloud.conf file --- 0.36s
neutron_sanity_check : Fail --------------------------------------------- 0.16s

neutron_sanity_check : Set oc_container_cli and container_name for the Controller --- 0.11s
neutron_sanity_check : Set uc_container_cli and container_name for the Undercloud --- 0.06s

neutron_sanity_check : Create output ------------------------------------ 0.06s
neutron_sanity_check : Output warning ----------------------------------- 0.06s
neutron_sanity_check : Detect errors ------------------------------------ 0.06s

neutron_sanity_check : Detect warnings ---------------------------------- 0.06s

/usr/lib/python3.6/site-packages/validations_libs/ansible.py:374: ResourceWarning: unclosed file <_io.BufferedWriter name='/var/log/validations/artifacts//d900bc2a-8183-4469-a360-72c78d008d83_undercloud-neutron-sanity-check.yaml_2020-11-16T17:49:32.583801Z/artifacts/stdout'>
  status, rc = runner.run()
+--------------------------------------+---------------------------------+--------+------------+----------------+-------------------+-------------+
|                 UUID                 |           Validations           | Status | Host_Group | Status_by_Host | Unreachable_Hosts |   Duration  |
+--------------------------------------+---------------------------------+--------+------------+----------------+-------------------+-------------+
| d900bc2a-8183-4469-a360-72c78d008d83 | undercloud-neutron-sanity-check | FAILED | undercloud |   undercloud   |                   | 0:00:03.589 |
+--------------------------------------+---------------------------------+--------+------------+----------------+-------------------+-------------+
sys:1: ResourceWarning: unclosed <ssl.SSLSocket fd=4, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('10.49.20.4', 49722), raddr=('10.49.20.4', 13000)>
~~~

Comment 3 Gaël Chamoulaud 2020-11-19 10:10:14 UTC

*** This bug has been marked as a duplicate of bug 1887444 ***


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