Skip to content

Commit 873e6a0

Browse files
pb82sean-m-sullivanAlanCoding
authored
Update collection args (ansible#16025)
* update collection arguments * Add integration testing for new param * fix: sanity check failures --------- Co-authored-by: Sean Sullivan <[email protected]> Co-authored-by: Alan Rominger <[email protected]>
1 parent 6182d68 commit 873e6a0

File tree

4 files changed

+79
-19
lines changed

4 files changed

+79
-19
lines changed

awx_collection/plugins/doc_fragments/auth.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,42 @@ class ModuleDocFragment(object):
1919
- If value not set, will try environment variable C(CONTROLLER_HOST) and then config files
2020
- If value not specified by any means, the value of C(127.0.0.1) will be used
2121
type: str
22-
aliases: [ tower_host ]
22+
aliases: [ tower_host, aap_hostname ]
2323
controller_username:
2424
description:
2525
- Username for your controller instance.
2626
- If value not set, will try environment variable C(CONTROLLER_USERNAME) and then config files
2727
type: str
28-
aliases: [ tower_username ]
28+
aliases: [ tower_username, aap_username ]
2929
controller_password:
3030
description:
3131
- Password for your controller instance.
3232
- If value not set, will try environment variable C(CONTROLLER_PASSWORD) and then config files
3333
type: str
34-
aliases: [ tower_password ]
34+
aliases: [ tower_password , aap_password ]
35+
aap_token:
36+
description:
37+
- The OAuth token to use.
38+
- This value can be in one of two formats.
39+
- A string which is the token itself. (i.e. bqV5txm97wqJqtkxlMkhQz0pKhRMMX)
40+
- A dictionary structure as returned by the token module.
41+
- If value not set, will try environment variable C(CONTROLLER_OAUTH_TOKEN) and then config files
42+
type: raw
43+
version_added: "3.7.0"
3544
validate_certs:
3645
description:
3746
- Whether to allow insecure connections to AWX.
3847
- If C(no), SSL certificates will not be validated.
3948
- This should only be used on personally controlled sites using self-signed certificates.
4049
- If value not set, will try environment variable C(CONTROLLER_VERIFY_SSL) and then config files
4150
type: bool
42-
aliases: [ tower_verify_ssl ]
51+
aliases: [ tower_verify_ssl, aap_validate_certs ]
4352
request_timeout:
4453
description:
4554
- Specify the timeout Ansible should use in requests to the controller host.
4655
- Defaults to 10s, but this is handled by the shared module_utils code
4756
type: float
57+
aliases: [ aap_request_timeout ]
4858
controller_config_file:
4959
description:
5060
- Path to the controller config file.

awx_collection/plugins/doc_fragments/auth_plugin.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,45 +17,50 @@ class ModuleDocFragment(object):
1717
description: The network address of your Automation Platform Controller host.
1818
env:
1919
- name: CONTROLLER_HOST
20-
- name: TOWER_HOST
2120
deprecated:
2221
collection_name: 'awx.awx'
2322
version: '4.0.0'
2423
why: Collection name change
25-
alternatives: 'CONTROLLER_HOST'
24+
alternatives: 'TOWER_HOST, AAP_HOSTNAME'
2625
username:
2726
description: The user that you plan to use to access inventories on the controller.
2827
env:
2928
- name: CONTROLLER_USERNAME
30-
- name: TOWER_USERNAME
3129
deprecated:
3230
collection_name: 'awx.awx'
3331
version: '4.0.0'
3432
why: Collection name change
35-
alternatives: 'CONTROLLER_USERNAME'
33+
alternatives: 'TOWER_USERNAME, AAP_USERNAME'
3634
password:
3735
description: The password for your controller user.
3836
env:
3937
- name: CONTROLLER_PASSWORD
40-
- name: TOWER_PASSWORD
4138
deprecated:
4239
collection_name: 'awx.awx'
4340
version: '4.0.0'
4441
why: Collection name change
45-
alternatives: 'CONTROLLER_PASSWORD'
42+
alternatives: 'TOWER_PASSWORD, AAP_PASSWORD'
43+
aap_token:
44+
description:
45+
- The OAuth token to use.
46+
env:
47+
- name: AAP_TOKEN
48+
deprecated:
49+
collection_name: 'awx.awx'
50+
version: '4.0.0'
51+
why: Collection name change
4652
verify_ssl:
4753
description:
4854
- Specify whether Ansible should verify the SSL certificate of the controller host.
4955
- Defaults to True, but this is handled by the shared module_utils code
5056
type: bool
5157
env:
5258
- name: CONTROLLER_VERIFY_SSL
53-
- name: TOWER_VERIFY_SSL
5459
deprecated:
5560
collection_name: 'awx.awx'
5661
version: '4.0.0'
5762
why: Collection name change
58-
alternatives: 'CONTROLLER_VERIFY_SSL'
63+
alternatives: 'TOWER_VERIFY_SSL, AAP_VALIDATE_CERTS'
5964
aliases: [ validate_certs ]
6065
request_timeout:
6166
description:
@@ -65,7 +70,12 @@ class ModuleDocFragment(object):
6570
type: float
6671
env:
6772
- name: CONTROLLER_REQUEST_TIMEOUT
68-
73+
deprecated:
74+
collection_name: 'awx.awx'
75+
version: '4.0.0'
76+
why: Support for AAP variables
77+
alternatives: 'AAP_REQUEST_TIMEOUT'
78+
aliases: [ aap_request_timeout ]
6979
notes:
7080
- If no I(config_file) is provided we will attempt to use the tower-cli library
7181
defaults to find your host information.

awx_collection/plugins/module_utils/controller_api.py

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,40 @@ class ItemNotDefined(Exception):
4949
class ControllerModule(AnsibleModule):
5050
url = None
5151
AUTH_ARGSPEC = dict(
52-
controller_host=dict(required=False, aliases=['tower_host'], fallback=(env_fallback, ['CONTROLLER_HOST', 'TOWER_HOST'])),
53-
controller_username=dict(required=False, aliases=['tower_username'], fallback=(env_fallback, ['CONTROLLER_USERNAME', 'TOWER_USERNAME'])),
54-
controller_password=dict(no_log=True, aliases=['tower_password'], required=False, fallback=(env_fallback, ['CONTROLLER_PASSWORD', 'TOWER_PASSWORD'])),
55-
validate_certs=dict(type='bool', aliases=['tower_verify_ssl'], required=False, fallback=(env_fallback, ['CONTROLLER_VERIFY_SSL', 'TOWER_VERIFY_SSL'])),
56-
request_timeout=dict(type='float', required=False, fallback=(env_fallback, ['CONTROLLER_REQUEST_TIMEOUT'])),
57-
controller_config_file=dict(type='path', aliases=['tower_config_file'], required=False, default=None),
52+
controller_host=dict(
53+
required=False,
54+
aliases=['tower_host', 'aap_hostname'],
55+
fallback=(env_fallback, ['CONTROLLER_HOST', 'TOWER_HOST', 'AAP_HOSTNAME'])),
56+
controller_username=dict(
57+
required=False,
58+
aliases=['tower_username', 'aap_username'],
59+
fallback=(env_fallback, ['CONTROLLER_USERNAME', 'TOWER_USERNAME', 'AAP_USERNAME'])),
60+
controller_password=dict(
61+
no_log=True,
62+
aliases=['tower_password', 'aap_password'],
63+
required=False,
64+
fallback=(env_fallback, ['CONTROLLER_PASSWORD', 'TOWER_PASSWORD', 'AAP_PASSWORD'])),
65+
validate_certs=dict(
66+
type='bool',
67+
aliases=['tower_verify_ssl', 'aap_validate_certs'],
68+
required=False,
69+
fallback=(env_fallback, ['CONTROLLER_VERIFY_SSL', 'TOWER_VERIFY_SSL', 'AAP_VALIDATE_CERTS'])),
70+
request_timeout=dict(
71+
type='float',
72+
aliases=['aap_request_timeout'],
73+
required=False,
74+
fallback=(env_fallback, ['CONTROLLER_REQUEST_TIMEOUT', 'AAP_REQUEST_TIMEOUT'])),
75+
aap_token=dict(
76+
type='raw',
77+
no_log=True,
78+
required=False,
79+
fallback=(env_fallback, ['CONTROLLER_OAUTH_TOKEN', 'TOWER_OAUTH_TOKEN', 'AAP_TOKEN'])
80+
),
81+
controller_config_file=dict(
82+
type='path',
83+
aliases=['tower_config_file'],
84+
required=False,
85+
default=None),
5886
)
5987
# Associations of these types are ordered and have special consideration in the modified associations function
6088
ordered_associations = ['instance_groups', 'galaxy_credentials', 'input_inventories']
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
- name: Perform an action with a different hostname via aap_hostname
3+
inventory:
4+
name: "Demo Inventory"
5+
organization: Default
6+
aap_hostname: https://foohostbar.invalid
7+
ignore_errors: true
8+
register: result
9+
10+
- assert:
11+
that:
12+
- "'foohostbar' in result.msg"

0 commit comments

Comments
 (0)