mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
ansible_tower: fix broken import, reuse tower_argument_spec and documentation fragment (#29115)
* module_utils/ansible_tower: fix broken import * tower_*: use tower_argument_spec & doc fragment * tower doc fragment: Ansible requires Python 2.6+ * tower_job_wait: fix broken import (Py3 compat)
This commit is contained in:
parent
af3e8950d6
commit
44f5b2bd25
18 changed files with 244 additions and 746 deletions
|
@ -98,45 +98,7 @@ options:
|
|||
required: False
|
||||
default: "present"
|
||||
choices: ["present", "absent"]
|
||||
tower_host:
|
||||
description:
|
||||
- URL to your Tower instance.
|
||||
required: False
|
||||
default: null
|
||||
tower_username:
|
||||
description:
|
||||
- Username for your Tower instance.
|
||||
required: False
|
||||
default: null
|
||||
tower_password:
|
||||
description:
|
||||
- Password for your Tower instance.
|
||||
required: False
|
||||
default: null
|
||||
tower_verify_ssl:
|
||||
description:
|
||||
- Dis/allow insecure connections to Tower. If C(no), SSL certificates will not be validated.
|
||||
This should only be used on personally controlled sites using self-signed certificates.
|
||||
required: False
|
||||
default: True
|
||||
tower_config_file:
|
||||
description:
|
||||
- Path to the Tower config file. See notes.
|
||||
required: False
|
||||
default: null
|
||||
|
||||
|
||||
requirements:
|
||||
- "python >= 2.6"
|
||||
- "ansible-tower-cli >= 3.0.2"
|
||||
|
||||
notes:
|
||||
- If no I(config_file) is provided we will attempt to use the tower-cli library
|
||||
defaults to find your Tower host information.
|
||||
- I(config_file) should contain Tower configuration in the following format
|
||||
host=hostname
|
||||
username=username
|
||||
password=password
|
||||
extends_documentation_fragment: tower
|
||||
'''
|
||||
|
||||
|
||||
|
@ -150,48 +112,42 @@ EXAMPLES = '''
|
|||
tower_config_file: "~/tower_cli.cfg"
|
||||
'''
|
||||
|
||||
import os
|
||||
|
||||
from ansible.module_utils.ansible_tower import tower_argument_spec, tower_auth_config, tower_check_mode, HAS_TOWER_CLI
|
||||
|
||||
try:
|
||||
import os
|
||||
import tower_cli
|
||||
import tower_cli.utils.exceptions as exc
|
||||
|
||||
from tower_cli.conf import settings
|
||||
from ansible.module_utils.ansible_tower import tower_auth_config, tower_check_mode
|
||||
|
||||
HAS_TOWER_CLI = True
|
||||
except ImportError:
|
||||
HAS_TOWER_CLI = False
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
name=dict(required=True),
|
||||
description=dict(),
|
||||
inventory=dict(required=True),
|
||||
variables=dict(),
|
||||
credential=dict(),
|
||||
source=dict(choices=["manual", "file", "ec2", "rax", "vmware",
|
||||
"gce", "azure", "azure_rm", "openstack",
|
||||
"satellite6", "cloudforms", "custom"], default="manual"),
|
||||
source_regions=dict(),
|
||||
source_vars=dict(),
|
||||
instance_filters=dict(),
|
||||
group_by=dict(),
|
||||
source_script=dict(),
|
||||
overwrite=dict(type='bool', default=False),
|
||||
overwrite_vars=dict(),
|
||||
update_on_launch=dict(type='bool', default=False),
|
||||
tower_host=dict(),
|
||||
tower_username=dict(),
|
||||
tower_password=dict(no_log=True),
|
||||
tower_verify_ssl=dict(type='bool', default=True),
|
||||
tower_config_file=dict(type='path'),
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
),
|
||||
supports_check_mode=True
|
||||
)
|
||||
argument_spec = tower_argument_spec()
|
||||
argument_spec.update(dict(
|
||||
name=dict(required=True),
|
||||
description=dict(),
|
||||
inventory=dict(required=True),
|
||||
variables=dict(),
|
||||
credential=dict(),
|
||||
source=dict(choices=["manual", "file", "ec2", "rax", "vmware",
|
||||
"gce", "azure", "azure_rm", "openstack",
|
||||
"satellite6", "cloudforms", "custom"], default="manual"),
|
||||
source_regions=dict(),
|
||||
source_vars=dict(),
|
||||
instance_filters=dict(),
|
||||
group_by=dict(),
|
||||
source_script=dict(),
|
||||
overwrite=dict(type='bool', default=False),
|
||||
overwrite_vars=dict(),
|
||||
update_on_launch=dict(type='bool', default=False),
|
||||
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')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue