mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07:00
Tower modules: move HAS_TOWER_CLI check in module_utils and minor improvements (#39809)
* tower_* modules: move HAS_TOWER_CLI in TowerModule Besides this change allows to define other common parameters such as mutually_exclusive. * tower_*: config file can not be used with auth params * tower module_utils: remove useless call to expanduser 'path' type: expanduser & expandvars are automatically called
This commit is contained in:
parent
934500fb05
commit
12973e0541
17 changed files with 89 additions and 162 deletions
|
@ -71,7 +71,7 @@ EXAMPLES = '''
|
|||
tower_config_file: "~/tower_cli.cfg"
|
||||
'''
|
||||
|
||||
from ansible.module_utils.ansible_tower import tower_argument_spec, tower_auth_config, tower_check_mode, HAS_TOWER_CLI
|
||||
from ansible.module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
|
||||
try:
|
||||
import tower_cli
|
||||
|
@ -110,8 +110,7 @@ def update_resources(module, p):
|
|||
|
||||
def main():
|
||||
|
||||
argument_spec = tower_argument_spec()
|
||||
argument_spec.update(dict(
|
||||
argument_spec = dict(
|
||||
user=dict(),
|
||||
team=dict(),
|
||||
role=dict(choices=["admin", "read", "member", "execute", "adhoc", "update", "use", "auditor"]),
|
||||
|
@ -122,12 +121,9 @@ def main():
|
|||
organization=dict(),
|
||||
project=dict(),
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
))
|
||||
)
|
||||
|
||||
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
|
||||
|
||||
if not HAS_TOWER_CLI:
|
||||
module.fail_json(msg='ansible-tower-cli required for this module')
|
||||
module = TowerModule(argument_spec=argument_spec, supports_check_mode=True)
|
||||
|
||||
role_type = module.params.pop('role')
|
||||
state = module.params.pop('state')
|
||||
|
@ -155,6 +151,5 @@ def main():
|
|||
module.exit_json(**json_output)
|
||||
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue