Update inventory_source module source_script parameter to be optional

Unitied comment

Fix up inventory_source example, misc comment edits
This commit is contained in:
beeankha
2020-02-11 16:32:41 -05:00
parent 94df58a55b
commit fcc679489e
10 changed files with 24 additions and 25 deletions

View File

@@ -111,7 +111,7 @@ def main():
if variables: if variables:
variables = module.load_variables_if_file_specified(variables, 'variables') variables = module.load_variables_if_file_specified(variables, 'variables')
# Create data to sent to create and update # Create the data that gets sent for create and update
group_fields = { group_fields = {
'name': new_name if new_name else name, 'name': new_name if new_name else name,
'inventory': inventory_id, 'inventory': inventory_id,

View File

@@ -125,7 +125,7 @@ def main():
} }
}) })
# Create data to send to create and update # Create the data that gets sent for create and update
host_fields = { host_fields = {
'name': new_name if new_name else name, 'name': new_name if new_name else name,
'description': description, 'description': description,

View File

@@ -117,7 +117,7 @@ def main():
} }
}) })
# Create the data sent to create and update # Create the data that gets sent for create and update
inventory_fields = { inventory_fields = {
'name': name, 'name': name,
'description': description, 'description': description,

View File

@@ -56,6 +56,7 @@ options:
description: description:
- Inventory script to be used when group type is C(custom). - Inventory script to be used when group type is C(custom).
type: str type: str
required: False
source_vars: source_vars:
description: description:
- The variables or environment fields to apply to this source type. - The variables or environment fields to apply to this source type.
@@ -130,13 +131,16 @@ extends_documentation_fragment: awx.awx.auth
''' '''
EXAMPLES = ''' EXAMPLES = '''
- name: Add tower group - name: Add an inventory source
tower_group: tower_inventory_source:
name: localhost name: "source-inventory"
description: "Local Host Group" description: Source for inventory
inventory: "Local Inventory" inventory: previously-created-inventory
state: present credential: previously-created-credential
tower_config_file: "~/tower_cli.cfg" overwrite: True
update_on_launch: True
source_vars:
private: false
''' '''
from ..module_utils.tower_api import TowerModule from ..module_utils.tower_api import TowerModule
@@ -157,7 +161,7 @@ def main():
"azure_rm", "vmware", "satellite6", "cloudforms", "azure_rm", "vmware", "satellite6", "cloudforms",
"openstack", "rhv", "tower", "custom"], required=False), "openstack", "rhv", "tower", "custom"], required=False),
source_path=dict(), source_path=dict(),
source_script=dict(), source_script=dict(required=False),
source_vars=dict(type='dict'), source_vars=dict(type='dict'),
credential=dict(), credential=dict(),
source_regions=dict(), source_regions=dict(),
@@ -176,7 +180,7 @@ def main():
) )
# One question here is do we want to end up supporting this within the ansible module itself (i.e. required if, etc) # One question here is do we want to end up supporting this within the ansible module itself (i.e. required if, etc)
# Or do we want to let the API return issues with "this dosen't support that", etc. # Or do we want to let the API return issues with "this doesn't support that", etc.
# #
# GUI OPTIONS: # GUI OPTIONS:
# - - - - - - - manual: file: scm: ec2: gce azure_rm vmware sat cloudforms openstack rhv tower custom # - - - - - - - manual: file: scm: ec2: gce azure_rm vmware sat cloudforms openstack rhv tower custom
@@ -323,7 +327,7 @@ def main():
if optional_vars['source_vars']: if optional_vars['source_vars']:
optional_vars['source_vars'] = dumps(optional_vars['source_vars']) optional_vars['source_vars'] = dumps(optional_vars['source_vars'])
# Attempt to lookup the related items the user specified (these will fail the module if not found) # Attempt to look up the related items the user specified (these will fail the module if not found)
inventory_id = module.resolve_name_to_id('inventories', inventory) inventory_id = module.resolve_name_to_id('inventories', inventory)
if credential: if credential:
optional_vars['credential'] = module.resolve_name_to_id('credentials', credential) optional_vars['credential'] = module.resolve_name_to_id('credentials', credential)
@@ -332,7 +336,7 @@ def main():
if source_script: if source_script:
optional_vars['source_script'] = module.resolve_name_to_id('inventory_scripts', source_script) optional_vars['source_script'] = module.resolve_name_to_id('inventory_scripts', source_script)
# Attempt to lookup team based on the provided name and org ID # Attempt to look up inventory source based on the provided name and inventory ID
inventory_source = module.get_one('inventory_sources', **{ inventory_source = module.get_one('inventory_sources', **{
'data': { 'data': {
'name': name, 'name': name,
@@ -344,7 +348,7 @@ def main():
if state == 'present' and not inventory_source and not optional_vars['source']: if state == 'present' and not inventory_source and not optional_vars['source']:
module.fail_json(msg="If creating a new inventory source, the source param must be present") module.fail_json(msg="If creating a new inventory source, the source param must be present")
# Create data to sent to create and update # Create the data that gets sent for create and update
inventory_source_fields = { inventory_source_fields = {
'name': new_name if new_name else name, 'name': new_name if new_name else name,
'inventory': inventory_id, 'inventory': inventory_id,

View File

@@ -88,17 +88,11 @@ extends_documentation_fragment: awx.awx.auth
''' '''
EXAMPLES = ''' EXAMPLES = '''
# Launch a job template
- name: Launch a job - name: Launch a job
tower_job_launch: tower_job_launch:
job_template: "My Job Template" job_template: "My Job Template"
register: job register: job
- name: Wait for job max 120s
tower_job_wait:
job_id: "{{ job.id }}"
timeout: 120
- name: Launch a job template with extra_vars on remote Tower instance - name: Launch a job template with extra_vars on remote Tower instance
tower_job_launch: tower_job_launch:
job_template: "My Job Template" job_template: "My Job Template"
@@ -108,7 +102,6 @@ EXAMPLES = '''
var3: "My Third Variable" var3: "My Third Variable"
job_type: run job_type: run
# Launch job template with inventory and credential for prompt on launch
- name: Launch a job with inventory and credential - name: Launch a job with inventory and credential
tower_job_launch: tower_job_launch:
job_template: "My Job Template" job_template: "My Job Template"

View File

@@ -108,6 +108,7 @@ def main():
} }
}) })
# Create the data that gets sent for create and update
org_fields = {'name': name} org_fields = {'name': name}
if description: if description:
org_fields['description'] = description org_fields['description'] = description

View File

@@ -232,6 +232,7 @@ def main():
} }
}) })
# Create the data that gets sent for create and update
project_fields = { project_fields = {
'name': name, 'name': name,
'description': description, 'description': description,

View File

@@ -46,8 +46,6 @@ options:
extends_documentation_fragment: awx.awx.auth extends_documentation_fragment: awx.awx.auth
''' '''
RETURN = ''' # '''
EXAMPLES = ''' EXAMPLES = '''
- name: Set the value of AWX_PROOT_BASE_PATH - name: Set the value of AWX_PROOT_BASE_PATH
tower_settings: tower_settings:

View File

@@ -101,7 +101,7 @@ def main():
} }
}) })
# Create data to sent to create and update # Create the data that gets sent for create and update
team_fields = { team_fields = {
'name': new_name if new_name else name, 'name': new_name if new_name else name,
'description': description, 'description': description,

View File

@@ -128,6 +128,8 @@ def main():
# Extract our parameters # Extract our parameters
state = module.params.get('state') state = module.params.get('state')
# Create the data that gets sent for create and update
user_fields = { user_fields = {
'username': module.params.get('username'), 'username': module.params.get('username'),
'first_name': module.params.get('first_name'), 'first_name': module.params.get('first_name'),