Primary development of inventory plugins, partial compat layer

Initialize some inventory plugin test data files
Implement openstack inventory plugin

This may be removed later:
- port non-JSON line strip method from core

Dupliate effort with AWX mainline devel
- Produce ansible_version related to venv

Refactor some of injector management, moving more
  of this overhead into tasks.py, when it comes to
  managing injector kwargs

Upgrade and move openstack inventory script
  sync up parameters

Add extremely detailed logic to inventory file creation
for ec2, Azure, and gce so that they are closer to a
genuine superset of what the contrib script used to give.
This commit is contained in:
AlanCoding
2019-01-29 14:59:16 -05:00
parent dd854baba2
commit bc5881ad21
14 changed files with 443 additions and 95 deletions
@@ -0,0 +1,4 @@
plugin: azure_rm
regions:
- southcentralus
- westus
@@ -0,0 +1,4 @@
plugin: aws_ec2
regions:
- us-east-2
- ap-south-1
@@ -0,0 +1,13 @@
ansible:
expand_hostvars: true
fail_on_errors: true
use_hostnames: false
clouds:
devstack:
auth:
auth_url: https://foo.invalid
domain_name: fooo
password: fooo
project_name: fooo
username: fooo
private: false
@@ -0,0 +1,6 @@
clouds_yaml_path:
- {{ file_reference }}
expand_hostvars: true
fail_on_errors: true
inventory_hostname: name
plugin: openstack
@@ -236,7 +236,12 @@ def test_inventory_script_structure(this_kind, script_or_plugin, inventory):
create_reference_data(ref_dir, content)
pytest.skip('You set MAKE_INVENTORY_REFERENCE_FILES, so this created files, unset to run actual test.')
else:
expected_file_list = os.listdir(ref_dir)
try:
expected_file_list = os.listdir(ref_dir)
except FileNotFoundError as e:
raise FileNotFoundError(
'Maybe you never made reference files? '
'MAKE_INVENTORY_REFERENCE_FILES=true py.test ...\noriginal: {}'.format(e))
assert set(expected_file_list) == set(content.keys()), (
'Inventory update runtime environment does not have expected files'
)
@@ -1,5 +1,6 @@
import os
import os.path
import json
import pytest
@@ -31,3 +32,10 @@ def test_could_be_inventory(filename):
def test_is_not_inventory(filename):
path = os.path.join(DATA, 'inventories', 'invalid')
assert could_be_inventory(DATA, path, filename) is None
def test_filter_non_json_lines():
data = {'foo': 'bar', 'bar': 'foo'}
dumped_data = json.dumps(data, indent=2)
output = 'Openstack does this\nOh why oh why\n{}\ntrailing lines\nneed testing too'.format(dumped_data)
assert filter_non_json_lines(output) == dumped_data