tower_username to controller_username, etc

This commit is contained in:
Seth Foster
2021-05-13 13:54:37 -04:00
parent 1a2e56c785
commit 7d06fc74dd
25 changed files with 116 additions and 111 deletions

View File

@@ -13,44 +13,49 @@ class ModuleDocFragment(object):
# Automation Platform Controller documentation fragment # Automation Platform Controller documentation fragment
DOCUMENTATION = r''' DOCUMENTATION = r'''
options: options:
tower_host: controller_host:
description: description:
- URL to your Automation Platform Controller instance. - URL to your Automation Platform Controller instance.
- If value not set, will try environment variable C(TOWER_HOST) and then config files - If value not set, will try environment variable C(CONTROLLER_HOST) and then config files
- If value not specified by any means, the value of C(127.0.0.1) will be used - If value not specified by any means, the value of C(127.0.0.1) will be used
type: str type: str
tower_username: aliases: [ tower_host ]
controller_username:
description: description:
- Username for your controller instance. - Username for your controller instance.
- If value not set, will try environment variable C(TOWER_USERNAME) and then config files - If value not set, will try environment variable C(CONTROLLER_USERNAME) and then config files
type: str type: str
tower_password: aliases: [ tower_username ]
controller_password:
description: description:
- Password for your controller instance. - Password for your controller instance.
- If value not set, will try environment variable C(TOWER_PASSWORD) and then config files - If value not set, will try environment variable C(CONTROLLER_PASSWORD) and then config files
type: str type: str
tower_oauthtoken: aliases: [ tower_password ]
controller_oauthtoken:
description: description:
- The OAuth token to use. - The OAuth token to use.
- This value can be in one of two formats. - This value can be in one of two formats.
- A string which is the token itself. (i.e. bqV5txm97wqJqtkxlMkhQz0pKhRMMX) - A string which is the token itself. (i.e. bqV5txm97wqJqtkxlMkhQz0pKhRMMX)
- A dictionary structure as returned by the token module. - A dictionary structure as returned by the token module.
- If value not set, will try environment variable C(TOWER_OAUTH_TOKEN) and then config files - If value not set, will try environment variable C(CONTROLLER_OAUTH_TOKEN) and then config files
type: raw type: raw
version_added: "3.7" version_added: "3.7"
aliases: [ tower_oauthtoken ]
validate_certs: validate_certs:
description: description:
- Whether to allow insecure connections to AWX. - Whether to allow insecure connections to AWX.
- If C(no), SSL certificates will not be validated. - If C(no), SSL certificates will not be validated.
- This should only be used on personally controlled sites using self-signed certificates. - This should only be used on personally controlled sites using self-signed certificates.
- If value not set, will try environment variable C(TOWER_VERIFY_SSL) and then config files - If value not set, will try environment variable C(CONTROLLER_VERIFY_SSL) and then config files
type: bool type: bool
aliases: [ tower_verify_ssl ] aliases: [ tower_verify_ssl ]
tower_config_file: controller_config_file:
description: description:
- Path to the controller config file. - Path to the controller config file.
- If provided, the other locations for config files will not be considered. - If provided, the other locations for config files will not be considered.
type: path type: path
aliases: [tower_config_file]
notes: notes:
- If no I(config_file) is provided we will attempt to use the tower-cli library - If no I(config_file) is provided we will attempt to use the tower-cli library

View File

@@ -16,27 +16,27 @@ options:
host: host:
description: The network address of your Automation Platform Controller host. description: The network address of your Automation Platform Controller host.
env: env:
- name: TOWER_HOST - name: CONTROLLER_HOST
username: username:
description: The user that you plan to use to access inventories on the controller. description: The user that you plan to use to access inventories on the controller.
env: env:
- name: TOWER_USERNAME - name: CONTROLLER_USERNAME
password: password:
description: The password for your controller user. description: The password for your controller user.
env: env:
- name: TOWER_PASSWORD - name: CONTROLLER_PASSWORD
oauth_token: oauth_token:
description: description:
- The OAuth token to use. - The OAuth token to use.
env: env:
- name: TOWER_OAUTH_TOKEN - name: CONTROLLER_OAUTH_TOKEN
verify_ssl: verify_ssl:
description: description:
- Specify whether Ansible should verify the SSL certificate of the controller host. - Specify whether Ansible should verify the SSL certificate of the controller host.
- Defaults to True, but this is handled by the shared module_utils code - Defaults to True, but this is handled by the shared module_utils code
type: bool type: bool
env: env:
- name: TOWER_VERIFY_SSL - name: CONTROLLER_VERIFY_SSL
aliases: [ validate_certs ] aliases: [ validate_certs ]
notes: notes:

