mirror of
https://github.com/ansible/awx.git
synced 2026-04-01 16:25:08 -02:30
move code linting to a stricter pep8-esque auto-formatting tool, black
This commit is contained in:
@@ -6,12 +6,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
@@ -168,26 +167,25 @@ def main():
|
||||
module.fail_json(msg="Failed to launch command, see response for details", **{'response': results})
|
||||
|
||||
if not wait:
|
||||
module.exit_json(**{
|
||||
module.exit_json(
|
||||
**{
|
||||
'changed': True,
|
||||
'id': results['json']['id'],
|
||||
'status': results['json']['status'],
|
||||
}
|
||||
)
|
||||
|
||||
# Invoke wait function
|
||||
results = module.wait_on_url(url=results['json']['url'], object_name=module_name, object_type='Ad Hoc Command', timeout=timeout, interval=interval)
|
||||
|
||||
module.exit_json(
|
||||
**{
|
||||
'changed': True,
|
||||
'id': results['json']['id'],
|
||||
'status': results['json']['status'],
|
||||
})
|
||||
|
||||
# Invoke wait function
|
||||
results = module.wait_on_url(
|
||||
url=results['json']['url'],
|
||||
object_name=module_name,
|
||||
object_type='Ad Hoc Command',
|
||||
timeout=timeout, interval=interval
|
||||
}
|
||||
)
|
||||
|
||||
module.exit_json(**{
|
||||
'changed': True,
|
||||
'id': results['json']['id'],
|
||||
'status': results['json']['status'],
|
||||
})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
@@ -85,11 +84,14 @@ def main():
|
||||
timeout = module.params.get('timeout')
|
||||
|
||||
# Attempt to look up the command based on the provided name
|
||||
command = module.get_one('ad_hoc_commands', **{
|
||||
'data': {
|
||||
'id': command_id,
|
||||
command = module.get_one(
|
||||
'ad_hoc_commands',
|
||||
**{
|
||||
'data': {
|
||||
'id': command_id,
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
if command is None:
|
||||
module.fail_json(msg="Unable to find command with id {0}".format(command_id))
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
@@ -103,22 +102,20 @@ def main():
|
||||
interval = module.params.get('interval')
|
||||
|
||||
# Attempt to look up command based on the provided id
|
||||
command = module.get_one('ad_hoc_commands', **{
|
||||
'data': {
|
||||
'id': command_id,
|
||||
command = module.get_one(
|
||||
'ad_hoc_commands',
|
||||
**{
|
||||
'data': {
|
||||
'id': command_id,
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
if command is None:
|
||||
module.fail_json(msg='Unable to wait on ad hoc command {0}; that ID does not exist in Tower.'.format(command_id))
|
||||
|
||||
# Invoke wait function
|
||||
module.wait_on_url(
|
||||
url=command['url'],
|
||||
object_name=command_id,
|
||||
object_type='ad hoc command',
|
||||
timeout=timeout, interval=interval
|
||||
)
|
||||
module.wait_on_url(url=command['url'], object_name=command_id, object_type='ad hoc command', timeout=timeout, interval=interval)
|
||||
|
||||
module.exit_json(**module.json_output)
|
||||
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
@@ -105,7 +104,7 @@ def main():
|
||||
organization=dict(required=True),
|
||||
redirect_uris=dict(type="list", elements='str'),
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
skip_authorization=dict(type='bool')
|
||||
skip_authorization=dict(type='bool'),
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
@@ -124,11 +123,7 @@ def main():
|
||||
org_id = module.resolve_name_to_id('organizations', organization)
|
||||
|
||||
# Attempt to look up application based on the provided name and org ID
|
||||
application = module.get_one('applications', name_or_id=name, **{
|
||||
'data': {
|
||||
'organization': org_id
|
||||
}
|
||||
})
|
||||
application = module.get_one('applications', name_or_id=name, **{'data': {'organization': org_id}})
|
||||
|
||||
if state == 'absent':
|
||||
# If the state was absent we can let the module delete it if needed, the module will handle exiting from this
|
||||
@@ -152,10 +147,7 @@ def main():
|
||||
application_fields['redirect_uris'] = ' '.join(redirect_uris)
|
||||
|
||||
# If the state was present and we can let the module build or update the existing application, this will return on its own
|
||||
module.create_or_update_if_needed(
|
||||
application, application_fields,
|
||||
endpoint='applications', item_type='application'
|
||||
)
|
||||
module.create_or_update_if_needed(application, application_fields, endpoint='applications', item_type='application')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
@@ -318,12 +317,25 @@ KIND_CHOICES = {
|
||||
|
||||
|
||||
OLD_INPUT_NAMES = (
|
||||
'authorize', 'authorize_password', 'client',
|
||||
'security_token', 'secret', 'tenant', 'subscription',
|
||||
'domain', 'become_method', 'become_username',
|
||||
'become_password', 'vault_password', 'project', 'host',
|
||||
'username', 'password', 'ssh_key_data', 'vault_id',
|
||||
'ssh_key_unlock'
|
||||
'authorize',
|
||||
'authorize_password',
|
||||
'client',
|
||||
'security_token',
|
||||
'secret',
|
||||
'tenant',
|
||||
'subscription',
|
||||
'domain',
|
||||
'become_method',
|
||||
'become_username',
|
||||
'become_password',
|
||||
'vault_password',
|
||||
'project',
|
||||
'host',
|
||||
'username',
|
||||
'password',
|
||||
'ssh_key_data',
|
||||
'vault_id',
|
||||
'ssh_key_unlock',
|
||||
)
|
||||
|
||||
|
||||
@@ -409,8 +421,11 @@ def main():
|
||||
if copy_from:
|
||||
# a new existing item is formed when copying and is returned.
|
||||
credential = module.copy_item(
|
||||
credential, copy_from, name,
|
||||
endpoint='credentials', item_type='credential',
|
||||
credential,
|
||||
copy_from,
|
||||
name,
|
||||
endpoint='credentials',
|
||||
item_type='credential',
|
||||
copy_lookup_data=copy_lookup_data,
|
||||
)
|
||||
|
||||
@@ -459,9 +474,7 @@ def main():
|
||||
credential_fields['team'] = team_id
|
||||
|
||||
# If the state was present we can let the module build or update the existing group, this will return on its own
|
||||
module.create_or_update_if_needed(
|
||||
credential, credential_fields, endpoint='credentials', item_type='credential'
|
||||
)
|
||||
module.create_or_update_if_needed(credential, credential_fields, endpoint='credentials', item_type='credential')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
|
||||
@@ -6,12 +6,11 @@
|
||||
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'status': ['preview'],
|
||||
'supported_by': 'community',
|
||||
'metadata_version': '1.1'}
|
||||
ANSIBLE_METADATA = {'status': ['preview'], 'supported_by': 'community', 'metadata_version': '1.1'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
@@ -83,14 +82,7 @@ RETURN = ''' # '''
|
||||
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
|
||||
KIND_CHOICES = {
|
||||
'ssh': 'Machine',
|
||||
'vault': 'Ansible Vault',
|
||||
'net': 'Network',
|
||||
'scm': 'Source Control',
|
||||
'cloud': 'Lots of others',
|
||||
'insights': 'Insights'
|
||||
}
|
||||
KIND_CHOICES = {'ssh': 'Machine', 'vault': 'Ansible Vault', 'net': 'Network', 'scm': 'Source Control', 'cloud': 'Lots of others', 'insights': 'Insights'}
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
@@ -81,7 +80,7 @@ def main():
|
||||
organization=dict(),
|
||||
credential=dict(default=''),
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
pull=dict(choices=['always', 'missing', 'never'], default='missing')
|
||||
pull=dict(choices=['always', 'missing', 'never'], default='missing'),
|
||||
)
|
||||
|
||||
# Create a module for ourselves
|
||||
@@ -118,11 +117,7 @@ def main():
|
||||
if credential:
|
||||
new_fields['credential'] = module.resolve_name_to_id('credentials', credential)
|
||||
|
||||
module.create_or_update_if_needed(
|
||||
existing_item, new_fields,
|
||||
endpoint='execution_environments',
|
||||
item_type='execution_environment'
|
||||
)
|
||||
module.create_or_update_if_needed(existing_item, new_fields, endpoint='execution_environments', item_type='execution_environment')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
@@ -104,6 +103,7 @@ from ..module_utils.tower_awxkit import TowerAWXKitModule
|
||||
|
||||
try:
|
||||
from awxkit.api.pages.api import EXPORTABLE_RESOURCES
|
||||
|
||||
HAS_EXPORTABLE_RESOURCES = True
|
||||
except ImportError:
|
||||
HAS_EXPORTABLE_RESOURCES = False
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
@@ -136,11 +135,7 @@ def main():
|
||||
inventory_id = module.resolve_name_to_id('inventories', inventory)
|
||||
|
||||
# Attempt to look up the object based on the provided name and inventory ID
|
||||
group = module.get_one('groups', name_or_id=name, **{
|
||||
'data': {
|
||||
'inventory': inventory_id
|
||||
}
|
||||
})
|
||||
group = module.get_one('groups', name_or_id=name, **{'data': {'inventory': inventory_id}})
|
||||
|
||||
if state == 'absent':
|
||||
# If the state was absent we can let the module delete it if needed, the module will handle exiting from this
|
||||
@@ -163,9 +158,13 @@ def main():
|
||||
continue
|
||||
id_list = []
|
||||
for sub_name in name_list:
|
||||
sub_obj = module.get_one(resource, name_or_id=sub_name, **{
|
||||
'data': {'inventory': inventory_id},
|
||||
})
|
||||
sub_obj = module.get_one(
|
||||
resource,
|
||||
name_or_id=sub_name,
|
||||
**{
|
||||
'data': {'inventory': inventory_id},
|
||||
}
|
||||
)
|
||||
if sub_obj is None:
|
||||
module.fail_json(msg='Could not find {0} with name {1}'.format(resource, sub_name))
|
||||
id_list.append(sub_obj['id'])
|
||||
@@ -178,10 +177,7 @@ def main():
|
||||
association_fields[relationship] = id_list
|
||||
|
||||
# If the state was present we can let the module build or update the existing group, this will return on its own
|
||||
module.create_or_update_if_needed(
|
||||
group, group_fields, endpoint='groups', item_type='group',
|
||||
associations=association_fields
|
||||
)
|
||||
module.create_or_update_if_needed(group, group_fields, endpoint='groups', item_type='group', associations=association_fields)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
@@ -104,11 +103,7 @@ def main():
|
||||
inventory_id = module.resolve_name_to_id('inventories', inventory)
|
||||
|
||||
# Attempt to look up host based on the provided name and inventory ID
|
||||
host = module.get_one('hosts', name_or_id=name, **{
|
||||
'data': {
|
||||
'inventory': inventory_id
|
||||
}
|
||||
})
|
||||
host = module.get_one('hosts', name_or_id=name, **{'data': {'inventory': inventory_id}})
|
||||
|
||||
if state == 'absent':
|
||||
# If the state was absent we can let the module delete it if needed, the module will handle exiting from this
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
@@ -58,15 +57,14 @@ import logging
|
||||
# In this module we don't use EXPORTABLE_RESOURCES, we just want to validate that our installed awxkit has import/export
|
||||
try:
|
||||
from awxkit.api.pages.api import EXPORTABLE_RESOURCES
|
||||
|
||||
HAS_EXPORTABLE_RESOURCES = True
|
||||
except ImportError:
|
||||
HAS_EXPORTABLE_RESOURCES = False
|
||||
|
||||
|
||||
def main():
|
||||
argument_spec = dict(
|
||||
assets=dict(type='dict', required=True)
|
||||
)
|
||||
argument_spec = dict(assets=dict(type='dict', required=True))
|
||||
|
||||
module = TowerAWXKitModule(argument_spec=argument_spec, supports_check_mode=False)
|
||||
|
||||
|
||||
@@ -6,12 +6,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
@@ -149,11 +148,13 @@ def main():
|
||||
|
||||
# If the state was present and we can let the module build or update the existing item, this will return on its own
|
||||
module.create_or_update_if_needed(
|
||||
existing_item, new_fields,
|
||||
endpoint='instance_groups', item_type='instance_group',
|
||||
existing_item,
|
||||
new_fields,
|
||||
endpoint='instance_groups',
|
||||
item_type='instance_group',
|
||||
associations={
|
||||
'instances': instances_ids,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
@@ -127,18 +126,17 @@ def main():
|
||||
org_id = module.resolve_name_to_id('organizations', organization)
|
||||
|
||||
# Attempt to look up inventory based on the provided name and org ID
|
||||
inventory = module.get_one('inventories', name_or_id=name, **{
|
||||
'data': {
|
||||
'organization': org_id
|
||||
}
|
||||
})
|
||||
inventory = module.get_one('inventories', name_or_id=name, **{'data': {'organization': org_id}})
|
||||
|
||||
# Attempt to look up credential to copy based on the provided name
|
||||
if copy_from:
|
||||
# a new existing item is formed when copying and is returned.
|
||||
inventory = module.copy_item(
|
||||
inventory, copy_from, name,
|
||||
endpoint='inventories', item_type='inventory',
|
||||
inventory,
|
||||
copy_from,
|
||||
name,
|
||||
endpoint='inventories',
|
||||
item_type='inventory',
|
||||
copy_lookup_data={},
|
||||
)
|
||||
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
@@ -163,9 +162,7 @@ def main():
|
||||
#
|
||||
# How do we handle manual and file? Tower does not seem to be able to activate them
|
||||
#
|
||||
source=dict(choices=["scm", "ec2", "gce",
|
||||
"azure_rm", "vmware", "satellite6",
|
||||
"openstack", "rhv", "tower", "custom"]),
|
||||
source=dict(choices=["scm", "ec2", "gce", "azure_rm", "vmware", "satellite6", "openstack", "rhv", "tower", "custom"]),
|
||||
source_path=dict(),
|
||||
source_script=dict(),
|
||||
source_vars=dict(type='dict'),
|
||||
@@ -211,11 +208,15 @@ def main():
|
||||
if not inventory_object:
|
||||
module.fail_json(msg='The specified inventory, {0}, was not found.'.format(lookup_data))
|
||||
|
||||
inventory_source_object = module.get_one('inventory_sources', name_or_id=name, **{
|
||||
'data': {
|
||||
'inventory': inventory_object['id'],
|
||||
inventory_source_object = module.get_one(
|
||||
'inventory_sources',
|
||||
name_or_id=name,
|
||||
**{
|
||||
'data': {
|
||||
'inventory': inventory_object['id'],
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
if state == 'absent':
|
||||
# If the state was absent we can let the module delete it if needed, the module will handle exiting from this
|
||||
@@ -259,10 +260,20 @@ def main():
|
||||
inventory_source_fields['source_script'] = module.resolve_name_to_id('inventory_scripts', source_script)
|
||||
|
||||
OPTIONAL_VARS = (
|
||||
'description', 'source', 'source_path', 'source_vars',
|
||||
'overwrite', 'overwrite_vars',
|
||||
'timeout', 'verbosity', 'update_on_launch', 'update_cache_timeout',
|
||||
'update_on_project_update', 'enabled_var', 'enabled_value', 'host_filter',
|
||||
'description',
|
||||
'source',
|
||||
'source_path',
|
||||
'source_vars',
|
||||
'overwrite',
|
||||
'overwrite_vars',
|
||||
'timeout',
|
||||
'verbosity',
|
||||
'update_on_launch',
|
||||
'update_cache_timeout',
|
||||
'update_on_project_update',
|
||||
'enabled_var',
|
||||
'enabled_value',
|
||||
'host_filter',
|
||||
)
|
||||
|
||||
# Layer in all remaining optional information
|
||||
@@ -281,9 +292,7 @@ def main():
|
||||
|
||||
# If the state was present we can let the module build or update the existing inventory_source_object, this will return on its own
|
||||
module.create_or_update_if_needed(
|
||||
inventory_source_object, inventory_source_fields,
|
||||
endpoint='inventory_sources', item_type='inventory source',
|
||||
associations=association_fields
|
||||
inventory_source_object, inventory_source_fields, endpoint='inventory_sources', item_type='inventory source', associations=association_fields
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
@@ -117,9 +116,7 @@ def main():
|
||||
if not inventory_object:
|
||||
module.fail_json(msg='The specified inventory, {0}, was not found.'.format(lookup_data))
|
||||
|
||||
inventory_source_object = module.get_one('inventory_sources',
|
||||
name_or_id=name,
|
||||
data={'inventory': inventory_object['id']})
|
||||
inventory_source_object = module.get_one('inventory_sources', name_or_id=name, data={'inventory': inventory_object['id']})
|
||||
|
||||
if not inventory_source_object:
|
||||
module.fail_json(msg='The specified inventory source was not found.')
|
||||
@@ -139,10 +136,7 @@ def main():
|
||||
|
||||
# Invoke wait function
|
||||
module.wait_on_url(
|
||||
url=inventory_source_update_results['json']['url'],
|
||||
object_name=inventory_object,
|
||||
object_type='inventory_update',
|
||||
timeout=timeout, interval=interval
|
||||
url=inventory_source_update_results['json']['url'], object_name=inventory_object, object_type='inventory_update', timeout=timeout, interval=interval
|
||||
)
|
||||
|
||||
module.exit_json(**module.json_output)
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
@@ -68,11 +67,14 @@ def main():
|
||||
fail_if_not_running = module.params.get('fail_if_not_running')
|
||||
|
||||
# Attempt to look up the job based on the provided name
|
||||
job = module.get_one('jobs', **{
|
||||
'data': {
|
||||
'id': job_id,
|
||||
job = module.get_one(
|
||||
'jobs',
|
||||
**{
|
||||
'data': {
|
||||
'id': job_id,
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
if job is None:
|
||||
module.fail_json(msg="Unable to find job with id {0}".format(job_id))
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
@@ -248,26 +247,25 @@ def main():
|
||||
module.fail_json(msg="Failed to launch job, see response for details", **{'response': results})
|
||||
|
||||
if not wait:
|
||||
module.exit_json(**{
|
||||
module.exit_json(
|
||||
**{
|
||||
'changed': True,
|
||||
'id': results['json']['id'],
|
||||
'status': results['json']['status'],
|
||||
}
|
||||
)
|
||||
|
||||
# Invoke wait function
|
||||
results = module.wait_on_url(url=results['json']['url'], object_name=name, object_type='Job', timeout=timeout, interval=interval)
|
||||
|
||||
module.exit_json(
|
||||
**{
|
||||
'changed': True,
|
||||
'id': results['json']['id'],
|
||||
'status': results['json']['status'],
|
||||
})
|
||||
|
||||
# Invoke wait function
|
||||
results = module.wait_on_url(
|
||||
url=results['json']['url'],
|
||||
object_name=name,
|
||||
object_type='Job',
|
||||
timeout=timeout, interval=interval
|
||||
}
|
||||
)
|
||||
|
||||
module.exit_json(**{
|
||||
'changed': True,
|
||||
'id': results['json']['id'],
|
||||
'status': results['json']['status'],
|
||||
})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
@@ -97,7 +96,7 @@ def main():
|
||||
argument_spec=argument_spec,
|
||||
mutually_exclusive=[
|
||||
('page', 'all_pages'),
|
||||
]
|
||||
],
|
||||
)
|
||||
|
||||
# Extract our parameters
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
@@ -447,8 +446,11 @@ def main():
|
||||
if copy_from:
|
||||
# a new existing item is formed when copying and is returned.
|
||||
existing_item = module.copy_item(
|
||||
existing_item, copy_from, name,
|
||||
endpoint='job_templates', item_type='job_template',
|
||||
existing_item,
|
||||
copy_from,
|
||||
name,
|
||||
endpoint='job_templates',
|
||||
item_type='job_template',
|
||||
copy_lookup_data={},
|
||||
)
|
||||
|
||||
@@ -459,12 +461,36 @@ def main():
|
||||
# Create the data that gets sent for create and update
|
||||
new_fields['name'] = new_name if new_name else (module.get_item_name(existing_item) if existing_item else name)
|
||||
for field_name in (
|
||||
'description', 'job_type', 'playbook', 'scm_branch', 'forks', 'limit', 'verbosity',
|
||||
'job_tags', 'force_handlers', 'skip_tags', 'start_at_task', 'timeout', 'use_fact_cache',
|
||||
'host_config_key', 'ask_scm_branch_on_launch', 'ask_diff_mode_on_launch', 'ask_variables_on_launch',
|
||||
'ask_limit_on_launch', 'ask_tags_on_launch', 'ask_skip_tags_on_launch', 'ask_job_type_on_launch',
|
||||
'ask_verbosity_on_launch', 'ask_inventory_on_launch', 'ask_credential_on_launch', 'survey_enabled',
|
||||
'become_enabled', 'diff_mode', 'allow_simultaneous', 'job_slice_count', 'webhook_service',
|
||||
'description',
|
||||
'job_type',
|
||||
'playbook',
|
||||
'scm_branch',
|
||||
'forks',
|
||||
'limit',
|
||||
'verbosity',
|
||||
'job_tags',
|
||||
'force_handlers',
|
||||
'skip_tags',
|
||||
'start_at_task',
|
||||
'timeout',
|
||||
'use_fact_cache',
|
||||
'host_config_key',
|
||||
'ask_scm_branch_on_launch',
|
||||
'ask_diff_mode_on_launch',
|
||||
'ask_variables_on_launch',
|
||||
'ask_limit_on_launch',
|
||||
'ask_tags_on_launch',
|
||||
'ask_skip_tags_on_launch',
|
||||
'ask_job_type_on_launch',
|
||||
'ask_verbosity_on_launch',
|
||||
'ask_inventory_on_launch',
|
||||
'ask_credential_on_launch',
|
||||
'survey_enabled',
|
||||
'become_enabled',
|
||||
'diff_mode',
|
||||
'allow_simultaneous',
|
||||
'job_slice_count',
|
||||
'webhook_service',
|
||||
):
|
||||
field_val = module.params.get(field_name)
|
||||
if field_val is not None:
|
||||
@@ -484,15 +510,17 @@ def main():
|
||||
new_fields['inventory'] = module.resolve_name_to_id('inventories', inventory)
|
||||
if project is not None:
|
||||
if organization_id is not None:
|
||||
project_data = module.get_one('projects', name_or_id=project, **{
|
||||
'data': {
|
||||
'organization': organization_id,
|
||||
project_data = module.get_one(
|
||||
'projects',
|
||||
name_or_id=project,
|
||||
**{
|
||||
'data': {
|
||||
'organization': organization_id,
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
if project_data is None:
|
||||
module.fail_json(msg="The project {0} in organization {1} was not found on the Tower server".format(
|
||||
project, organization
|
||||
))
|
||||
module.fail_json(msg="The project {0} in organization {1} was not found on the Tower server".format(project, organization))
|
||||
new_fields['project'] = project_data['id']
|
||||
else:
|
||||
new_fields['project'] = module.resolve_name_to_id('projects', project)
|
||||
@@ -511,12 +539,12 @@ def main():
|
||||
association_fields['labels'] = []
|
||||
for item in labels:
|
||||
association_fields['labels'].append(module.resolve_name_to_id('labels', item))
|
||||
# Code to use once Issue #7567 is resolved
|
||||
# search_fields = {'name': item}
|
||||
# if organization:
|
||||
# search_fields['organization'] = organization_id
|
||||
# label_id = module.get_one('labels', **{'data': search_fields})
|
||||
# association_fields['labels'].append(label_id)
|
||||
# Code to use once Issue #7567 is resolved
|
||||
# search_fields = {'name': item}
|
||||
# if organization:
|
||||
# search_fields['organization'] = organization_id
|
||||
# label_id = module.get_one('labels', **{'data': search_fields})
|
||||
# association_fields['labels'].append(label_id)
|
||||
|
||||
notifications_start = module.params.get('notification_templates_started')
|
||||
if notifications_start is not None:
|
||||
@@ -551,10 +579,13 @@ def main():
|
||||
|
||||
# If the state was present and we can let the module build or update the existing item, this will return on its own
|
||||
module.create_or_update_if_needed(
|
||||
existing_item, new_fields,
|
||||
endpoint='job_templates', item_type='job_template',
|
||||
existing_item,
|
||||
new_fields,
|
||||
endpoint='job_templates',
|
||||
item_type='job_template',
|
||||
associations=association_fields,
|
||||
on_create=on_change, on_update=on_change,
|
||||
on_create=on_change,
|
||||
on_update=on_change,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
@@ -134,26 +133,24 @@ def main():
|
||||
interval = abs((min_interval + max_interval) / 2)
|
||||
module.deprecate(
|
||||
msg="Min and max interval have been deprecated, please use interval instead; interval will be set to {0}".format(interval),
|
||||
version="ansible.tower:4.0.0"
|
||||
version="ansible.tower:4.0.0",
|
||||
)
|
||||
|
||||
# Attempt to look up job based on the provided id
|
||||
job = module.get_one(job_type, **{
|
||||
'data': {
|
||||
'id': job_id,
|
||||
job = module.get_one(
|
||||
job_type,
|
||||
**{
|
||||
'data': {
|
||||
'id': job_id,
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
if job is None:
|
||||
module.fail_json(msg='Unable to wait on ' + job_type.rstrip("s") + ' {0}; that ID does not exist in Tower.'.format(job_id))
|
||||
|
||||
# Invoke wait function
|
||||
result = module.wait_on_url(
|
||||
url=job['url'],
|
||||
object_name=job_id,
|
||||
object_type='legacy_job_wait',
|
||||
timeout=timeout, interval=interval
|
||||
)
|
||||
result = module.wait_on_url(url=job['url'], object_name=job_id, object_type='legacy_job_wait', timeout=timeout, interval=interval)
|
||||
|
||||
module.exit_json(**module.json_output)
|
||||
|
||||
|
||||
@@ -6,12 +6,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
@@ -80,11 +79,15 @@ def main():
|
||||
organization_id = module.resolve_name_to_id('organizations', organization)
|
||||
|
||||
# Attempt to look up an existing item based on the provided data
|
||||
existing_item = module.get_one('labels', name_or_id=name, **{
|
||||
'data': {
|
||||
'organization': organization_id,
|
||||
existing_item = module.get_one(
|
||||
'labels',
|
||||
name_or_id=name,
|
||||
**{
|
||||
'data': {
|
||||
'organization': organization_id,
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
# Create the data that gets sent for create and update
|
||||
new_fields = {}
|
||||
@@ -92,12 +95,7 @@ def main():
|
||||
if organization:
|
||||
new_fields['organization'] = organization_id
|
||||
|
||||
module.create_or_update_if_needed(
|
||||
existing_item, new_fields,
|
||||
endpoint='labels', item_type='label',
|
||||
associations={
|
||||
}
|
||||
)
|
||||
module.create_or_update_if_needed(existing_item, new_fields, endpoint='labels', item_type='label', associations={})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -5,11 +5,10 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
@@ -62,9 +61,7 @@ def main():
|
||||
module.fail_json(msg='You must accept the EULA by passing in the param eula_accepted as True')
|
||||
|
||||
try:
|
||||
manifest = base64.b64encode(
|
||||
open(module.params.get('manifest'), 'rb').read()
|
||||
)
|
||||
manifest = base64.b64encode(open(module.params.get('manifest'), 'rb').read())
|
||||
except OSError as e:
|
||||
module.fail_json(msg=str(e))
|
||||
|
||||
@@ -72,10 +69,7 @@ def main():
|
||||
if module.check_mode:
|
||||
module.exit_json(**json_output)
|
||||
|
||||
module.post_endpoint('config', data={
|
||||
'eula_accepted': True,
|
||||
'manifest': manifest.decode()
|
||||
})
|
||||
module.post_endpoint('config', data={'eula_accepted': True, 'manifest': manifest.decode()})
|
||||
|
||||
module.exit_json(**json_output)
|
||||
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
@@ -67,17 +66,9 @@ from ..module_utils.tower_api import TowerAPIModule
|
||||
|
||||
def main():
|
||||
module = TowerAPIModule(argument_spec={})
|
||||
namespace = {
|
||||
'awx': 'awx',
|
||||
'tower': 'ansible'
|
||||
}.get(module._COLLECTION_TYPE, 'unknown')
|
||||
namespace = {'awx': 'awx', 'tower': 'ansible'}.get(module._COLLECTION_TYPE, 'unknown')
|
||||
namespace_name = '{0}.{1}'.format(namespace, module._COLLECTION_TYPE)
|
||||
module.exit_json(
|
||||
prefix=namespace_name,
|
||||
name=module._COLLECTION_TYPE,
|
||||
namespace=namespace,
|
||||
version=module._COLLECTION_VERSION
|
||||
)
|
||||
module.exit_json(prefix=namespace_name, name=module._COLLECTION_TYPE, namespace=namespace, version=module._COLLECTION_VERSION)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
@@ -317,13 +316,31 @@ RETURN = ''' # '''
|
||||
from ..module_utils.tower_api import TowerAPIModule
|
||||
|
||||
OLD_INPUT_NAMES = (
|
||||
'username', 'sender', 'recipients', 'use_tls',
|
||||
'host', 'use_ssl', 'password', 'port',
|
||||
'channels', 'token', 'account_token', 'from_number',
|
||||
'to_numbers', 'account_sid', 'subdomain', 'service_key',
|
||||
'client_name', 'message_from', 'color',
|
||||
'notify', 'url', 'headers', 'server',
|
||||
'nickname', 'targets',
|
||||
'username',
|
||||
'sender',
|
||||
'recipients',
|
||||
'use_tls',
|
||||
'host',
|
||||
'use_ssl',
|
||||
'password',
|
||||
'port',
|
||||
'channels',
|
||||
'token',
|
||||
'account_token',
|
||||
'from_number',
|
||||
'to_numbers',
|
||||
'account_sid',
|
||||
'subdomain',
|
||||
'service_key',
|
||||
'client_name',
|
||||
'message_from',
|
||||
'color',
|
||||
'notify',
|
||||
'url',
|
||||
'headers',
|
||||
'server',
|
||||
'nickname',
|
||||
'targets',
|
||||
)
|
||||
|
||||
|
||||
@@ -335,10 +352,7 @@ def main():
|
||||
copy_from=dict(),
|
||||
description=dict(),
|
||||
organization=dict(),
|
||||
notification_type=dict(choices=[
|
||||
'email', 'grafana', 'irc', 'mattermost',
|
||||
'pagerduty', 'rocketchat', 'slack', 'twilio', 'webhook'
|
||||
]),
|
||||
notification_type=dict(choices=['email', 'grafana', 'irc', 'mattermost', 'pagerduty', 'rocketchat', 'slack', 'twilio', 'webhook']),
|
||||
notification_configuration=dict(type='dict'),
|
||||
messages=dict(type='dict'),
|
||||
username=dict(),
|
||||
@@ -387,8 +401,8 @@ def main():
|
||||
for legacy_input in OLD_INPUT_NAMES:
|
||||
if module.params.get(legacy_input) is not None:
|
||||
module.deprecate(
|
||||
msg='{0} parameter has been deprecated, please use notification_configuration instead'.format(legacy_input),
|
||||
version="ansible.tower:4.0.0")
|
||||
msg='{0} parameter has been deprecated, please use notification_configuration instead'.format(legacy_input), version="ansible.tower:4.0.0"
|
||||
)
|
||||
|
||||
# Attempt to look up the related items the user specified (these will fail the module if not found)
|
||||
organization_id = None
|
||||
@@ -396,18 +410,25 @@ def main():
|
||||
organization_id = module.resolve_name_to_id('organizations', organization)
|
||||
|
||||
# Attempt to look up an existing item based on the provided data
|
||||
existing_item = module.get_one('notification_templates', name_or_id=name, **{
|
||||
'data': {
|
||||
'organization': organization_id,
|
||||
existing_item = module.get_one(
|
||||
'notification_templates',
|
||||
name_or_id=name,
|
||||
**{
|
||||
'data': {
|
||||
'organization': organization_id,
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
# Attempt to look up credential to copy based on the provided name
|
||||
if copy_from:
|
||||
# a new existing item is formed when copying and is returned.
|
||||
existing_item = module.copy_item(
|
||||
existing_item, copy_from, name,
|
||||
endpoint='notification_templates', item_type='notification_template',
|
||||
existing_item,
|
||||
copy_from,
|
||||
name,
|
||||
endpoint='notification_templates',
|
||||
item_type='notification_template',
|
||||
copy_lookup_data={},
|
||||
)
|
||||
|
||||
@@ -439,12 +460,7 @@ def main():
|
||||
new_fields['messages'] = messages
|
||||
|
||||
# If the state was present and we can let the module build or update the existing item, this will return on its own
|
||||
module.create_or_update_if_needed(
|
||||
existing_item, new_fields,
|
||||
endpoint='notification_templates', item_type='notification_template',
|
||||
associations={
|
||||
}
|
||||
)
|
||||
module.create_or_update_if_needed(existing_item, new_fields, endpoint='notification_templates', item_type='notification_template', associations={})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
@@ -178,8 +177,10 @@ def main():
|
||||
|
||||
# If the state was present and we can let the module build or update the existing organization, this will return on its own
|
||||
module.create_or_update_if_needed(
|
||||
organization, org_fields,
|
||||
endpoint='organizations', item_type='organization',
|
||||
organization,
|
||||
org_fields,
|
||||
endpoint='organizations',
|
||||
item_type='organization',
|
||||
associations=association_fields,
|
||||
)
|
||||
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
@@ -226,10 +225,7 @@ def wait_for_project_update(module, last_request):
|
||||
|
||||
# Invoke wait function
|
||||
module.wait_on_url(
|
||||
url=result['json']['url'],
|
||||
object_name=module.get_item_name(last_request),
|
||||
object_type='Project Update',
|
||||
timeout=timeout, interval=interval
|
||||
url=result['json']['url'], object_name=module.get_item_name(last_request), object_type='Project Update', timeout=timeout, interval=interval
|
||||
)
|
||||
|
||||
module.exit_json(**module.json_output)
|
||||
@@ -298,8 +294,11 @@ def main():
|
||||
if copy_from:
|
||||
# a new existing item is formed when copying and is returned.
|
||||
project = module.copy_item(
|
||||
project, copy_from, name,
|
||||
endpoint='projects', item_type='project',
|
||||
project,
|
||||
copy_from,
|
||||
name,
|
||||
endpoint='projects',
|
||||
item_type='project',
|
||||
copy_lookup_data={},
|
||||
)
|
||||
|
||||
@@ -341,9 +340,16 @@ def main():
|
||||
}
|
||||
|
||||
for field_name in (
|
||||
'scm_url', 'scm_branch', 'scm_refspec', 'scm_clean', 'scm_delete_on_update',
|
||||
'timeout', 'scm_update_cache_timeout', 'custom_virtualenv',
|
||||
'description', 'allow_override',
|
||||
'scm_url',
|
||||
'scm_branch',
|
||||
'scm_refspec',
|
||||
'scm_clean',
|
||||
'scm_delete_on_update',
|
||||
'timeout',
|
||||
'scm_update_cache_timeout',
|
||||
'custom_virtualenv',
|
||||
'description',
|
||||
'allow_override',
|
||||
):
|
||||
field_val = module.params.get(field_name)
|
||||
if field_val is not None:
|
||||
@@ -368,10 +374,7 @@ def main():
|
||||
|
||||
# If the state was present and we can let the module build or update the existing project, this will return on its own
|
||||
module.create_or_update_if_needed(
|
||||
project, project_fields,
|
||||
endpoint='projects', item_type='project',
|
||||
associations=association_fields,
|
||||
on_create=on_change, on_update=on_change
|
||||
project, project_fields, endpoint='projects', item_type='project', associations=association_fields, on_create=on_change, on_update=on_change
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -4,11 +4,10 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.0',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.0', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
@@ -127,12 +126,7 @@ def main():
|
||||
start = time.time()
|
||||
|
||||
# Invoke wait function
|
||||
module.wait_on_url(
|
||||
url=result['json']['url'],
|
||||
object_name=module.get_item_name(project),
|
||||
object_type='Project Update',
|
||||
timeout=timeout, interval=interval
|
||||
)
|
||||
module.wait_on_url(url=result['json']['url'], object_name=module.get_item_name(project), object_type='Project Update', timeout=timeout, interval=interval)
|
||||
|
||||
module.exit_json(**module.json_output)
|
||||
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['deprecated'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['deprecated'], 'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
@@ -142,6 +141,7 @@ try:
|
||||
from tower_cli.utils.exceptions import TowerCLIError
|
||||
|
||||
from tower_cli.conf import settings
|
||||
|
||||
TOWER_CLI_HAS_EXPORT = True
|
||||
except ImportError:
|
||||
TOWER_CLI_HAS_EXPORT = False
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
@@ -157,9 +156,26 @@ def main():
|
||||
argument_spec = dict(
|
||||
user=dict(),
|
||||
team=dict(),
|
||||
role=dict(choices=["admin", "read", "member", "execute", "adhoc", "update", "use", "approval",
|
||||
"auditor", "project_admin", "inventory_admin", "credential_admin",
|
||||
"workflow_admin", "notification_admin", "job_template_admin"], required=True),
|
||||
role=dict(
|
||||
choices=[
|
||||
"admin",
|
||||
"read",
|
||||
"member",
|
||||
"execute",
|
||||
"adhoc",
|
||||
"update",
|
||||
"use",
|
||||
"approval",
|
||||
"auditor",
|
||||
"project_admin",
|
||||
"inventory_admin",
|
||||
"credential_admin",
|
||||
"workflow_admin",
|
||||
"notification_admin",
|
||||
"job_template_admin",
|
||||
],
|
||||
required=True,
|
||||
),
|
||||
target_team=dict(),
|
||||
target_teams=dict(type='list', elements='str'),
|
||||
inventory=dict(),
|
||||
@@ -194,12 +210,10 @@ def main():
|
||||
'organizations': 'organization',
|
||||
'projects': 'project',
|
||||
'target_teams': 'target_team',
|
||||
'workflows': 'workflow'
|
||||
'workflows': 'workflow',
|
||||
}
|
||||
# Singular parameters
|
||||
resource_param_keys = (
|
||||
'user', 'team', 'lookup_organization'
|
||||
)
|
||||
resource_param_keys = ('user', 'team', 'lookup_organization')
|
||||
|
||||
resources = {}
|
||||
for resource_group in resource_list_param_keys:
|
||||
@@ -256,9 +270,9 @@ def main():
|
||||
resource_roles = resource['summary_fields']['object_roles']
|
||||
if role_field not in resource_roles:
|
||||
available_roles = ', '.join(list(resource_roles.keys()))
|
||||
module.fail_json(msg='Resource {0} has no role {1}, available roles: {2}'.format(
|
||||
resource['url'], role_field, available_roles
|
||||
), changed=False)
|
||||
module.fail_json(
|
||||
msg='Resource {0} has no role {1}, available roles: {2}'.format(resource['url'], role_field, available_roles), changed=False
|
||||
)
|
||||
role_data = resource_roles[role_field]
|
||||
endpoint = '/roles/{0}/{1}/'.format(role_data['id'], module.param_to_endpoint(actor_type))
|
||||
associations.setdefault(endpoint, [])
|
||||
|
||||
@@ -6,12 +6,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
@@ -227,12 +226,7 @@ def main():
|
||||
module.delete_if_needed(existing_item)
|
||||
elif state == 'present':
|
||||
# If the state was present and we can let the module build or update the existing item, this will return on its own
|
||||
module.create_or_update_if_needed(
|
||||
existing_item, new_fields,
|
||||
endpoint='schedules', item_type='schedule',
|
||||
associations={
|
||||
}
|
||||
)
|
||||
module.create_or_update_if_needed(existing_item, new_fields, endpoint='schedules', item_type='schedule', associations={})
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['deprecated'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['deprecated'], 'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
@@ -90,6 +89,7 @@ try:
|
||||
from tower_cli.utils.exceptions import TowerCLIError
|
||||
|
||||
from tower_cli.conf import settings
|
||||
|
||||
TOWER_CLI_HAS_EXPORT = True
|
||||
except ImportError:
|
||||
TOWER_CLI_HAS_EXPORT = False
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
@@ -74,6 +73,7 @@ from ..module_utils.tower_api import TowerAPIModule
|
||||
|
||||
try:
|
||||
import yaml
|
||||
|
||||
HAS_YAML = True
|
||||
except ImportError:
|
||||
HAS_YAML = False
|
||||
@@ -84,11 +84,7 @@ def coerce_type(module, value):
|
||||
if value is None:
|
||||
return value
|
||||
|
||||
yaml_ish = bool((
|
||||
value.startswith('{') and value.endswith('}')
|
||||
) or (
|
||||
value.startswith('[') and value.endswith(']'))
|
||||
)
|
||||
yaml_ish = bool((value.startswith('{') and value.endswith('}')) or (value.startswith('[') and value.endswith(']')))
|
||||
if yaml_ish:
|
||||
if not HAS_YAML:
|
||||
module.fail_json(msg="yaml is not installed, try 'pip install pyyaml'")
|
||||
@@ -115,7 +111,7 @@ def main():
|
||||
argument_spec=argument_spec,
|
||||
required_one_of=[['name', 'settings']],
|
||||
mutually_exclusive=[['name', 'settings']],
|
||||
required_if=[['name', 'present', ['value']]]
|
||||
required_if=[['name', 'present', ['value']]],
|
||||
)
|
||||
|
||||
# Extract our parameters
|
||||
@@ -145,10 +141,7 @@ def main():
|
||||
json_output['new_values'][a_setting] = new_settings[a_setting]
|
||||
|
||||
if module._diff:
|
||||
json_output['diff'] = {
|
||||
'before': json_output['old_values'],
|
||||
'after': json_output['new_values']
|
||||
}
|
||||
json_output['diff'] = {'before': json_output['old_values'], 'after': json_output['new_values']}
|
||||
|
||||
# If nothing needs an update we can simply exit with the response (as not changed)
|
||||
if not needs_update:
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
@@ -87,21 +86,14 @@ def main():
|
||||
org_id = module.resolve_name_to_id('organizations', organization)
|
||||
|
||||
# Attempt to look up team based on the provided name and org ID
|
||||
team = module.get_one('teams', name_or_id=name, **{
|
||||
'data': {
|
||||
'organization': org_id
|
||||
}
|
||||
})
|
||||
team = module.get_one('teams', name_or_id=name, **{'data': {'organization': org_id}})
|
||||
|
||||
if state == 'absent':
|
||||
# If the state was absent we can let the module delete it if needed, the module will handle exiting from this
|
||||
module.delete_if_needed(team)
|
||||
|
||||
# Create the data that gets sent for create and update
|
||||
team_fields = {
|
||||
'name': new_name if new_name else (module.get_item_name(team) if team else name),
|
||||
'organization': org_id
|
||||
}
|
||||
team_fields = {'name': new_name if new_name else (module.get_item_name(team) if team else name), 'organization': org_id}
|
||||
if description is not None:
|
||||
team_fields['description'] = description
|
||||
|
||||
|
||||
@@ -6,12 +6,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
@@ -150,7 +149,12 @@ def main():
|
||||
],
|
||||
# If we are state absent make sure one of existing_token or existing_token_id are present
|
||||
required_if=[
|
||||
['state', 'absent', ('existing_token', 'existing_token_id'), True, ],
|
||||
[
|
||||
'state',
|
||||
'absent',
|
||||
('existing_token', 'existing_token_id'),
|
||||
True,
|
||||
],
|
||||
],
|
||||
)
|
||||
|
||||
@@ -164,11 +168,14 @@ def main():
|
||||
|
||||
if state == 'absent':
|
||||
if not existing_token:
|
||||
existing_token = module.get_one('tokens', **{
|
||||
'data': {
|
||||
'id': existing_token_id,
|
||||
existing_token = module.get_one(
|
||||
'tokens',
|
||||
**{
|
||||
'data': {
|
||||
'id': existing_token_id,
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
# If the state was absent we can let the module delete it if needed, the module will handle exiting from this
|
||||
module.delete_if_needed(existing_token)
|
||||
@@ -189,10 +196,11 @@ def main():
|
||||
|
||||
# If the state was present and we can let the module build or update the existing item, this will return on its own
|
||||
module.create_or_update_if_needed(
|
||||
None, new_fields,
|
||||
endpoint='tokens', item_type='token',
|
||||
associations={
|
||||
},
|
||||
None,
|
||||
new_fields,
|
||||
endpoint='tokens',
|
||||
item_type='token',
|
||||
associations={},
|
||||
on_create=return_token,
|
||||
)
|
||||
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
|
||||
@@ -6,12 +6,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
@@ -240,8 +239,11 @@ def main():
|
||||
if copy_from:
|
||||
# a new existing item is formed when copying and is returned.
|
||||
existing_item = module.copy_item(
|
||||
existing_item, copy_from, name,
|
||||
endpoint='workflow_job_templates', item_type='workflow_job_template',
|
||||
existing_item,
|
||||
copy_from,
|
||||
name,
|
||||
endpoint='workflow_job_templates',
|
||||
item_type='workflow_job_template',
|
||||
copy_lookup_data={},
|
||||
)
|
||||
|
||||
@@ -260,10 +262,18 @@ def main():
|
||||
# Create the data that gets sent for create and update
|
||||
new_fields['name'] = new_name if new_name else (module.get_item_name(existing_item) if existing_item else name)
|
||||
for field_name in (
|
||||
'description', 'survey_enabled', 'allow_simultaneous',
|
||||
'limit', 'scm_branch', 'extra_vars',
|
||||
'ask_inventory_on_launch', 'ask_scm_branch_on_launch', 'ask_limit_on_launch', 'ask_variables_on_launch',
|
||||
'webhook_service',):
|
||||
'description',
|
||||
'survey_enabled',
|
||||
'allow_simultaneous',
|
||||
'limit',
|
||||
'scm_branch',
|
||||
'extra_vars',
|
||||
'ask_inventory_on_launch',
|
||||
'ask_scm_branch_on_launch',
|
||||
'ask_limit_on_launch',
|
||||
'ask_variables_on_launch',
|
||||
'webhook_service',
|
||||
):
|
||||
field_val = module.params.get(field_name)
|
||||
if field_val:
|
||||
new_fields[field_name] = field_val
|
||||
@@ -302,12 +312,12 @@ def main():
|
||||
association_fields['labels'] = []
|
||||
for item in labels:
|
||||
association_fields['labels'].append(module.resolve_name_to_id('labels', item))
|
||||
# Code to use once Issue #7567 is resolved
|
||||
# search_fields = {'name': item}
|
||||
# if organization:
|
||||
# search_fields['organization'] = organization_id
|
||||
# label_id = module.get_one('labels', **{'data': search_fields})
|
||||
# association_fields['labels'].append(label_id)
|
||||
# Code to use once Issue #7567 is resolved
|
||||
# search_fields = {'name': item}
|
||||
# if organization:
|
||||
# search_fields['organization'] = organization_id
|
||||
# label_id = module.get_one('labels', **{'data': search_fields})
|
||||
# association_fields['labels'].append(label_id)
|
||||
|
||||
on_change = None
|
||||
new_spec = module.params.get('survey_spec')
|
||||
@@ -324,10 +334,13 @@ def main():
|
||||
|
||||
# If the state was present and we can let the module build or update the existing item, this will return on its own
|
||||
module.create_or_update_if_needed(
|
||||
existing_item, new_fields,
|
||||
endpoint='workflow_job_templates', item_type='workflow_job_template',
|
||||
existing_item,
|
||||
new_fields,
|
||||
endpoint='workflow_job_templates',
|
||||
item_type='workflow_job_template',
|
||||
associations=association_fields,
|
||||
on_create=on_change, on_update=on_change
|
||||
on_create=on_change,
|
||||
on_update=on_change,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -6,12 +6,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
@@ -234,13 +233,9 @@ def main():
|
||||
if organization:
|
||||
organization_id = module.resolve_name_to_id('organizations', organization)
|
||||
wfjt_search_fields['organization'] = organization_id
|
||||
wfjt_data = module.get_one('workflow_job_templates', name_or_id=workflow_job_template, **{
|
||||
'data': wfjt_search_fields
|
||||
})
|
||||
wfjt_data = module.get_one('workflow_job_templates', name_or_id=workflow_job_template, **{'data': wfjt_search_fields})
|
||||
if wfjt_data is None:
|
||||
module.fail_json(msg="The workflow {0} in organization {1} was not found on the Tower server".format(
|
||||
workflow_job_template, organization
|
||||
))
|
||||
module.fail_json(msg="The workflow {0} in organization {1} was not found on the Tower server".format(workflow_job_template, organization))
|
||||
workflow_job_template_id = wfjt_data['id']
|
||||
search_fields['workflow_job_template'] = new_fields['workflow_job_template'] = workflow_job_template_id
|
||||
|
||||
@@ -261,8 +256,17 @@ def main():
|
||||
|
||||
# Create the data that gets sent for create and update
|
||||
for field_name in (
|
||||
'identifier', 'extra_data', 'scm_branch', 'job_type', 'job_tags', 'skip_tags',
|
||||
'limit', 'diff_mode', 'verbosity', 'all_parents_must_converge',):
|
||||
'identifier',
|
||||
'extra_data',
|
||||
'scm_branch',
|
||||
'job_type',
|
||||
'job_tags',
|
||||
'skip_tags',
|
||||
'limit',
|
||||
'diff_mode',
|
||||
'verbosity',
|
||||
'all_parents_must_converge',
|
||||
):
|
||||
field_val = module.params.get(field_name)
|
||||
if field_val:
|
||||
new_fields[field_name] = field_val
|
||||
@@ -294,9 +298,12 @@ def main():
|
||||
|
||||
# If the state was present and we can let the module build or update the existing item, this will return on its own
|
||||
module.create_or_update_if_needed(
|
||||
existing_item, new_fields,
|
||||
endpoint='workflow_job_template_nodes', item_type='workflow_job_template_node', auto_exit=not approval_node,
|
||||
associations=association_fields
|
||||
existing_item,
|
||||
new_fields,
|
||||
endpoint='workflow_job_template_nodes',
|
||||
item_type='workflow_job_template_node',
|
||||
auto_exit=not approval_node,
|
||||
associations=association_fields,
|
||||
)
|
||||
|
||||
# Create approval node unified template or update existing
|
||||
@@ -326,9 +333,7 @@ def main():
|
||||
existing_item = module.get_endpoint(workflow_job_template_node['related']['unified_job_template'])['json']
|
||||
approval_endpoint = 'workflow_job_template_nodes/{0}/create_approval_template/'.format(workflow_job_template_node_id)
|
||||
module.create_or_update_if_needed(
|
||||
existing_item, new_fields,
|
||||
endpoint=approval_endpoint, item_type='workflow_job_template_approval_node',
|
||||
associations=association_fields
|
||||
existing_item, new_fields, endpoint=approval_endpoint, item_type='workflow_job_template_approval_node', associations=association_fields
|
||||
)
|
||||
module.exit_json(**module.json_output)
|
||||
|
||||
|
||||
@@ -4,11 +4,10 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'}
|
||||
ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
@@ -180,12 +179,7 @@ def main():
|
||||
module.exit_json(**module.json_output)
|
||||
|
||||
# Invoke wait function
|
||||
module.wait_on_url(
|
||||
url=result['json']['url'],
|
||||
object_name=name,
|
||||
object_type='Workflow Job',
|
||||
timeout=timeout, interval=interval
|
||||
)
|
||||
module.wait_on_url(url=result['json']['url'], object_name=name, object_type='Workflow Job', timeout=timeout, interval=interval)
|
||||
|
||||
module.exit_json(**module.json_output)
|
||||
|
||||
|
||||
@@ -5,12 +5,11 @@
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
ANSIBLE_METADATA = {'status': ['deprecated'],
|
||||
'supported_by': 'community',
|
||||
'metadata_version': '1.1'}
|
||||
ANSIBLE_METADATA = {'status': ['deprecated'], 'supported_by': 'community', 'metadata_version': '1.1'}
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
@@ -108,11 +107,7 @@ EXAMPLES = '''
|
||||
RETURN = ''' # '''
|
||||
|
||||
|
||||
from ..module_utils.tower_legacy import (
|
||||
TowerLegacyModule,
|
||||
tower_auth_config,
|
||||
tower_check_mode
|
||||
)
|
||||
from ..module_utils.tower_legacy import TowerLegacyModule, tower_auth_config, tower_check_mode
|
||||
|
||||
import json
|
||||
|
||||
@@ -140,16 +135,16 @@ def main():
|
||||
state=dict(choices=['present', 'absent'], default='present'),
|
||||
)
|
||||
|
||||
module = TowerLegacyModule(
|
||||
argument_spec=argument_spec,
|
||||
supports_check_mode=False
|
||||
)
|
||||
module = TowerLegacyModule(argument_spec=argument_spec, supports_check_mode=False)
|
||||
|
||||
module.deprecate(msg=(
|
||||
"This module is replaced by the combination of tower_workflow_job_template and "
|
||||
"tower_workflow_job_template_node. This uses the old tower-cli and wll be "
|
||||
"removed in 2022."
|
||||
), version='awx.awx:14.0.0')
|
||||
module.deprecate(
|
||||
msg=(
|
||||
"This module is replaced by the combination of tower_workflow_job_template and "
|
||||
"tower_workflow_job_template_node. This uses the old tower-cli and wll be "
|
||||
"removed in 2022."
|
||||
),
|
||||
version='awx.awx:14.0.0',
|
||||
)
|
||||
|
||||
name = module.params.get('name')
|
||||
state = module.params.get('state')
|
||||
@@ -159,10 +154,7 @@ def main():
|
||||
schema = module.params.get('schema')
|
||||
|
||||
if schema and state == 'absent':
|
||||
module.fail_json(
|
||||
msg='Setting schema when state is absent is not allowed',
|
||||
changed=False
|
||||
)
|
||||
module.fail_json(msg='Setting schema when state is absent is not allowed', changed=False)
|
||||
|
||||
json_output = {'workflow_template': name, 'state': state}
|
||||
|
||||
@@ -179,15 +171,10 @@ def main():
|
||||
if module.params.get('organization'):
|
||||
organization_res = tower_cli.get_resource('organization')
|
||||
try:
|
||||
organization = organization_res.get(
|
||||
name=module.params.get('organization'))
|
||||
organization = organization_res.get(name=module.params.get('organization'))
|
||||
params['organization'] = organization['id']
|
||||
except exc.NotFound as excinfo:
|
||||
module.fail_json(
|
||||
msg='Failed to update organization source,'
|
||||
'organization not found: {0}'.format(excinfo),
|
||||
changed=False
|
||||
)
|
||||
module.fail_json(msg='Failed to update organization source,' 'organization not found: {0}'.format(excinfo), changed=False)
|
||||
|
||||
if module.params.get('survey'):
|
||||
params['survey_spec'] = module.params.get('survey')
|
||||
@@ -198,8 +185,7 @@ def main():
|
||||
if module.params.get('ask_inventory'):
|
||||
params['ask_inventory_on_launch'] = module.params.get('ask_inventory')
|
||||
|
||||
for key in ('allow_simultaneous', 'inventory',
|
||||
'survey_enabled', 'description'):
|
||||
for key in ('allow_simultaneous', 'inventory', 'survey_enabled', 'description'):
|
||||
if module.params.get(key):
|
||||
params[key] = module.params.get(key)
|
||||
|
||||
@@ -219,8 +205,13 @@ def main():
|
||||
params['fail_on_missing'] = False
|
||||
result = wfjt_res.delete(**params)
|
||||
except (exc.ConnectionError, exc.BadRequest, exc.AuthError) as excinfo:
|
||||
module.fail_json(msg='Failed to update workflow template: \
|
||||
{0}'.format(excinfo), changed=False)
|
||||
module.fail_json(
|
||||
msg='Failed to update workflow template: \
|
||||
{0}'.format(
|
||||
excinfo
|
||||
),
|
||||
changed=False,
|
||||
)
|
||||
|
||||
json_output['changed'] = result['changed']
|
||||
module.exit_json(**json_output)
|
||||
|
||||
Reference in New Issue
Block a user