mirror of
https://github.com/ansible/awx.git
synced 2026-01-09 23:12:08 -03:30
add constructed kind to inventory module
- add kind 'constructed' to inventory module - add 'input_inventories' field to inventory module Co-authored-by: Rick Elrod <rick@elrod.me> Signed-off-by: Rick Elrod <rick@elrod.me>
This commit is contained in:
parent
df6bb5a8b8
commit
e22967d28d
@ -54,7 +54,7 @@ options:
|
||||
kind:
|
||||
description:
|
||||
- The kind field. Cannot be modified after created.
|
||||
choices: ["", "smart"]
|
||||
choices: ["", "smart", "constructed"]
|
||||
type: str
|
||||
host_filter:
|
||||
description:
|
||||
@ -65,6 +65,11 @@ options:
|
||||
- list of Instance Groups for this Organization to run on.
|
||||
type: list
|
||||
elements: str
|
||||
input_inventories:
|
||||
description:
|
||||
- List of Inventories to use as input for Constructed Inventory.
|
||||
type: list
|
||||
elements: str
|
||||
prevent_instance_group_fallback:
|
||||
description:
|
||||
- Prevent falling back to instance groups set on the organization
|
||||
@ -111,11 +116,12 @@ def main():
|
||||
description=dict(),
|
||||
organization=dict(required=True),
|
||||
variables=dict(type='dict'),
|
||||
kind=dict(choices=['', 'smart']),
|
||||
kind=dict(choices=['', 'smart', 'constructed']),
|
||||
host_filter=dict(),
|
||||
instance_groups=dict(type="list", elements='str'),
|
||||
prevent_instance_group_fallback=dict(type='bool'),
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
input_inventories=dict(type='list', elements='str'),
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
@ -181,6 +187,13 @@ def main():
|
||||
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 kind == 'constructed':
|
||||
input_inventory_names = module.params.get('input_inventories')
|
||||
if input_inventory_names is not None:
|
||||
association_fields['input_inventories'] = []
|
||||
for item in input_inventory_names:
|
||||
association_fields['input_inventories'].append(module.resolve_name_to_id('inventories', item))
|
||||
|
||||
# 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,
|
||||
|
||||
@ -20,7 +20,9 @@ read_only_endpoints_with_modules = ['settings', 'role', 'project_update', 'workf
|
||||
|
||||
# If a module should not be created for an endpoint and the endpoint is not read-only add it here
|
||||
# THINK HARD ABOUT DOING THIS
|
||||
no_module_for_endpoint = []
|
||||
no_module_for_endpoint = [
|
||||
'constructed_inventory', # This is a view for inventory with kind=constructed
|
||||
]
|
||||
|
||||
# Some modules work on the related fields of an endpoint. These modules will not have an auto-associated endpoint
|
||||
no_endpoint_for_module = [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user