Merge branch 'devel' into collection-existential-state-for-credential-module

This commit is contained in:
Matthew Fernandez
2023-04-10 15:31:11 -06:00
committed by GitHub
231 changed files with 18249 additions and 8709 deletions

View File

@@ -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
@@ -95,6 +100,35 @@ EXAMPLES = '''
description: "Our Foo Cloud Servers"
organization: Foo
state: present
# You can create and modify constructed inventories by creating an inventory
# of kind "constructed" and then editing the automatically generated inventory
# source for that inventory.
- name: Add constructed inventory with two existing input inventories
inventory:
name: My Constructed Inventory
organization: Default
kind: constructed
input_inventories:
- "West Datacenter"
- "East Datacenter"
- name: Edit the constructed inventory source
inventory_source:
# The constructed inventory source will always be in the format:
# "Auto-created source for: <constructed inventory name>"
name: "Auto-created source for: My Constructed Inventory"
inventory: My Constructed Inventory
limit: host3,host4,host6
source_vars:
plugin: constructed
strict: true
use_vars_plugins: true
groups:
shutdown: resolved_state == "shutdown"
shutdown_in_product_dev: resolved_state == "shutdown" and account_alias == "product_dev"
compose:
resolved_state: state | default("running")
'''
@@ -111,11 +145,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 +216,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,

View File

@@ -64,6 +64,10 @@ options:
description:
- If specified, AWX will only import hosts that match this regular expression.
type: str
limit:
description:
- Enter host, group or pattern match
type: str
credential:
description:
- Credential to use for the source.
@@ -172,6 +176,7 @@ def main():
enabled_var=dict(),
enabled_value=dict(),
host_filter=dict(),
limit=dict(),
credential=dict(),
execution_environment=dict(),
custom_virtualenv=dict(),
@@ -279,6 +284,7 @@ def main():
'enabled_value',
'host_filter',
'scm_branch',
'limit',
)
# Layer in all remaining optional information

View File

@@ -284,13 +284,15 @@ def main():
argument_spec=argument_spec,
)
# Alias for manual projects
if module.params.get('scm_type') == "manual":
module.params['scm_type'] = ''
# Extract our parameters
name = module.params.get('name')
new_name = module.params.get("new_name")
copy_from = module.params.get('copy_from')
scm_type = module.params.get('scm_type')
if scm_type == "manual":
scm_type = ""
local_path = module.params.get('local_path')
credential = module.params.get('credential')
scm_update_on_launch = module.params.get('scm_update_on_launch')
@@ -387,7 +389,8 @@ def main():
# this is resolved earlier, so save an API call and don't do it again in the loop above
project_fields['organization'] = org_id
if scm_type == '' and local_path is not None:
# Respect local_path if scm_type is manual type or not specified
if scm_type in ('', None) and local_path is not None:
project_fields['local_path'] = local_path
if scm_update_cache_timeout not in (0, None) and scm_update_on_launch is not True:

View File

@@ -116,8 +116,7 @@ def main():
if result['status_code'] == 405:
module.fail_json(
msg="Unable to trigger a project update because the project scm_type ({0}) does not support it.".format(project['scm_type']),
response=result
msg="Unable to trigger a project update because the project scm_type ({0}) does not support it.".format(project['scm_type']), response=result
)
elif result['status_code'] != 202:
module.fail_json(msg="Failed to update project, see response for details", response=result)

View File

@@ -116,6 +116,11 @@ options:
- Project the role acts on.
type: list
elements: str
instance_groups:
description:
- Instance Group the role acts on.
type: list
elements: str
state:
description:
- Desired state.
@@ -193,6 +198,7 @@ def main():
lookup_organization=dict(),
project=dict(),
projects=dict(type='list', elements='str'),
instance_groups=dict(type='list', elements='str'),
state=dict(choices=['present', 'absent'], default='present'),
)