mirror of
https://github.com/ansible/awx.git
synced 2026-02-17 03:00:04 -03:30
Add ability to look up inventory sources by org name/ID
This commit is contained in:
@@ -128,6 +128,10 @@ options:
|
||||
- list of notifications to send on error
|
||||
type: list
|
||||
elements: str
|
||||
organization:
|
||||
description:
|
||||
- Name of organization for project.
|
||||
type: str
|
||||
extends_documentation_fragment: awx.awx.auth
|
||||
'''
|
||||
|
||||
@@ -140,6 +144,7 @@ EXAMPLES = '''
|
||||
credential: previously-created-credential
|
||||
overwrite: True
|
||||
update_on_launch: True
|
||||
organization: Default
|
||||
source_vars:
|
||||
private: false
|
||||
'''
|
||||
@@ -168,6 +173,10 @@ def main():
|
||||
enabled_value=dict(),
|
||||
host_filter=dict(),
|
||||
credential=dict(),
|
||||
source_regions=dict(),
|
||||
instance_filters=dict(),
|
||||
group_by=dict(),
|
||||
organization=dict(),
|
||||
overwrite=dict(type='bool'),
|
||||
overwrite_vars=dict(type='bool'),
|
||||
custom_virtualenv=dict(),
|
||||
@@ -195,6 +204,12 @@ def main():
|
||||
source_project = module.params.get('source_project')
|
||||
state = module.params.get('state')
|
||||
|
||||
new_fields = {}
|
||||
organization_id = None
|
||||
organization = module.params.get('organization')
|
||||
if organization:
|
||||
organization_id = module.get_one_by_name_or_id('organizations', organization)
|
||||
|
||||
# Attempt to look up inventory source based on the provided name and inventory ID
|
||||
inventory_id = module.resolve_name_to_id('inventories', inventory)
|
||||
inventory_source = module.get_one('inventory_sources', **{
|
||||
|
||||
@@ -32,6 +32,11 @@ options:
|
||||
- The name of the inventory source to update.
|
||||
required: True
|
||||
type: str
|
||||
organization:
|
||||
description:
|
||||
- Name of organization for project.
|
||||
type: str
|
||||
required: False
|
||||
extends_documentation_fragment: awx.awx.auth
|
||||
'''
|
||||
|
||||
@@ -40,6 +45,7 @@ EXAMPLES = '''
|
||||
tower_inventory_source_update:
|
||||
inventory: "My Inventory"
|
||||
inventory_source: "Example Inventory Source"
|
||||
organization: Default
|
||||
|
||||
- name: Update all inventory sources
|
||||
tower_inventory_source_update:
|
||||
@@ -69,6 +75,7 @@ def main():
|
||||
argument_spec = dict(
|
||||
inventory=dict(required=True),
|
||||
inventory_source=dict(required=True),
|
||||
organization=dict(),
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
@@ -78,6 +85,12 @@ def main():
|
||||
inventory = module.params.get('inventory')
|
||||
inventory_source = module.params.get('inventory_source')
|
||||
|
||||
new_fields = {}
|
||||
organization_id = None
|
||||
organization = module.params.get('organization')
|
||||
if organization:
|
||||
organization_id = module.get_one_by_name_or_id('organizations', organization)
|
||||
|
||||
# Attempt to look up the inventory the user specified (these will fail the module if not found)
|
||||
inventory_object = module.get_one_by_name_or_id('inventories', inventory)
|
||||
# Return all inventory sources related to the specified inventory
|
||||
|
||||
Reference in New Issue
Block a user