diff options
author | sean-m-ssullivan <ssulliva@redhat.com> | 2021-04-03 21:00:56 +0200 |
---|---|---|
committer | sean-m-ssullivan <ssulliva@redhat.com> | 2021-04-03 21:00:56 +0200 |
commit | f9d2db696b2ac3f2bbdd36574a105c973c43f054 (patch) | |
tree | 679ce833b69ca69cb034079323d6ec92ff3acb3d /awx_collection/plugins | |
parent | Merge pull request #64 from ansible/devel (diff) | |
download | awx-f9d2db696b2ac3f2bbdd36574a105c973c43f054.tar.xz awx-f9d2db696b2ac3f2bbdd36574a105c973c43f054.zip |
add instance groups
Diffstat (limited to 'awx_collection/plugins')
-rw-r--r-- | awx_collection/plugins/modules/tower_inventory.py | 16 | ||||
-rw-r--r-- | awx_collection/plugins/modules/tower_job_template.py | 12 | ||||
-rw-r--r-- | awx_collection/plugins/modules/tower_organization.py | 13 |
3 files changed, 39 insertions, 2 deletions
diff --git a/awx_collection/plugins/modules/tower_inventory.py b/awx_collection/plugins/modules/tower_inventory.py index 10d469d047..b262a3a7a1 100644 --- a/awx_collection/plugins/modules/tower_inventory.py +++ b/awx_collection/plugins/modules/tower_inventory.py @@ -61,6 +61,11 @@ options: description: - Credentials to be used by hosts belonging to this inventory when accessing Red Hat Insights API. type: str + instance_groups: + description: + - list of Instance Groups for this Organization to run on. + type: list + elements: str state: description: - Desired state of the resource. @@ -104,6 +109,7 @@ def main(): variables=dict(type='dict'), kind=dict(choices=['', 'smart'], default=''), host_filter=dict(), + instance_groups=dict(type="list", elements='str'), insights_credential=dict(), state=dict(choices=['present', 'absent'], default='present'), ) @@ -158,12 +164,20 @@ def main(): if insights_credential is not None: inventory_fields['insights_credential'] = module.resolve_name_to_id('credentials', insights_credential) + association_fields = {} + + instance_group_names = module.params.get('instance_groups') + if instance_group_names is not None: + association_fields['instance_groups'] = [] + for item in instance_group_names: + association_fields['instance_groups'].append(module.resolve_name_to_id('instance_groups', item)) + # We need to perform a check to make sure you are not trying to convert a regular inventory into a smart one. if inventory and inventory['kind'] == '' and inventory_fields['kind'] == 'smart': module.fail_json(msg='You cannot turn a regular inventory into a "smart" inventory.') # If the state was present and we can let the module build or update the existing inventory, this will return on its own - module.create_or_update_if_needed(inventory, inventory_fields, endpoint='inventories', item_type='inventory') + module.create_or_update_if_needed(inventory, inventory_fields, endpoint='inventories', item_type='inventory', associations=association_fields,) if __name__ == '__main__': diff --git a/awx_collection/plugins/modules/tower_job_template.py b/awx_collection/plugins/modules/tower_job_template.py index e7ae3f96ff..41e6cbfc3b 100644 --- a/awx_collection/plugins/modules/tower_job_template.py +++ b/awx_collection/plugins/modules/tower_job_template.py @@ -86,6 +86,11 @@ options: description: - Execution Environment to use for the JT. type: str + instance_groups: + description: + - list of Instance Groups for this Organization to run on. + type: list + elements: str forks: description: - The number of parallel or simultaneous processes to use while executing the playbook. @@ -366,6 +371,7 @@ def main(): vault_credential=dict(), credentials=dict(type='list', elements='str'), execution_environment=dict(), + instance_groups=dict(type="list", elements='str'), forks=dict(type='int'), limit=dict(), verbosity=dict(type='int', choices=[0, 1, 2, 3, 4], default=0), @@ -564,6 +570,12 @@ def main(): for item in notifications_error: association_fields['notification_templates_error'].append(module.resolve_name_to_id('notification_templates', item)) + instance_group_names = module.params.get('instance_groups') + if instance_group_names is not None: + association_fields['instance_groups'] = [] + for item in instance_group_names: + association_fields['instance_groups'].append(module.resolve_name_to_id('instance_groups', item)) + on_change = None new_spec = module.params.get('survey_spec') if new_spec is not None: diff --git a/awx_collection/plugins/modules/tower_organization.py b/awx_collection/plugins/modules/tower_organization.py index 4576094c3a..a74aec6653 100644 --- a/awx_collection/plugins/modules/tower_organization.py +++ b/awx_collection/plugins/modules/tower_organization.py @@ -45,6 +45,11 @@ options: default: "present" choices: ["present", "absent"] type: str + instance_groups: + description: + - list of Instance Groups for this Organization to run on. + type: list + elements: str notification_templates_started: description: - list of notifications to send on start @@ -108,6 +113,7 @@ def main(): description=dict(), default_environment=dict(), max_hosts=dict(type='int', default="0"), + instance_groups=dict(type="list", elements='str'), notification_templates_started=dict(type="list", elements='str'), notification_templates_success=dict(type="list", elements='str'), notification_templates_error=dict(type="list", elements='str'), @@ -124,7 +130,6 @@ def main(): description = module.params.get('description') default_ee = module.params.get('default_environment') max_hosts = module.params.get('max_hosts') - # instance_group_names = module.params.get('instance_groups') state = module.params.get('state') # Attempt to look up organization based on the provided name @@ -136,6 +141,12 @@ def main(): # Attempt to look up associated field items the user specified. association_fields = {} + instance_group_names = module.params.get('instance_groups') + if instance_group_names is not None: + association_fields['instance_groups'] = [] + for item in instance_group_names: + association_fields['instance_groups'].append(module.resolve_name_to_id('instance_groups', item)) + notifications_start = module.params.get('notification_templates_started') if notifications_start is not None: association_fields['notification_templates_started'] = [] |