View File

@@ -32,19 +32,19 @@ class ItemNotDefined(Exception):
class ControllerModule(AnsibleModule): class ControllerModule(AnsibleModule):
url = None url = None
AUTH_ARGSPEC = dict( AUTH_ARGSPEC = dict(
tower_host=dict(required=False, fallback=(env_fallback, ['CONTROLLER_HOST', 'TOWER_HOST'])), controller_host=dict(required=False, fallback=(env_fallback, ['CONTROLLER_HOST', 'TOWER_HOST'])),
tower_username=dict(required=False, fallback=(env_fallback, ['CONTROLLER_USERNAME', 'TOWER_USERNAME'])), controller_username=dict(required=False, fallback=(env_fallback, ['CONTROLLER_USERNAME', 'TOWER_USERNAME'])),
tower_password=dict(no_log=True, required=False, fallback=(env_fallback, ['CONTROLLER_PASSWORD', 'TOWER_PASSWORD'])), controller_password=dict(no_log=True, required=False, fallback=(env_fallback, ['CONTROLLER_PASSWORD', 'TOWER_PASSWORD'])),
validate_certs=dict(type='bool', aliases=['tower_verify_ssl'], required=False, fallback=(env_fallback, ['CONTROLLER_VERIFY_SSL', 'TOWER_VERIFY_SSL'])), validate_certs=dict(type='bool', aliases=['tower_verify_ssl'], required=False, fallback=(env_fallback, ['CONTROLLER_VERIFY_SSL', 'TOWER_VERIFY_SSL'])),
tower_oauthtoken=dict(type='raw', no_log=True, required=False, fallback=(env_fallback, ['CONTROLLER_OAUTH_TOKEN', 'TOWER_OAUTH_TOKEN'])), controller_oauthtoken=dict(type='raw', no_log=True, required=False, fallback=(env_fallback, ['CONTROLLER_OAUTH_TOKEN', 'TOWER_OAUTH_TOKEN'])),
tower_config_file=dict(type='path', required=False, default=None), controller_config_file=dict(type='path', required=False, default=None),
) )
short_params = { short_params = {
'host': 'tower_host', 'host': 'controller_host',
'username': 'tower_username', 'username': 'controller_username',
'password': 'tower_password', 'password': 'controller_password',
'verify_ssl': 'validate_certs', 'verify_ssl': 'validate_certs',
'oauth_token': 'tower_oauthtoken', 'oauth_token': 'controller_oauthtoken',
} }
host = '127.0.0.1' host = '127.0.0.1'
username = None username = None
@@ -82,18 +82,18 @@ class ControllerModule(AnsibleModule):
if direct_value is not None: if direct_value is not None:
setattr(self, short_param, direct_value) setattr(self, short_param, direct_value)
# Perform magic depending on whether tower_oauthtoken is a string or a dict # Perform magic depending on whether controller_oauthtoken is a string or a dict
if self.params.get('tower_oauthtoken'): if self.params.get('controller_oauthtoken'):
token_param = self.params.get('tower_oauthtoken') token_param = self.params.get('controller_oauthtoken')
if type(token_param) is dict: if type(token_param) is dict:
if 'token' in token_param: if 'token' in token_param:
self.oauth_token = self.params.get('tower_oauthtoken')['token'] self.oauth_token = self.params.get('controller_oauthtoken')['token']
else: else:
self.fail_json(msg="The provided dict in tower_oauthtoken did not properly contain the token entry") self.fail_json(msg="The provided dict in controller_oauthtoken did not properly contain the token entry")
elif isinstance(token_param, string_types): elif isinstance(token_param, string_types):
self.oauth_token = self.params.get('tower_oauthtoken') self.oauth_token = self.params.get('controller_oauthtoken')
else: else:
error_msg = "The provided tower_oauthtoken type was not valid ({0}). Valid options are str or dict.".format(type(token_param).__name__) error_msg = "The provided controller_oauthtoken type was not valid ({0}). Valid options are str or dict.".format(type(token_param).__name__)
self.fail_json(msg=error_msg) self.fail_json(msg=error_msg)
# Perform some basic validation # Perform some basic validation
@@ -104,14 +104,14 @@ class ControllerModule(AnsibleModule):
try: try:
self.url = urlparse(self.host) self.url = urlparse(self.host)
except Exception as e: except Exception as e:
self.fail_json(msg="Unable to parse tower_host as a URL ({1}): {0}".format(self.host, e)) self.fail_json(msg="Unable to parse controller_host as a URL ({1}): {0}".format(self.host, e))
# Try to resolve the hostname # Try to resolve the hostname
hostname = self.url.netloc.split(':')[0] hostname = self.url.netloc.split(':')[0]
try: try:
gethostbyname(hostname) gethostbyname(hostname)
except Exception as e: except Exception as e:
self.fail_json(msg="Unable to resolve tower_host ({1}): {0}".format(hostname, e)) self.fail_json(msg="Unable to resolve controller_host ({1}): {0}".format(hostname, e))
def build_url(self, endpoint, query_params=None): def build_url(self, endpoint, query_params=None):
# Make sure we start with /api/vX # Make sure we start with /api/vX
@@ -140,18 +140,18 @@ class ControllerModule(AnsibleModule):
config_files.insert(2, join(local_dir, ".{0}".format(self.config_name))) config_files.insert(2, join(local_dir, ".{0}".format(self.config_name)))
# If we have a specified tower config, load it # If we have a specified tower config, load it
if self.params.get('tower_config_file'): if self.params.get('controller_config_file'):
duplicated_params = [fn for fn in self.AUTH_ARGSPEC if fn != 'tower_config_file' and self.params.get(fn) is not None] duplicated_params = [fn for fn in self.AUTH_ARGSPEC if fn != 'controller_config_file' and self.params.get(fn) is not None]
if duplicated_params: if duplicated_params:
self.warn( self.warn(
( (
'The parameter(s) {0} were provided at the same time as tower_config_file. ' 'The parameter(s) {0} were provided at the same time as controller_config_file. '
'Precedence may be unstable, we suggest either using config file or params.' 'Precedence may be unstable, we suggest either using config file or params.'
).format(', '.join(duplicated_params)) ).format(', '.join(duplicated_params))
) )
try: try:
# TODO: warn if there are conflicts with other params # TODO: warn if there are conflicts with other params
self.load_config(self.params.get('tower_config_file')) self.load_config(self.params.get('controller_config_file'))
except ConfigFileException as cfe: except ConfigFileException as cfe:
# Since we were told specifically to load this we want it to fail if we have an error # Since we were told specifically to load this we want it to fail if we have an error
self.fail_json(msg=cfe) self.fail_json(msg=cfe)

