From 616e7082b33c267f4227ab965b0e5252b040ba1f Mon Sep 17 00:00:00 2001 From: Jim Ladd Date: Mon, 27 Apr 2020 00:17:46 -0700 Subject: [PATCH] Add support for satellite6_want_ansible_ssh_host * defaults to IPv6, falls back to IP --- awx/main/models/inventory.py | 9 +++++++++ .../data/inventory/plugins/satellite6/files/foreman.yml | 2 ++ 2 files changed, 11 insertions(+) diff --git a/awx/main/models/inventory.py b/awx/main/models/inventory.py index 7c596547e7..c8a54354cf 100644 --- a/awx/main/models/inventory.py +++ b/awx/main/models/inventory.py @@ -2577,6 +2577,12 @@ class satellite6(PluginFileInjector): def inventory_as_dict(self, inventory_update, private_data_dir): ret = super(satellite6, self).inventory_as_dict(inventory_update, private_data_dir) + want_ansible_ssh_host = False + foreman_opts = inventory_update.source_vars_dict.copy() + for k, v in foreman_opts.items(): + if k == 'satellite6_want_ansible_ssh_host' and isinstance(v, bool): + want_ansible_ssh_host = v + # Compatibility content group_by_hostvar = { "environment": {"prefix": "foreman_environment_", @@ -2603,6 +2609,9 @@ class satellite6(PluginFileInjector): ret['want_facts'] = True ret['want_params'] = True + if want_ansible_ssh_host: + ret['compose'] = {'ansible_ssh_host': "foreman['ip6'] | default(foreman['ip'], true)"} + return ret diff --git a/awx/main/tests/data/inventory/plugins/satellite6/files/foreman.yml b/awx/main/tests/data/inventory/plugins/satellite6/files/foreman.yml index 20d868137a..6d4faee619 100644 --- a/awx/main/tests/data/inventory/plugins/satellite6/files/foreman.yml +++ b/awx/main/tests/data/inventory/plugins/satellite6/files/foreman.yml @@ -1,3 +1,5 @@ +compose: + ansible_ssh_host: foreman['ip6'] | default(foreman['ip'], true) keyed_groups: - key: foreman['environment_name'] | lower | regex_replace(' ', '') | regex_replace('[^A-Za-z0-9\_]', '_') | regex_replace('none', '') prefix: foreman_environment_