mirror of
https://github.com/ansible/awx.git
synced 2026-03-07 19:51:08 -03:30
Removed references to tower in InventorySource and Credentials
--- Removed reference to tower in InventorySource and InventoryUpdate model --- Added a migration for above change --- Added new CONTROLLER* variables in awx/main/models/credentials/__init__.py --- Migrated awxkit to new CONTROLLER* variables --- Updated the tests to use new CONTROLLER* variables --- Fix some issues with upgrade path, rename more cases
This commit is contained in:
committed by
Shane McDonald
parent
645f7f6dac
commit
b64c2d6861
@@ -79,7 +79,7 @@ credential_type_name_to_config_kind_map = {
|
||||
'amazon web services': 'aws',
|
||||
'container registry': 'registry',
|
||||
'ansible galaxy/automation hub api token': 'galaxy',
|
||||
'ansible tower': 'tower',
|
||||
'red hat ansible automation platform': 'controller',
|
||||
'google compute engine': 'gce',
|
||||
'insights': 'insights',
|
||||
'openshift or kubernetes api bearer token': 'kubernetes',
|
||||
|
||||
@@ -2,6 +2,6 @@ Building the Documentation
|
||||
--------------------------
|
||||
To build the docs, spin up a real AWX server, `pip install sphinx sphinxcontrib-autoprogram`, and run:
|
||||
|
||||
~ TOWER_HOST=https://awx.example.org TOWER_USERNAME=example TOWER_PASSWORD=secret make clean html
|
||||
~ CONTROLLER_HOST=https://awx.example.org CONTROLLER_USERNAME=example CONTROLLER_PASSWORD=secret make clean html
|
||||
~ cd build/html/ && python -m http.server
|
||||
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ..
|
||||
|
||||
@@ -12,9 +12,9 @@ The preferred mechanism for authenticating with AWX and |RHAT| is by generating
|
||||
|
||||
.. code:: bash
|
||||
|
||||
TOWER_HOST=https://awx.example.org \
|
||||
TOWER_USERNAME=alice \
|
||||
TOWER_PASSWORD=secret \
|
||||
CONTROLLER_HOST=https://awx.example.org \
|
||||
CONTROLLER_USERNAME=alice \
|
||||
CONTROLLER_PASSWORD=secret \
|
||||
awx login
|
||||
|
||||
As a convenience, the ``awx login -f human`` command prints a shell-formatted token
|
||||
@@ -22,15 +22,15 @@ value:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
export TOWER_OAUTH_TOKEN=6E5SXhld7AMOhpRveZsLJQsfs9VS8U
|
||||
export CONTROLLER_OAUTH_TOKEN=6E5SXhld7AMOhpRveZsLJQsfs9VS8U
|
||||
|
||||
By ingesting this token, you can run subsequent CLI commands without having to
|
||||
specify your username and password each time:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
export TOWER_HOST=https://awx.example.org
|
||||
$(TOWER_USERNAME=alice TOWER_PASSWORD=secret awx login -f human)
|
||||
export CONTROLLER_HOST=https://awx.example.org
|
||||
$(CONTROLLER_USERNAME=alice CONTROLLER_PASSWORD=secret awx login -f human)
|
||||
awx config
|
||||
|
||||
Working with OAuth2.0 Applications
|
||||
@@ -43,7 +43,7 @@ application was created.
|
||||
|
||||
.. code:: bash
|
||||
|
||||
TOWER_USERNAME=alice TOWER_PASSWORD=secret awx login \
|
||||
CONTROLLER_USERNAME=alice CONTROLLER_PASSWORD=secret awx login \
|
||||
--conf.client_id <value> --conf.client_secret <value>
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ a read-only token, specify ``--scope read``:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
TOWER_USERNAME=alice TOWER_PASSWORD=secret \
|
||||
CONTROLLER_USERNAME=alice CONTROLLER_PASSWORD=secret \
|
||||
awx login --conf.scope read
|
||||
|
||||
Session Authentication
|
||||
@@ -65,5 +65,5 @@ specify your username and password on every invocation:
|
||||
|
||||
.. code:: bash
|
||||
|
||||
TOWER_USERNAME=alice TOWER_PASSWORD=secret awx jobs list
|
||||
CONTROLLER_USERNAME=alice CONTROLLER_PASSWORD=secret awx jobs list
|
||||
awx --conf.username alice --conf.password secret jobs list
|
||||
|
||||
@@ -54,4 +54,4 @@ Colorized Output
|
||||
|
||||
By default, |prog| prints colorized output using ANSI color codes. To disable
|
||||
this functionality, specify ``--conf.color f`` or set the environment variable
|
||||
``TOWER_COLOR=f``.
|
||||
``CONTROLLER_COLOR=f``.
|
||||
|
||||
@@ -77,17 +77,17 @@ A few of the most important ones are:
|
||||
``-f, --conf.format``
|
||||
used to specify a custom output format (the default is json)
|
||||
|
||||
``--conf.host, TOWER_HOST``
|
||||
``--conf.host, CONTROLLER_HOST``
|
||||
the full URL of the AWX/|RHAT| host (i.e., https://my.awx.example.org)
|
||||
|
||||
``-k, --conf.insecure, TOWER_VERIFY_SSL``
|
||||
``-k, --conf.insecure, CONTROLLER_VERIFY_SSL``
|
||||
allows insecure server connections when using SSL
|
||||
|
||||
``--conf.username, TOWER_USERNAME``
|
||||
``--conf.username, CONTROLLER_USERNAME``
|
||||
the AWX username to use for authentication
|
||||
|
||||
``--conf.password, TOWER_PASSWORD``
|
||||
``--conf.password, CONTROLLER_PASSWORD``
|
||||
the AWX password to use for authentication
|
||||
|
||||
``--conf.token, TOWER_OAUTH_TOKEN``
|
||||
``--conf.token, CONTROLLER_OAUTH_TOKEN``
|
||||
an OAuth2.0 token to use for authentication
|
||||
|
||||
@@ -11,30 +11,30 @@ def add_authentication_arguments(parser, env):
|
||||
auth = parser.add_argument_group('authentication')
|
||||
auth.add_argument(
|
||||
'--conf.host',
|
||||
default=env.get('TOWER_HOST', 'https://127.0.0.1:443'),
|
||||
default=env.get('CONTROLLER_HOST', env.get('TOWER_HOST', 'https://127.0.0.1:443')),
|
||||
metavar='https://example.awx.org',
|
||||
)
|
||||
auth.add_argument(
|
||||
'--conf.token',
|
||||
default=env.get('TOWER_OAUTH_TOKEN', env.get('TOWER_TOKEN', '')),
|
||||
default=env.get('CONTROLLER_OAUTH_TOKEN', env.get('CONTROLLER_TOKEN', env.get('TOWER_OAUTH_TOKEN', env.get('TOWER_TOKEN', '')))),
|
||||
help='an OAuth2.0 token (get one by using `awx login`)',
|
||||
metavar='TEXT',
|
||||
)
|
||||
auth.add_argument(
|
||||
'--conf.username',
|
||||
default=env.get('TOWER_USERNAME', 'admin'),
|
||||
default=env.get('CONTROLLER_USERNAME', env.get('TOWER_USERNAME', 'admin')),
|
||||
metavar='TEXT',
|
||||
)
|
||||
auth.add_argument(
|
||||
'--conf.password',
|
||||
default=env.get('TOWER_PASSWORD', 'password'),
|
||||
default=env.get('CONTROLLER_PASSWORD', env.get('TOWER_PASSWORD', 'password')),
|
||||
metavar='TEXT',
|
||||
)
|
||||
auth.add_argument(
|
||||
'-k',
|
||||
'--conf.insecure',
|
||||
help='Allow insecure server connections when using SSL',
|
||||
default=not strtobool(env.get('TOWER_VERIFY_SSL', 'True')),
|
||||
default=not strtobool(env.get('CONTROLLER_VERIFY_SSL', env.get('TOWER_VERIFY_SSL', 'True'))),
|
||||
action='store_true',
|
||||
)
|
||||
|
||||
@@ -47,7 +47,7 @@ def add_output_formatting_arguments(parser, env):
|
||||
'--conf.format',
|
||||
dest='conf.format',
|
||||
choices=FORMATTERS.keys(),
|
||||
default=env.get('TOWER_FORMAT', 'json'),
|
||||
default=env.get('CONTROLLER_FORMAT', env.get('TOWER_FORMAT', 'json')),
|
||||
help=('specify a format for the input and output'),
|
||||
)
|
||||
formatting.add_argument(
|
||||
@@ -61,7 +61,7 @@ def add_output_formatting_arguments(parser, env):
|
||||
'--conf.color',
|
||||
metavar='BOOLEAN',
|
||||
help='Display colorized output. Defaults to True',
|
||||
default=env.get('TOWER_COLOR', 't'),
|
||||
default=env.get('CONTROLLER_COLOR', env.get('TOWER_COLOR', 't')),
|
||||
type=strtobool,
|
||||
)
|
||||
formatting.add_argument(
|
||||
@@ -69,7 +69,7 @@ def add_output_formatting_arguments(parser, env):
|
||||
'--verbose',
|
||||
dest='conf.verbose',
|
||||
help='print debug-level logs, including requests made',
|
||||
default=strtobool(env.get('TOWER_VERBOSE', 'f')),
|
||||
default=strtobool(env.get('CONTROLLER_VERBOSE', env.get('TOWER_VERBOSE', 'f'))),
|
||||
action="store_true",
|
||||
)
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ class Login(CustomCommand):
|
||||
else:
|
||||
fmt = client.get_config('format')
|
||||
if fmt == 'human':
|
||||
print('export TOWER_OAUTH_TOKEN={}'.format(token))
|
||||
print('export CONTROLLER_OAUTH_TOKEN={}'.format(token))
|
||||
else:
|
||||
print(to_str(FORMATTERS[fmt]({'token': token}, '.')).strip())
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ def render():
|
||||
# The return value of this function is an argparse.ArgumentParser, which
|
||||
# the sphinxcontrib.autoprogram plugin crawls and generates an indexed
|
||||
# Sphinx document from.
|
||||
for e in ('TOWER_HOST', 'TOWER_USERNAME', 'TOWER_PASSWORD'):
|
||||
for e in ('CONTROLLER_HOST', 'CONTROLLER_USERNAME', 'CONTROLLER_PASSWORD'):
|
||||
if not os.environ.get(e):
|
||||
raise SystemExit('Please specify a valid {} for a real (running) installation.'.format(e)) # noqa
|
||||
cli = CLI()
|
||||
|
||||
@@ -7,7 +7,7 @@ from awxkit import config
|
||||
|
||||
def test_host_from_environment():
|
||||
cli = CLI()
|
||||
cli.parse_args(['awx'], env={'TOWER_HOST': 'https://xyz.local'})
|
||||
cli.parse_args(['awx'], env={'CONTROLLER_HOST': 'https://xyz.local'})
|
||||
with pytest.raises(ConnectionError):
|
||||
cli.connect()
|
||||
assert config.base_url == 'https://xyz.local'
|
||||
@@ -23,7 +23,7 @@ def test_host_from_argv():
|
||||
|
||||
def test_username_and_password_from_environment():
|
||||
cli = CLI()
|
||||
cli.parse_args(['awx'], env={'TOWER_USERNAME': 'mary', 'TOWER_PASSWORD': 'secret'})
|
||||
cli.parse_args(['awx'], env={'CONTROLLER_USERNAME': 'mary', 'CONTROLLER_PASSWORD': 'secret'})
|
||||
with pytest.raises(ConnectionError):
|
||||
cli.connect()
|
||||
|
||||
@@ -43,7 +43,7 @@ def test_username_and_password_argv():
|
||||
|
||||
def test_config_precedence():
|
||||
cli = CLI()
|
||||
cli.parse_args(['awx', '--conf.username', 'mary', '--conf.password', 'secret'], env={'TOWER_USERNAME': 'IGNORE', 'TOWER_PASSWORD': 'IGNORE'})
|
||||
cli.parse_args(['awx', '--conf.username', 'mary', '--conf.password', 'secret'], env={'CONTROLLER_USERNAME': 'IGNORE', 'CONTROLLER_PASSWORD': 'IGNORE'})
|
||||
with pytest.raises(ConnectionError):
|
||||
cli.connect()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user