View File

@@ -210,7 +210,7 @@ EXAMPLES = '''
organization: test-org organization: test-org
credential_type: Machine credential_type: Machine
state: present state: present
tower_config_file: "~/tower_cli.cfg" controller_config_file: "~/tower_cli.cfg"
- name: Create a valid SCM credential from a private_key file - name: Create a valid SCM credential from a private_key file
credential: credential:
@@ -244,9 +244,9 @@ EXAMPLES = '''
name: Workshop Credential name: Workshop Credential
credential_type: MyCloudCredential credential_type: MyCloudCredential
organization: Default organization: Default
tower_username: admin controller_username: admin
tower_password: ansible controller_password: ansible
tower_host: https://localhost controller_host: https://localhost
- name: Create a Vaiult credential (example for notes) - name: Create a Vaiult credential (example for notes)
credential: credential:

View File

@@ -84,7 +84,7 @@ EXAMPLES = '''
description: "Local Host Group" description: "Local Host Group"
inventory: "Local Inventory" inventory: "Local Inventory"
state: present state: present
tower_config_file: "~/tower_cli.cfg" controller_config_file: "~/tower_cli.cfg"
- name: Add group - name: Add group
group: group:

View File

@@ -65,7 +65,7 @@ EXAMPLES = '''
description: "Local Host Group" description: "Local Host Group"
inventory: "Local Inventory" inventory: "Local Inventory"
state: present state: present
tower_config_file: "~/tower_cli.cfg" controller_config_file: "~/tower_cli.cfg"
variables: variables:
example_var: 123 example_var: 123
''' '''

