From e84642b4a17abe968c7704f498f560e77393cfba Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Thu, 28 Mar 2019 10:37:30 -0400 Subject: [PATCH] Set Ansible name transform setting for built-in sources This is the current default but will change in the future for these sources, we do not want behavior change --- awx/main/models/inventory.py | 2 ++ awx/main/tasks.py | 2 -- awx/main/tests/data/inventory/plugins/azure_rm/env.json | 3 ++- awx/main/tests/data/inventory/plugins/ec2/env.json | 3 ++- awx/main/tests/data/inventory/plugins/gce/env.json | 3 +++ awx/main/tests/data/inventory/plugins/openstack/env.json | 3 +++ awx/main/tests/data/inventory/plugins/satellite6/env.json | 3 ++- awx/main/tests/data/inventory/plugins/tower/env.json | 3 ++- awx/main/tests/data/inventory/scripts/azure_rm/env.json | 3 ++- awx/main/tests/data/inventory/scripts/cloudforms/env.json | 3 ++- awx/main/tests/data/inventory/scripts/ec2/env.json | 3 ++- awx/main/tests/data/inventory/scripts/gce/env.json | 3 ++- awx/main/tests/data/inventory/scripts/openstack/env.json | 3 ++- awx/main/tests/data/inventory/scripts/rhv/env.json | 3 ++- awx/main/tests/data/inventory/scripts/satellite6/env.json | 3 ++- awx/main/tests/data/inventory/scripts/tower/env.json | 3 ++- awx/main/tests/data/inventory/scripts/vmware/env.json | 3 ++- 17 files changed, 34 insertions(+), 15 deletions(-) create mode 100644 awx/main/tests/data/inventory/plugins/gce/env.json create mode 100644 awx/main/tests/data/inventory/plugins/openstack/env.json diff --git a/awx/main/models/inventory.py b/awx/main/models/inventory.py index 9f466964e2..4501f2f6ba 100644 --- a/awx/main/models/inventory.py +++ b/awx/main/models/inventory.py @@ -1886,6 +1886,8 @@ class PluginFileInjector(object): else: injector_env = self.get_script_env(inventory_update, private_data_dir, private_data_files) env.update(injector_env) + # Preserves current behavior for Ansible change in default planned for 2.10 + env['ANSIBLE_TRANSFORM_INVALID_GROUP_CHARS'] = 'never' return env def _get_shared_env(self, inventory_update, private_data_dir, private_data_files): diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 41b48c2489..f4b62ebe77 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -1996,8 +1996,6 @@ class RunInventoryUpdate(BaseTask): else: env['ANSIBLE_INVENTORY_ENABLED'] = 'script' - # TODO: option for Automatic transformation of group names, ANSIBLE_TRANSFORM_INVALID_GROUP_CHARS - if inventory_update.source in ['scm', 'custom']: for env_k in inventory_update.source_vars_dict: if str(env_k) not in env and str(env_k) not in settings.INV_ENV_VARIABLE_BLACKLIST: diff --git a/awx/main/tests/data/inventory/plugins/azure_rm/env.json b/awx/main/tests/data/inventory/plugins/azure_rm/env.json index 244256f83c..da02daeb92 100644 --- a/awx/main/tests/data/inventory/plugins/azure_rm/env.json +++ b/awx/main/tests/data/inventory/plugins/azure_rm/env.json @@ -4,5 +4,6 @@ "AZURE_TENANT": "fooo", "AZURE_SECRET": "fooo", "AZURE_CLOUD_ENVIRONMENT": "fooo", - "ANSIBLE_JINJA2_NATIVE": "True" + "ANSIBLE_JINJA2_NATIVE": "True", + "ANSIBLE_TRANSFORM_INVALID_GROUP_CHARS": "never" } \ No newline at end of file diff --git a/awx/main/tests/data/inventory/plugins/ec2/env.json b/awx/main/tests/data/inventory/plugins/ec2/env.json index f57b4748c3..f03d9b25b0 100644 --- a/awx/main/tests/data/inventory/plugins/ec2/env.json +++ b/awx/main/tests/data/inventory/plugins/ec2/env.json @@ -2,5 +2,6 @@ "AWS_ACCESS_KEY_ID": "fooo", "AWS_SECRET_ACCESS_KEY": "fooo", "AWS_SECURITY_TOKEN": "fooo", - "ANSIBLE_JINJA2_NATIVE": "True" + "ANSIBLE_JINJA2_NATIVE": "True", + "ANSIBLE_TRANSFORM_INVALID_GROUP_CHARS": "never" } \ No newline at end of file diff --git a/awx/main/tests/data/inventory/plugins/gce/env.json b/awx/main/tests/data/inventory/plugins/gce/env.json new file mode 100644 index 0000000000..f18da63d1c --- /dev/null +++ b/awx/main/tests/data/inventory/plugins/gce/env.json @@ -0,0 +1,3 @@ +{ + "ANSIBLE_TRANSFORM_INVALID_GROUP_CHARS": "never" +} \ No newline at end of file diff --git a/awx/main/tests/data/inventory/plugins/openstack/env.json b/awx/main/tests/data/inventory/plugins/openstack/env.json new file mode 100644 index 0000000000..f18da63d1c --- /dev/null +++ b/awx/main/tests/data/inventory/plugins/openstack/env.json @@ -0,0 +1,3 @@ +{ + "ANSIBLE_TRANSFORM_INVALID_GROUP_CHARS": "never" +} \ No newline at end of file diff --git a/awx/main/tests/data/inventory/plugins/satellite6/env.json b/awx/main/tests/data/inventory/plugins/satellite6/env.json index ae1941a8dc..4d5dbb0c6b 100644 --- a/awx/main/tests/data/inventory/plugins/satellite6/env.json +++ b/awx/main/tests/data/inventory/plugins/satellite6/env.json @@ -1,5 +1,6 @@ { "FOREMAN_SERVER": "https://foo.invalid", "FOREMAN_USER": "fooo", - "FOREMAN_PASSWORD": "fooo" + "FOREMAN_PASSWORD": "fooo", + "ANSIBLE_TRANSFORM_INVALID_GROUP_CHARS": "never" } \ No newline at end of file diff --git a/awx/main/tests/data/inventory/plugins/tower/env.json b/awx/main/tests/data/inventory/plugins/tower/env.json index d46d7e22ae..169ba26f53 100644 --- a/awx/main/tests/data/inventory/plugins/tower/env.json +++ b/awx/main/tests/data/inventory/plugins/tower/env.json @@ -2,5 +2,6 @@ "TOWER_HOST": "https://foo.invalid", "TOWER_USERNAME": "fooo", "TOWER_PASSWORD": "fooo", - "TOWER_VERIFY_SSL": "False" + "TOWER_VERIFY_SSL": "False", + "ANSIBLE_TRANSFORM_INVALID_GROUP_CHARS": "never" } \ No newline at end of file diff --git a/awx/main/tests/data/inventory/scripts/azure_rm/env.json b/awx/main/tests/data/inventory/scripts/azure_rm/env.json index acab1810f9..15eaf5a60e 100644 --- a/awx/main/tests/data/inventory/scripts/azure_rm/env.json +++ b/awx/main/tests/data/inventory/scripts/azure_rm/env.json @@ -4,5 +4,6 @@ "AZURE_TENANT": "fooo", "AZURE_SECRET": "fooo", "AZURE_CLOUD_ENVIRONMENT": "fooo", - "AZURE_INI_PATH": "{{ file_reference }}" + "AZURE_INI_PATH": "{{ file_reference }}", + "ANSIBLE_TRANSFORM_INVALID_GROUP_CHARS": "never" } \ No newline at end of file diff --git a/awx/main/tests/data/inventory/scripts/cloudforms/env.json b/awx/main/tests/data/inventory/scripts/cloudforms/env.json index 9d6bf03bda..fc47a8a120 100644 --- a/awx/main/tests/data/inventory/scripts/cloudforms/env.json +++ b/awx/main/tests/data/inventory/scripts/cloudforms/env.json @@ -1,3 +1,4 @@ { - "CLOUDFORMS_INI_PATH": "{{ file_reference }}" + "CLOUDFORMS_INI_PATH": "{{ file_reference }}", + "ANSIBLE_TRANSFORM_INVALID_GROUP_CHARS": "never" } \ No newline at end of file diff --git a/awx/main/tests/data/inventory/scripts/ec2/env.json b/awx/main/tests/data/inventory/scripts/ec2/env.json index d8dc466709..6be2ff5e3c 100644 --- a/awx/main/tests/data/inventory/scripts/ec2/env.json +++ b/awx/main/tests/data/inventory/scripts/ec2/env.json @@ -2,5 +2,6 @@ "AWS_ACCESS_KEY_ID": "fooo", "AWS_SECRET_ACCESS_KEY": "fooo", "AWS_SECURITY_TOKEN": "fooo", - "EC2_INI_PATH": "{{ file_reference }}" + "EC2_INI_PATH": "{{ file_reference }}", + "ANSIBLE_TRANSFORM_INVALID_GROUP_CHARS": "never" } \ No newline at end of file diff --git a/awx/main/tests/data/inventory/scripts/gce/env.json b/awx/main/tests/data/inventory/scripts/gce/env.json index 76ccfa623b..5d7cc259b2 100644 --- a/awx/main/tests/data/inventory/scripts/gce/env.json +++ b/awx/main/tests/data/inventory/scripts/gce/env.json @@ -3,5 +3,6 @@ "GCE_PROJECT": "fooo", "GCE_CREDENTIALS_FILE_PATH": "{{ file_reference }}", "GCE_ZONE": "us-east4-a,us-west1-b", - "GCE_INI_PATH": "{{ file_reference }}" + "GCE_INI_PATH": "{{ file_reference }}", + "ANSIBLE_TRANSFORM_INVALID_GROUP_CHARS": "never" } \ No newline at end of file diff --git a/awx/main/tests/data/inventory/scripts/openstack/env.json b/awx/main/tests/data/inventory/scripts/openstack/env.json index 71903398b7..2fd8882a19 100644 --- a/awx/main/tests/data/inventory/scripts/openstack/env.json +++ b/awx/main/tests/data/inventory/scripts/openstack/env.json @@ -1,3 +1,4 @@ { - "OS_CLIENT_CONFIG_FILE": "{{ file_reference }}" + "OS_CLIENT_CONFIG_FILE": "{{ file_reference }}", + "ANSIBLE_TRANSFORM_INVALID_GROUP_CHARS": "never" } \ No newline at end of file diff --git a/awx/main/tests/data/inventory/scripts/rhv/env.json b/awx/main/tests/data/inventory/scripts/rhv/env.json index 6896ec0f5f..b2e702e809 100644 --- a/awx/main/tests/data/inventory/scripts/rhv/env.json +++ b/awx/main/tests/data/inventory/scripts/rhv/env.json @@ -2,5 +2,6 @@ "OVIRT_INI_PATH": "{{ file_reference }}", "OVIRT_URL": "https://foo.invalid", "OVIRT_USERNAME": "fooo", - "OVIRT_PASSWORD": "fooo" + "OVIRT_PASSWORD": "fooo", + "ANSIBLE_TRANSFORM_INVALID_GROUP_CHARS": "never" } \ No newline at end of file diff --git a/awx/main/tests/data/inventory/scripts/satellite6/env.json b/awx/main/tests/data/inventory/scripts/satellite6/env.json index 73a0cd0d79..4597e9b24c 100644 --- a/awx/main/tests/data/inventory/scripts/satellite6/env.json +++ b/awx/main/tests/data/inventory/scripts/satellite6/env.json @@ -1,3 +1,4 @@ { - "FOREMAN_INI_PATH": "{{ file_reference }}" + "FOREMAN_INI_PATH": "{{ file_reference }}", + "ANSIBLE_TRANSFORM_INVALID_GROUP_CHARS": "never" } \ No newline at end of file diff --git a/awx/main/tests/data/inventory/scripts/tower/env.json b/awx/main/tests/data/inventory/scripts/tower/env.json index e951d3484a..18176bfefd 100644 --- a/awx/main/tests/data/inventory/scripts/tower/env.json +++ b/awx/main/tests/data/inventory/scripts/tower/env.json @@ -4,5 +4,6 @@ "TOWER_PASSWORD": "fooo", "TOWER_VERIFY_SSL": "False", "TOWER_INVENTORY": "42", - "TOWER_LICENSE_TYPE": "open" + "TOWER_LICENSE_TYPE": "open", + "ANSIBLE_TRANSFORM_INVALID_GROUP_CHARS": "never" } \ No newline at end of file diff --git a/awx/main/tests/data/inventory/scripts/vmware/env.json b/awx/main/tests/data/inventory/scripts/vmware/env.json index 15d41e90b5..cc4760b027 100644 --- a/awx/main/tests/data/inventory/scripts/vmware/env.json +++ b/awx/main/tests/data/inventory/scripts/vmware/env.json @@ -3,5 +3,6 @@ "VMWARE_PASSWORD": "fooo", "VMWARE_HOST": "https://foo.invalid", "VMWARE_VALIDATE_CERTS": "False", - "VMWARE_INI_PATH": "{{ file_reference }}" + "VMWARE_INI_PATH": "{{ file_reference }}", + "ANSIBLE_TRANSFORM_INVALID_GROUP_CHARS": "never" } \ No newline at end of file