mirror of
https://github.com/ansible/awx.git
synced 2024-10-30 05:25:29 +03:00
Making variables work for hosts
Clear up sanity test and remove redundant import statement
This commit is contained in:
parent
badd667efa
commit
d8513a4e86
@ -79,8 +79,6 @@ EXAMPLES = '''
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
from ..module_utils.tower_api import TowerModule
|
from ..module_utils.tower_api import TowerModule
|
||||||
|
|
||||||
|
|
||||||
@ -106,13 +104,10 @@ def main():
|
|||||||
inventory = module.params.get('inventory')
|
inventory = module.params.get('inventory')
|
||||||
enabled = module.params.get('enabled')
|
enabled = module.params.get('enabled')
|
||||||
state = module.params.get('state')
|
state = module.params.get('state')
|
||||||
|
|
||||||
variables = module.params.get('variables')
|
variables = module.params.get('variables')
|
||||||
|
|
||||||
if variables:
|
if variables:
|
||||||
if variables.startswith('@'):
|
variables = module.load_variables_if_file_specified(variables, 'variables')
|
||||||
filename = os.path.expanduser(variables[1:])
|
|
||||||
with open(filename, 'r') as f:
|
|
||||||
variables = f.read()
|
|
||||||
|
|
||||||
# Attempt to look up 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)
|
||||||
@ -130,8 +125,10 @@ def main():
|
|||||||
'name': new_name if new_name else name,
|
'name': new_name if new_name else name,
|
||||||
'description': description,
|
'description': description,
|
||||||
'inventory': inventory_id,
|
'inventory': inventory_id,
|
||||||
'enabled': enabled
|
'enabled': enabled,
|
||||||
}
|
}
|
||||||
|
if variables:
|
||||||
|
host_fields['variables'] = variables
|
||||||
|
|
||||||
if state == 'absent':
|
if state == 'absent':
|
||||||
# If the state was absent we can let the module delete it if needed, the module will handle exiting from this
|
# If the state was absent we can let the module delete it if needed, the module will handle exiting from this
|
||||||
|
@ -1 +0,0 @@
|
|||||||
plugins/modules/tower_host.py use-argspec-type-path
|
|
Loading…
Reference in New Issue
Block a user