View File

@@ -83,7 +83,7 @@ EXAMPLES = '''
description: "Our Foo Cloud Servers" description: "Our Foo Cloud Servers"
organization: "Bar Org" organization: "Bar Org"
state: present state: present
tower_config_file: "~/tower_cli.cfg" controller_config_file: "~/tower_cli.cfg"
- name: Copy inventory - name: Copy inventory
inventory: inventory:

View File

@@ -48,7 +48,7 @@ EXAMPLES = '''
job_list: job_list:
status: running status: running
query: {"playbook": "testing.yml"} query: {"playbook": "testing.yml"}
tower_config_file: "~/tower_cli.cfg" controller_config_file: "~/tower_cli.cfg"
register: testing_jobs register: testing_jobs
''' '''

View File

@@ -315,7 +315,7 @@ EXAMPLES = '''
credentials: credentials:
- "Local" - "Local"
state: "present" state: "present"
tower_config_file: "~/tower_cli.cfg" controller_config_file: "~/tower_cli.cfg"
survey_enabled: yes survey_enabled: yes
survey_spec: "{{ lookup('file', 'my_survey.json') }}" survey_spec: "{{ lookup('file', 'my_survey.json') }}"

View File

@@ -226,7 +226,7 @@ EXAMPLES = '''
error: error:
message: "{{ '{{ job_friendly_name }} FAILED! Please look at {{ job.url }}' }}" message: "{{ '{{ job_friendly_name }} FAILED! Please look at {{ job.url }}' }}"
state: present state: present
tower_config_file: "~/tower_cli.cfg" controller_config_file: "~/tower_cli.cfg"
- name: Add webhook notification - name: Add webhook notification
notification_template: notification_template:
@@ -237,7 +237,7 @@ EXAMPLES = '''
headers: headers:
X-Custom-Header: value123 X-Custom-Header: value123
state: present state: present
tower_config_file: "~/tower_cli.cfg" controller_config_file: "~/tower_cli.cfg"
- name: Add email notification - name: Add email notification
notification_template: notification_template:
@@ -254,7 +254,7 @@ EXAMPLES = '''
use_tls: no use_tls: no
use_ssl: no use_ssl: no
state: present state: present
tower_config_file: "~/tower_cli.cfg" controller_config_file: "~/tower_cli.cfg"
- name: Add twilio notification - name: Add twilio notification
notification_template: notification_template:
@@ -267,7 +267,7 @@ EXAMPLES = '''
to_numbers: to_numbers:
- '+15553334444' - '+15553334444'
state: present state: present
tower_config_file: "~/tower_cli.cfg" controller_config_file: "~/tower_cli.cfg"
- name: Add PagerDuty notification - name: Add PagerDuty notification
notification_template: notification_template:
@@ -279,7 +279,7 @@ EXAMPLES = '''
client_name: client client_name: client
service_key: a_key service_key: a_key
state: present state: present
tower_config_file: "~/tower_cli.cfg" controller_config_file: "~/tower_cli.cfg"
- name: Add IRC notification - name: Add IRC notification
notification_template: notification_template:
@@ -294,13 +294,13 @@ EXAMPLES = '''
server: irc.example.com server: irc.example.com
use_ssl: no use_ssl: no
state: present state: present
tower_config_file: "~/tower_cli.cfg" controller_config_file: "~/tower_cli.cfg"
- name: Delete notification - name: Delete notification
notification_template: notification_template:
name: old notification name: old notification
state: absent state: absent
tower_config_file: "~/tower_cli.cfg" controller_config_file: "~/tower_cli.cfg"
- name: Copy webhook notification - name: Copy webhook notification
notification_template: notification_template:

View File

@@ -91,14 +91,14 @@ EXAMPLES = '''
name: "Foo" name: "Foo"
description: "Foo bar organization" description: "Foo bar organization"
state: present state: present
tower_config_file: "~/tower_cli.cfg" controller_config_file: "~/tower_cli.cfg"
- name: Create organization using 'foo-venv' as default Python virtualenv - name: Create organization using 'foo-venv' as default Python virtualenv
organization: organization:
name: "Foo" name: "Foo"
description: "Foo bar organization using foo-venv" description: "Foo bar organization using foo-venv"
state: present state: present
tower_config_file: "~/tower_cli.cfg" controller_config_file: "~/tower_cli.cfg"
- name: Create organization that pulls content from galaxy.ansible.com - name: Create organization that pulls content from galaxy.ansible.com
organization: organization:
@@ -106,7 +106,7 @@ EXAMPLES = '''
state: present state: present
galaxy_credentials: galaxy_credentials:
- Ansible Galaxy - Ansible Galaxy
tower_config_file: "~/tower_cli.cfg" controller_config_file: "~/tower_cli.cfg"
''' '''
from ..module_utils.controller_api import ControllerAPIModule from ..module_utils.controller_api import ControllerAPIModule

View File

@@ -176,7 +176,7 @@ EXAMPLES = '''
description: "Foo bar project" description: "Foo bar project"
organization: "test" organization: "test"
state: present state: present
tower_config_file: "~/tower_cli.cfg" controller_config_file: "~/tower_cli.cfg"
- name: Add Project with cache timeout - name: Add Project with cache timeout
project: project:
@@ -186,7 +186,7 @@ EXAMPLES = '''
scm_update_on_launch: True scm_update_on_launch: True
scm_update_cache_timeout: 60 scm_update_cache_timeout: 60
state: present state: present
tower_config_file: "~/tower_cli.cfg" controller_config_file: "~/tower_cli.cfg"
- name: Copy project - name: Copy project
project: project:

View File

@@ -104,7 +104,7 @@ EXAMPLES = '''
- name: Export all Automation Platform Controller assets - name: Export all Automation Platform Controller assets
receive: receive:
all: True all: True
tower_config_file: "~/tower_cli.cfg" controller_config_file: "~/tower_cli.cfg"
- name: Export all inventories - name: Export all inventories
receive: receive:

