mirror of
https://github.com/ansible/awx.git
synced 2026-03-18 17:37:30 -02:30
[last PR stuff] + Add warning if configs specified in 2 params (#5)
* Lean on API validation for tower_inventory_source arg errors used for - validating needed credential is given - missing source_project for scm sources * Add warning when config is specified in 2 places Fix up unit tests, address multiple comments re: backwards compatibility, redundant methods, etc. Update new_name and variables parameters, update unit tests
This commit is contained in:
@@ -49,8 +49,8 @@ options:
|
||||
default: 'yes'
|
||||
variables:
|
||||
description:
|
||||
- Variables to use for the host. Use C(@) for a file.
|
||||
type: str
|
||||
- Variables to use for the host.
|
||||
type: dict
|
||||
state:
|
||||
description:
|
||||
- Desired state of the resource.
|
||||
@@ -80,6 +80,7 @@ EXAMPLES = '''
|
||||
|
||||
|
||||
from ..module_utils.tower_api import TowerModule
|
||||
import json
|
||||
|
||||
|
||||
def main():
|
||||
@@ -90,7 +91,7 @@ def main():
|
||||
description=dict(default=''),
|
||||
inventory=dict(required=True),
|
||||
enabled=dict(type='bool', default=True),
|
||||
variables=dict(default=''),
|
||||
variables=dict(type='dict', default=''),
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
)
|
||||
|
||||
@@ -106,9 +107,6 @@ def main():
|
||||
state = module.params.get('state')
|
||||
variables = module.params.get('variables')
|
||||
|
||||
if variables:
|
||||
variables = module.load_variables_if_file_specified(variables, 'variables')
|
||||
|
||||
# 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)
|
||||
|
||||
@@ -128,7 +126,7 @@ def main():
|
||||
'enabled': enabled,
|
||||
}
|
||||
if variables:
|
||||
host_fields['variables'] = variables
|
||||
host_fields['variables'] = json.dumps(variables)
|
||||
|
||||
if state == 'absent':
|
||||
# If the state was absent we can let the module delete it if needed, the module will handle exiting from this
|
||||
|
||||
Reference in New Issue
Block a user