diff --git a/awx_collection/plugins/doc_fragments/auth.py b/awx_collection/plugins/doc_fragments/auth.py index f8241e1c7841..d0529a83d3d8 100644 --- a/awx_collection/plugins/doc_fragments/auth.py +++ b/awx_collection/plugins/doc_fragments/auth.py @@ -19,19 +19,29 @@ class ModuleDocFragment(object): - 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 type: str - aliases: [ tower_host ] + aliases: [ tower_host, aap_hostname ] controller_username: description: - Username for your controller instance. - If value not set, will try environment variable C(CONTROLLER_USERNAME) and then config files type: str - aliases: [ tower_username ] + aliases: [ tower_username, aap_username ] controller_password: description: - Password for your controller instance. - If value not set, will try environment variable C(CONTROLLER_PASSWORD) and then config files type: str - aliases: [ tower_password ] + aliases: [ tower_password , aap_password ] + aap_token: + description: + - The OAuth token to use. + - This value can be in one of two formats. + - A string which is the token itself. (i.e. bqV5txm97wqJqtkxlMkhQz0pKhRMMX) + - A dictionary structure as returned by the token module. + - If value not set, will try environment variable C(CONTROLLER_OAUTH_TOKEN) and then config files + type: raw + version_added: "3.7.0" + aliases: [ tower_oauthtoken, controller_oauthtoken] validate_certs: description: - Whether to allow insecure connections to AWX. @@ -39,12 +49,13 @@ class ModuleDocFragment(object): - This should only be used on personally controlled sites using self-signed certificates. - If value not set, will try environment variable C(CONTROLLER_VERIFY_SSL) and then config files type: bool - aliases: [ tower_verify_ssl ] + aliases: [ tower_verify_ssl, aap_validate_certs ] request_timeout: description: - Specify the timeout Ansible should use in requests to the controller host. - Defaults to 10s, but this is handled by the shared module_utils code type: float + aliases: [ aap_request_timeout ] controller_config_file: description: - Path to the controller config file. diff --git a/awx_collection/plugins/doc_fragments/auth_plugin.py b/awx_collection/plugins/doc_fragments/auth_plugin.py index 49118baf714f..6914dfab9cec 100644 --- a/awx_collection/plugins/doc_fragments/auth_plugin.py +++ b/awx_collection/plugins/doc_fragments/auth_plugin.py @@ -17,32 +17,39 @@ class ModuleDocFragment(object): description: The network address of your Automation Platform Controller host. env: - name: CONTROLLER_HOST - - name: TOWER_HOST deprecated: collection_name: 'awx.awx' version: '4.0.0' why: Collection name change - alternatives: 'CONTROLLER_HOST' + alternatives: 'TOWER_HOST, AAP_HOSTNAME' username: description: The user that you plan to use to access inventories on the controller. env: - name: CONTROLLER_USERNAME - - name: TOWER_USERNAME deprecated: collection_name: 'awx.awx' version: '4.0.0' why: Collection name change - alternatives: 'CONTROLLER_USERNAME' + alternatives: 'TOWER_USERNAME, AAP_USERNAME' password: description: The password for your controller user. env: - name: CONTROLLER_PASSWORD - - name: TOWER_PASSWORD deprecated: collection_name: 'awx.awx' version: '4.0.0' why: Collection name change - alternatives: 'CONTROLLER_PASSWORD' + alternatives: 'TOWER_PASSWORD, AAP_PASSWORD' + oauth_token: + description: + - The OAuth token to use. + env: + - name: CONTROLLER_OAUTH_TOKEN + deprecated: + collection_name: 'awx.awx' + version: '4.0.0' + why: Collection name change + alternatives: 'TOWER_OAUTH_TOKEN, AAP_TOKEN' verify_ssl: description: - Specify whether Ansible should verify the SSL certificate of the controller host. @@ -50,12 +57,11 @@ class ModuleDocFragment(object): type: bool env: - name: CONTROLLER_VERIFY_SSL - - name: TOWER_VERIFY_SSL deprecated: collection_name: 'awx.awx' version: '4.0.0' why: Collection name change - alternatives: 'CONTROLLER_VERIFY_SSL' + alternatives: 'TOWER_VERIFY_SSL, AAP_VALIDATE_CERTS' aliases: [ validate_certs ] request_timeout: description: @@ -65,6 +71,7 @@ class ModuleDocFragment(object): type: float env: - name: CONTROLLER_REQUEST_TIMEOUT + alternatives: 'AAP_REQUEST_TIMEOUT' notes: - If no I(config_file) is provided we will attempt to use the tower-cli library diff --git a/awx_collection/plugins/module_utils/controller_api.py b/awx_collection/plugins/module_utils/controller_api.py index 2e9cdd126cb1..10d5039d18bc 100644 --- a/awx_collection/plugins/module_utils/controller_api.py +++ b/awx_collection/plugins/module_utils/controller_api.py @@ -50,12 +50,41 @@ class ItemNotDefined(Exception): class ControllerModule(AnsibleModule): url = None AUTH_ARGSPEC = dict( - controller_host=dict(required=False, aliases=['tower_host'], fallback=(env_fallback, ['CONTROLLER_HOST', 'TOWER_HOST'])), - controller_username=dict(required=False, aliases=['tower_username'], fallback=(env_fallback, ['CONTROLLER_USERNAME', 'TOWER_USERNAME'])), - controller_password=dict(no_log=True, aliases=['tower_password'], 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'])), - request_timeout=dict(type='float', required=False, fallback=(env_fallback, ['CONTROLLER_REQUEST_TIMEOUT'])), - controller_config_file=dict(type='path', aliases=['tower_config_file'], required=False, default=None), + controller_host=dict( + required=False, + aliases=['tower_host', 'aap_hostname'], + fallback=(env_fallback, ['CONTROLLER_HOST', 'TOWER_HOST', 'AAP_HOSTNAME'])), + controller_username=dict( + required=False, + aliases=['tower_username', 'aap_username'], + fallback=(env_fallback, ['CONTROLLER_USERNAME', 'TOWER_USERNAME', 'AAP_USERNAME'])), + controller_password=dict( + no_log=True, + aliases=['tower_password', 'aap_password'], + required=False, + fallback=(env_fallback, ['CONTROLLER_PASSWORD', 'TOWER_PASSWORD', 'AAP_PASSWORD'])), + validate_certs=dict( + type='bool', + aliases=['tower_verify_ssl', 'aap_validate_certs'], + required=False, + fallback=(env_fallback, ['CONTROLLER_VERIFY_SSL', 'TOWER_VERIFY_SSL', 'AAP_VALIDATE_CERTS'])), + request_timeout=dict( + type='float', + aliases=['aap_request_timeout'], + required=False, + fallback=(env_fallback, ['CONTROLLER_REQUEST_TIMEOUT', 'AAP_REQUEST_TIMEOUT'])), + controller_oauthtoken=dict( + type='raw', + no_log=True, + aliases=['tower_oauthtoken', 'aap_token'], + required=False, + fallback=(env_fallback, ['CONTROLLER_OAUTH_TOKEN', 'TOWER_OAUTH_TOKEN', 'AAP_TOKEN']) + ), + controller_config_file=dict( + type='path', + aliases=['tower_config_file'], + required=False, + default=None), ) # Associations of these types are ordered and have special consideration in the modified associations function ordered_associations = ['instance_groups', 'galaxy_credentials'] diff --git a/awx_collection/tests/integration/targets/params/tasks/main.yml b/awx_collection/tests/integration/targets/params/tasks/main.yml new file mode 100644 index 000000000000..86e8688c02d1 --- /dev/null +++ b/awx_collection/tests/integration/targets/params/tasks/main.yml @@ -0,0 +1,11 @@ +- name: Perform an action with a different hostname via aap_hostname + inventory: + name: "Demo Inventory" + organization: Default + aap_hostname: https://foohostbar.invalid + ignore_errors: true + register: result + +- assert: + that: + - "'foohostbar' in result.msg"