View File

@@ -65,7 +65,7 @@ EXAMPLES = '''
- name: Import all Automation Platform Controller assets - name: Import all Automation Platform Controller assets
send: send:
assets: "{{ export_output.assets }}" assets: "{{ export_output.assets }}"
tower_config_file: "~/tower_cli.cfg" controller_config_file: "~/tower_cli.cfg"
''' '''
RETURN = ''' RETURN = '''

View File

@@ -56,7 +56,7 @@ EXAMPLES = '''
description: Team Description description: Team Description
organization: test-org organization: test-org
state: present state: present
tower_config_file: "~/tower_cli.cfg" controller_config_file: "~/tower_cli.cfg"
''' '''
from ..module_utils.controller_api import ControllerAPIModule from ..module_utils.controller_api import ControllerAPIModule

View File

@@ -22,7 +22,7 @@ description:
- Create or destroy Automation Platform Controller tokens. See - Create or destroy Automation Platform Controller tokens. See
U(https://www.ansible.com/tower) for an overview. U(https://www.ansible.com/tower) for an overview.
- In addition, the module sets an Ansible fact which can be passed into other - In addition, the module sets an Ansible fact which can be passed into other
controller modules as the parameter tower_oauthtoken. See examples for usage. controller modules as the parameter controller_oauthtoken. See examples for usage.
- Because of the sensitive nature of tokens, the created token value is only available once - Because of the sensitive nature of tokens, the created token value is only available once
through the Ansible fact. (See RETURN for details) through the Ansible fact. (See RETURN for details)
- Due to the nature of tokens this module is not idempotent. A second will - Due to the nature of tokens this module is not idempotent. A second will
@@ -49,7 +49,7 @@ options:
default: 'write' default: 'write'
choices: ["read", "write"] choices: ["read", "write"]
existing_token: existing_token:
description: The data structure produced from tower_token in create mode to be used with state absent. description: The data structure produced from token in create mode to be used with state absent.
type: dict type: dict
existing_token_id: existing_token_id:
description: A token ID (number) which can be used to delete an arbitrary token with state absent. description: A token ID (number) which can be used to delete an arbitrary token with state absent.
@@ -70,11 +70,11 @@ EXAMPLES = '''
description: '{{ token_description }}' description: '{{ token_description }}'
scope: "write" scope: "write"
state: present state: present
tower_oauthtoken: "{{ my_existing_token }}" controller_oauthtoken: "{{ my_existing_token }}"
- name: Delete this token - name: Delete this token
token: token:
existing_token: "{{ tower_token }}" existing_token: "{{ token }}"
state: absent state: absent
- name: Create a new token using username/password - name: Create a new token using username/password
@@ -82,19 +82,19 @@ EXAMPLES = '''
description: '{{ token_description }}' description: '{{ token_description }}'
scope: "write" scope: "write"
state: present state: present
tower_username: "{{ my_username }}" controller_username: "{{ my_username }}"
tower_password: "{{ my_password }}" controller_password: "{{ my_password }}"
- name: Use our new token to make another call - name: Use our new token to make another call
job_list: job_list:
tower_oauthtoken: "{{ tower_token }}" controller_oauthtoken: "{{ token }}"
always: always:
- name: Delete our Token with the token we created - name: Delete our Token with the token we created
token: token:
existing_token: "{{ tower_token }}" existing_token: "{{ token }}"
state: absent state: absent
when: tower_token is defined when: token is defined
- name: Delete a token by its id - name: Delete a token by its id
token: token:
@@ -125,7 +125,7 @@ def return_token(module, last_response):
# This method will return the entire token object we got back so that a user has access to the token # This method will return the entire token object we got back so that a user has access to the token
module.json_output['ansible_facts'] = { module.json_output['ansible_facts'] = {
'tower_token': last_response, 'token': last_response,
} }
module.exit_json(**module.json_output) module.exit_json(**module.json_output)

View File

@@ -79,7 +79,7 @@ EXAMPLES = '''
first_name: John first_name: John
last_name: Doe last_name: Doe
state: present state: present
tower_config_file: "~/tower_cli.cfg" controller_config_file: "~/tower_cli.cfg"
- name: Add user as a system administrator - name: Add user as a system administrator
user: user:
@@ -88,7 +88,7 @@ EXAMPLES = '''
email: jdoe@example.org email: jdoe@example.org
superuser: yes superuser: yes
state: present state: present
tower_config_file: "~/tower_cli.cfg" controller_config_file: "~/tower_cli.cfg"
- name: Add user as a system auditor - name: Add user as a system auditor
user: user:
@@ -97,14 +97,14 @@ EXAMPLES = '''
email: jdoe@example.org email: jdoe@example.org
auditor: yes auditor: yes
state: present state: present
tower_config_file: "~/tower_cli.cfg" controller_config_file: "~/tower_cli.cfg"
- name: Delete user - name: Delete user
user: user:
username: jdoe username: jdoe
email: jdoe@example.org email: jdoe@example.org
state: absent state: absent
tower_config_file: "~/tower_cli.cfg" controller_config_file: "~/tower_cli.cfg"
''' '''
from ..module_utils.controller_api import ControllerAPIModule from ..module_utils.controller_api import ControllerAPIModule

View File

@@ -129,7 +129,7 @@ def test_type_warning(collection_import, silence_warning):
def test_duplicate_config(collection_import, silence_warning): def test_duplicate_config(collection_import, silence_warning):
# imports done here because of PATH issues unique to this test suite # imports done here because of PATH issues unique to this test suite
ControllerAPIModule = collection_import('plugins.module_utils.controller_api').ControllerAPIModule ControllerAPIModule = collection_import('plugins.module_utils.controller_api').ControllerAPIModule
data = {'name': 'zigzoom', 'zig': 'zoom', 'tower_username': 'bob', 'tower_config_file': 'my_config'} data = {'name': 'zigzoom', 'zig': 'zoom', 'controller_username': 'bob', 'controller_config_file': 'my_config'}
with mock.patch.object(ControllerAPIModule, 'load_config') as mock_load: with mock.patch.object(ControllerAPIModule, 'load_config') as mock_load:
argument_spec = dict( argument_spec = dict(
@@ -140,8 +140,8 @@ def test_duplicate_config(collection_import, silence_warning):
assert mock_load.mock_calls[-1] == mock.call('my_config') assert mock_load.mock_calls[-1] == mock.call('my_config')
silence_warning.assert_called_once_with( silence_warning.assert_called_once_with(
'The parameter(s) tower_username were provided at the same time as ' 'The parameter(s) controller_username were provided at the same time as '
'tower_config_file. Precedence may be unstable, ' 'controller_config_file. Precedence may be unstable, '
'we suggest either using config file or params.' 'we suggest either using config file or params.'
) )
@@ -167,7 +167,7 @@ def test_conflicting_name_and_id(run_module, admin_user):
one item has an id that matches input one item has an id that matches input
one item has a name that matches input one item has a name that matches input
We should preference the id over the name. We should preference the id over the name.
Otherwise, the universality of the tower_api lookup plugin is compromised. Otherwise, the universality of the controller_api lookup plugin is compromised.
""" """
org_by_id = Organization.objects.create(name='foo') org_by_id = Organization.objects.create(name='foo')
slug = str(org_by_id.id) slug = str(org_by_id.id)

View File

@@ -15,12 +15,12 @@ def test_create_organization(run_module, admin_user):
'description': 'barfoo', 'description': 'barfoo',
'state': 'present', 'state': 'present',
'max_hosts': '0', 'max_hosts': '0',
'tower_host': None, 'controller_host': None,
'tower_username': None, 'controller_username': None,
'tower_password': None, 'controller_password': None,
'validate_certs': None, 'validate_certs': None,
'tower_oauthtoken': None, 'controller_oauthtoken': None,
'tower_config_file': None, 'controller_config_file': None,
} }
result = run_module('organization', module_args, admin_user) result = run_module('organization', module_args, admin_user)

View File

@@ -14,12 +14,12 @@ def test_create_token(run_module, admin_user):
'description': 'barfoo', 'description': 'barfoo',
'state': 'present', 'state': 'present',
'scope': 'read', 'scope': 'read',
'tower_host': None, 'controller_host': None,
'tower_username': None, 'controller_username': None,
'tower_password': None, 'controller_password': None,
'validate_certs': None, 'validate_certs': None,
'tower_oauthtoken': None, 'controller_oauthtoken': None,
'tower_config_file': None, 'controller_config_file': None,
} }
result = run_module('token', module_args, admin_user) result = run_module('token', module_args, admin_user)

View File

@@ -18,7 +18,7 @@
group_name1: "AWX-Collection-tests-instance_group-group1-{{ test_id }}" group_name1: "AWX-Collection-tests-instance_group-group1-{{ test_id }}"
- name: "Create a new organization" - name: "Create a new organization"
tower_organization: organization:
name: "{{ org_name }}" name: "{{ org_name }}"
galaxy_credentials: galaxy_credentials:
- Ansible Galaxy - Ansible Galaxy
@@ -53,7 +53,7 @@
kind: ssh kind: ssh
- name: Create Labels - name: Create Labels
tower_label: label:
name: "{{ lab1 }}" name: "{{ lab1 }}"
organization: "{{ item }}" organization: "{{ item }}"
loop: loop:
@@ -423,7 +423,7 @@
state: absent state: absent
- name: "Remove the organization" - name: "Remove the organization"
tower_organization: organization:
name: "{{ org_name }}" name: "{{ org_name }}"
state: absent state: absent
register: result register: result

View File

@@ -5,7 +5,7 @@
- name: Try to use a token as a dict which is missing the token parameter - name: Try to use a token as a dict which is missing the token parameter
job_list: job_list:
tower_oauthtoken: controller_oauthtoken:
not_token: "This has no token entry" not_token: "This has no token entry"
register: results register: results
ignore_errors: true ignore_errors: true
@@ -13,11 +13,11 @@
- assert: - assert:
that: that:
- results is failed - results is failed
- '"The provided dict in tower_oauthtoken did not properly contain the token entry" == results.msg' - '"The provided dict in controller_oauthtoken did not properly contain the token entry" == results.msg'
- name: Try to use a token as a list - name: Try to use a token as a list
job_list: job_list:
tower_oauthtoken: controller_oauthtoken:
- dummy_token - dummy_token
register: results register: results
ignore_errors: true ignore_errors: true
@@ -25,7 +25,7 @@
- assert: - assert:
that: that:
- results is failed - results is failed
- '"The provided tower_oauthtoken type was not valid (list). Valid options are str or dict." == results.msg' - '"The provided controller_oauthtoken type was not valid (list). Valid options are str or dict." == results.msg'
- name: Try to delete a token with no existing_token or existing_token_id - name: Try to delete a token with no existing_token or existing_token_id
token: token:
@@ -63,21 +63,21 @@
- name: Validate our token works by token - name: Validate our token works by token
job_list: job_list:
tower_oauthtoken: "{{ tower_token.token }}" oauthtoken: "{{ token.token }}"
register: job_list register: job_list
- name: Validate out token works by object - name: Validate out token works by object
job_list: job_list:
tower_oauthtoken: "{{ tower_token }}" oauthtoken: "{{ token }}"
register: job_list register: job_list
always: always:
- name: Delete our Token with our own token - name: Delete our Token with our own token
token: token:
existing_token: "{{ tower_token }}" existing_token: "{{ token }}"
tower_oauthtoken: "{{ tower_token }}" oauthtoken: "{{ token }}"
state: absent state: absent
when: tower_token is defined when: token is defined
register: results register: results
- assert: - assert:
@@ -99,10 +99,10 @@
always: always:
- name: Delete the second Token with our own token - name: Delete the second Token with our own token
token: token:
existing_token_id: "{{ tower_token['id'] }}" existing_token_id: "{{ token['id'] }}"
tower_oauthtoken: "{{ tower_token }}" oauthtoken: "{{ token }}"
state: absent state: absent
when: tower_token is defined when: token is defined
register: results register: results
- assert: - assert:

View File

@@ -110,11 +110,11 @@
email: joe@example.org email: joe@example.org
state: present state: present
validate_certs: true validate_certs: true
tower_host: http://foo.invalid controller_host: http://foo.invalid
ignore_errors: true ignore_errors: true
register: result register: result
- assert: - assert:
that: that:
- "'Unable to resolve tower_host' in result.msg or - "'Unable to resolve controller_host' in result.msg or
'Can not verify ssl with non-https protocol' in result.exception" 'Can not verify ssl with non-https protocol' in result.exception"

View File

@@ -19,7 +19,7 @@
project_inv_source: "AWX-Collection-tests-inventory_source-inv-source-project-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}" project_inv_source: "AWX-Collection-tests-inventory_source-inv-source-project-{{ lookup('password', '/dev/null chars=ascii_letters length=16') }}"
- name: "Create a new organization" - name: "Create a new organization"
tower_organization: organization:
name: "{{ org_name }}" name: "{{ org_name }}"
galaxy_credentials: galaxy_credentials:
- Ansible Galaxy - Ansible Galaxy
@@ -64,7 +64,7 @@
register: result register: result
- name: Create Labels - name: Create Labels
tower_label: label:
name: "{{ lab1 }}" name: "{{ lab1 }}"
organization: "{{ item }}" organization: "{{ item }}"
loop: loop:
@@ -667,7 +667,7 @@
state: absent state: absent
- name: "Remove the organization" - name: "Remove the organization"
tower_organization: organization:
name: "{{ org_name }}" name: "{{ org_name }}"
state: absent state: absent
register: result register: result

View File

@@ -36,9 +36,9 @@
- name: Change runtime.yml redirect destinations - name: Change runtime.yml redirect destinations
replace: replace:
path: "{{ collection_path}}/meta/runtime.yml" path: "{{ collection_path }}/meta/runtime.yml"
regexp: "redirect: awx.awx." regexp: "redirect: awx.awx."
replace: "redirect: '{{ collection_namespace }}.{{ collection_package }}." replace: "redirect: {{ collection_namespace }}.{{ collection_package }}."
- name: get list of test files - name: get list of test files
find: find: