mirror of
https://github.com/ZwareBear/awx.git
synced 2026-04-10 10:01:48 -05:00
Integrate Ansible core tower modules content into AWX
This commit includes all the changes involved in converting the old Ansible Tower modules from commits in Ansible core into the AWX collection that replaces it. Also includes work needed to integrate it into the AWX processes like tests, docs, and the Makefile. Apply changes from content_collector tool Add integrated module tests operate via run_module fixture add makefile target for them Add flake8 target and fix flake8 errors Update README Make consolidated target for testing modules
This commit is contained in:
@@ -190,7 +190,7 @@ EXAMPLES = '''
|
||||
import os
|
||||
|
||||
from ansible.module_utils._text import to_text
|
||||
from ansible.module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
from ..module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
|
||||
try:
|
||||
import tower_cli
|
||||
|
||||
@@ -87,7 +87,7 @@ EXAMPLES = '''
|
||||
RETURN = ''' # '''
|
||||
|
||||
|
||||
from ansible.module_utils.ansible_tower import (
|
||||
from ..module_utils.ansible_tower import (
|
||||
TowerModule,
|
||||
tower_auth_config,
|
||||
tower_check_mode
|
||||
|
||||
@@ -93,7 +93,7 @@ EXAMPLES = '''
|
||||
|
||||
import os
|
||||
|
||||
from ansible.module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
from ..module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
|
||||
try:
|
||||
import tower_cli
|
||||
|
||||
@@ -66,7 +66,7 @@ EXAMPLES = '''
|
||||
|
||||
import os
|
||||
|
||||
from ansible.module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode, HAS_TOWER_CLI
|
||||
from ..module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
|
||||
try:
|
||||
import tower_cli
|
||||
|
||||
@@ -67,7 +67,7 @@ EXAMPLES = '''
|
||||
'''
|
||||
|
||||
|
||||
from ansible.module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
from ..module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
|
||||
try:
|
||||
import tower_cli
|
||||
|
||||
@@ -166,7 +166,7 @@ EXAMPLES = '''
|
||||
RETURN = ''' # '''
|
||||
|
||||
|
||||
from ansible.module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
from ..module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
|
||||
try:
|
||||
import tower_cli
|
||||
|
||||
@@ -55,7 +55,7 @@ status:
|
||||
'''
|
||||
|
||||
|
||||
from ansible.module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
from ..module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
|
||||
try:
|
||||
import tower_cli
|
||||
|
||||
@@ -96,7 +96,7 @@ status:
|
||||
'''
|
||||
|
||||
|
||||
from ansible.module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
from ..module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
|
||||
try:
|
||||
import tower_cli
|
||||
|
||||
@@ -78,7 +78,7 @@ results:
|
||||
'''
|
||||
|
||||
|
||||
from ansible.module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
from ..module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
|
||||
try:
|
||||
import tower_cli
|
||||
|
||||
@@ -199,7 +199,7 @@ EXAMPLES = '''
|
||||
survey_spec: "{{ lookup('file', 'my_survey.json') }}"
|
||||
'''
|
||||
|
||||
from ansible.module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
from ..module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
|
||||
try:
|
||||
import tower_cli
|
||||
|
||||
@@ -82,7 +82,7 @@ status:
|
||||
'''
|
||||
|
||||
|
||||
from ansible.module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
from ..module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
from ansible.module_utils.six.moves import cStringIO as StringIO
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ def main():
|
||||
job_id = params.get('job_id')
|
||||
try:
|
||||
result = job.monitor(job_id, **params)
|
||||
except exc.Timeout as excinfo:
|
||||
except exc.Timeout:
|
||||
result = job.status(job_id)
|
||||
result['id'] = job_id
|
||||
json_output['msg'] = 'Timeout waiting for job to finish.'
|
||||
|
||||
@@ -49,7 +49,7 @@ EXAMPLES = '''
|
||||
tower_config_file: "~/tower_cli.cfg"
|
||||
'''
|
||||
|
||||
from ansible.module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
from ..module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
|
||||
try:
|
||||
import tower_cli
|
||||
|
||||
@@ -268,7 +268,7 @@ EXAMPLES = '''
|
||||
RETURN = ''' # '''
|
||||
|
||||
|
||||
from ansible.module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
from ..module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
|
||||
try:
|
||||
import tower_cli
|
||||
|
||||
@@ -48,7 +48,7 @@ EXAMPLES = '''
|
||||
tower_config_file: "~/tower_cli.cfg"
|
||||
'''
|
||||
|
||||
from ansible.module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
from ..module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
|
||||
try:
|
||||
import tower_cli
|
||||
|
||||
@@ -110,7 +110,7 @@ EXAMPLES = '''
|
||||
tower_config_file: "~/tower_cli.cfg"
|
||||
'''
|
||||
|
||||
from ansible.module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
from ..module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
|
||||
try:
|
||||
import tower_cli
|
||||
@@ -171,7 +171,7 @@ def main():
|
||||
try:
|
||||
org_res = tower_cli.get_resource('organization')
|
||||
org = org_res.get(name=organization)
|
||||
except (exc.NotFound) as excinfo:
|
||||
except exc.NotFound:
|
||||
module.fail_json(msg='Failed to update project, organization not found: {0}'.format(organization), changed=False)
|
||||
|
||||
if scm_credential:
|
||||
@@ -179,11 +179,11 @@ def main():
|
||||
cred_res = tower_cli.get_resource('credential')
|
||||
try:
|
||||
cred = cred_res.get(name=scm_credential)
|
||||
except (tower_cli.exceptions.MultipleResults) as multi_res_excinfo:
|
||||
except tower_cli.exceptions.MultipleResults:
|
||||
module.warn('Multiple credentials found for {0}, falling back looking in project organization'.format(scm_credential))
|
||||
cred = cred_res.get(name=scm_credential, organization=org['id'])
|
||||
scm_credential = cred['id']
|
||||
except (exc.NotFound) as excinfo:
|
||||
except exc.NotFound:
|
||||
module.fail_json(msg='Failed to update project, credential not found: {0}'.format(scm_credential), changed=False)
|
||||
|
||||
if (scm_update_cache_timeout is not None) and (scm_update_on_launch is not True):
|
||||
|
||||
@@ -109,7 +109,7 @@ assets:
|
||||
sample: [ {}, {} ]
|
||||
'''
|
||||
|
||||
from ansible.module_utils.ansible_tower import TowerModule, tower_auth_config, HAS_TOWER_CLI
|
||||
from ..module_utils.ansible_tower import TowerModule, tower_auth_config, HAS_TOWER_CLI
|
||||
|
||||
try:
|
||||
from tower_cli.cli.transfer.receive import Receiver
|
||||
|
||||
@@ -72,7 +72,7 @@ EXAMPLES = '''
|
||||
tower_config_file: "~/tower_cli.cfg"
|
||||
'''
|
||||
|
||||
from ansible.module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
from ..module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
|
||||
try:
|
||||
import tower_cli
|
||||
|
||||
@@ -76,7 +76,7 @@ import os
|
||||
import sys
|
||||
|
||||
from ansible.module_utils.six.moves import StringIO
|
||||
from ansible.module_utils.ansible_tower import TowerModule, tower_auth_config, HAS_TOWER_CLI
|
||||
from ..module_utils.ansible_tower import TowerModule, tower_auth_config, HAS_TOWER_CLI
|
||||
|
||||
from tempfile import mkstemp
|
||||
|
||||
@@ -138,7 +138,7 @@ def main():
|
||||
sys.stdout = captured_stdout = StringIO()
|
||||
try:
|
||||
sender.send(files, prevent, password_management)
|
||||
except TypeError as e:
|
||||
except TypeError:
|
||||
# Newer versions of TowerCLI require 4 parameters
|
||||
sender.send(files, prevent, [], password_management)
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ EXAMPLES = '''
|
||||
no_log: true
|
||||
'''
|
||||
|
||||
from ansible.module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
from ..module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
|
||||
try:
|
||||
import tower_cli
|
||||
|
||||
@@ -50,7 +50,7 @@ EXAMPLES = '''
|
||||
tower_config_file: "~/tower_cli.cfg"
|
||||
'''
|
||||
|
||||
from ansible.module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
from ..module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
|
||||
try:
|
||||
import tower_cli
|
||||
|
||||
@@ -100,7 +100,7 @@ EXAMPLES = '''
|
||||
tower_config_file: "~/tower_cli.cfg"
|
||||
'''
|
||||
|
||||
from ansible.module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
from ..module_utils.ansible_tower import TowerModule, tower_auth_config, tower_check_mode
|
||||
|
||||
try:
|
||||
import tower_cli
|
||||
|
||||
@@ -75,7 +75,7 @@ EXAMPLES = '''
|
||||
register: workflow_task_info
|
||||
'''
|
||||
|
||||
from ansible.module_utils.ansible_tower import TowerModule, tower_auth_config
|
||||
from ..module_utils.ansible_tower import TowerModule, tower_auth_config
|
||||
|
||||
try:
|
||||
import tower_cli
|
||||
|
||||
@@ -93,8 +93,7 @@ EXAMPLES = '''
|
||||
RETURN = ''' # '''
|
||||
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.ansible_tower import (
|
||||
from ..module_utils.ansible_tower import (
|
||||
TowerModule,
|
||||
tower_auth_config,
|
||||
tower_check_mode
|
||||
|
||||
Reference in New Issue
Block a user