Finish adding settings to UI

This commit is contained in:
AlanCoding
2019-08-26 12:40:43 -04:00
parent d59d8562db
commit 093bf6877b
4 changed files with 35 additions and 14 deletions

View File

@@ -442,47 +442,54 @@ register(
register( register(
'PRIVATE_GALAXY_URL', 'PRIVATE_GALAXY_URL',
field_class=fields.URLField, field_class=fields.URLField,
label=_('Private Galaxy Server Host'), required=False,
allow_blank=True,
label=_('Private Galaxy Server URL'),
help_text=_('For using a private galaxy server at higher precedence than the public Ansible Galaxy. ' help_text=_('For using a private galaxy server at higher precedence than the public Ansible Galaxy. '
'The URL of the galaxy instance to connect to, this is required if using a private galaxy server.'), 'The URL of the galaxy instance to connect to, this is required if using a private galaxy server.'),
category=_('Jobs'), category=_('Jobs'),
category_slug='jobs', category_slug='jobs'
) )
register( register(
'PRIVATE_GALAXY_USERNAME', 'PRIVATE_GALAXY_USERNAME',
field_class=fields.CharField, field_class=fields.CharField,
required=False,
allow_blank=True,
label=_('Private Galaxy Server Username'), label=_('Private Galaxy Server Username'),
help_text=_('For using a private galaxy server at higher precedence than the public Ansible Galaxy. ' help_text=_('For using a private galaxy server at higher precedence than the public Ansible Galaxy. '
'The username to use for basic authentication against the Galaxy instance, ' 'The username to use for basic authentication against the Galaxy instance, '
'this is mutually exclusive with PRIVATE_GALAXY_TOKEN.'), 'this is mutually exclusive with PRIVATE_GALAXY_TOKEN.'),
category=_('Jobs'), category=_('Jobs'),
category_slug='jobs', category_slug='jobs'
depends_on=['PRIVATE_GALAXY_URL']
) )
register( register(
'PRIVATE_GALAXY_PASSWORD', 'PRIVATE_GALAXY_PASSWORD',
field_class=fields.CharField, field_class=fields.CharField,
encrypted=True,
required=False,
allow_blank=True,
label=_('Private Galaxy Server Password'), label=_('Private Galaxy Server Password'),
help_text=_('For using a private galaxy server at higher precedence than the public Ansible Galaxy. ' help_text=_('For using a private galaxy server at higher precedence than the public Ansible Galaxy. '
'The password to use for basic authentication against the Galaxy instance, ' 'The password to use for basic authentication against the Galaxy instance, '
'this is mutually exclusive with PRIVATE_GALAXY_TOKEN.'), 'this is mutually exclusive with PRIVATE_GALAXY_TOKEN.'),
category=_('Jobs'), category=_('Jobs'),
category_slug='jobs', category_slug='jobs'
depends_on=['PRIVATE_GALAXY_URL']
) )
register( register(
'PRIVATE_GALAXY_TOKEN', 'PRIVATE_GALAXY_TOKEN',
field_class=fields.CharField, field_class=fields.CharField,
encrypted=True,
required=False,
allow_blank=True,
label=_('Private Galaxy Server Token'), label=_('Private Galaxy Server Token'),
help_text=_('For using a private galaxy server at higher precedence than the public Ansible Galaxy. ' help_text=_('For using a private galaxy server at higher precedence than the public Ansible Galaxy. '
'The username to use for basic authentication against the Galaxy instance, ' 'The token to use for connecting with the Galaxy instance, '
'this is mutually exclusive with corresponding username and password settings.'), 'this is mutually exclusive with corresponding username and password settings.'),
category=_('Jobs'), category=_('Jobs'),
category_slug='jobs', category_slug='jobs'
depends_on=['PRIVATE_GALAXY_URL']
) )
register( register(

View File

@@ -1883,11 +1883,11 @@ class RunProjectUpdate(BaseTask):
env['TMP'] = settings.AWX_PROOT_BASE_PATH env['TMP'] = settings.AWX_PROOT_BASE_PATH
env['PROJECT_UPDATE_ID'] = str(project_update.pk) env['PROJECT_UPDATE_ID'] = str(project_update.pk)
env['ANSIBLE_CALLBACK_PLUGINS'] = self.get_path_to('..', 'plugins', 'callback') env['ANSIBLE_CALLBACK_PLUGINS'] = self.get_path_to('..', 'plugins', 'callback')
# If private galaxy URL is non-blank, that means this feature is enabled
private_galaxy_url = settings.PRIVATE_GALAXY_URL private_galaxy_url = settings.PRIVATE_GALAXY_URL
if private_galaxy_url: if private_galaxy_url:
# set up the fallback server, which is the normal Ansible Galaxy # set up the fallback server, which is the normal Ansible Galaxy
env['ANSIBLE_GALAXY_SERVER_GALAXY_URL'] = 'https://galaxy.ansible.com' env['ANSIBLE_GALAXY_SERVER_GALAXY_URL'] = 'https://galaxy.ansible.com'
env['ANSIBLE_GALAXY_SERVER_PRIVATE_GALAXY_URL'] = private_galaxy_url
for key in ('url', 'username', 'password', 'token'): for key in ('url', 'username', 'password', 'token'):
setting_name = 'PRIVATE_GALAXY_{}'.format(key.upper()) setting_name = 'PRIVATE_GALAXY_{}'.format(key.upper())
value = getattr(settings, setting_name) value = getattr(settings, setting_name)

View File

@@ -623,10 +623,10 @@ AWX_ROLES_ENABLED = True
AWX_COLLECTIONS_ENABLED = True AWX_COLLECTIONS_ENABLED = True
# Settings for private galaxy server, should be set in the UI # Settings for private galaxy server, should be set in the UI
PRIVATE_GALAXY_URL = None PRIVATE_GALAXY_URL = ''
PRIVATE_GALAXY_USERNAME = None PRIVATE_GALAXY_USERNAME = ''
PRIVATE_GALAXY_TOKEN = None PRIVATE_GALAXY_TOKEN = ''
PRIVATE_GALAXY_PASSWORD = None PRIVATE_GALAXY_PASSWORD = ''
# Public Galaxy URL, not configurable outside of file-based settings # Public Galaxy URL, not configurable outside of file-based settings
PUBLIC_GALAXY_URL = 'https://galaxy.ansible.com' PUBLIC_GALAXY_URL = 'https://galaxy.ansible.com'

View File

@@ -71,6 +71,20 @@ export default ['i18n', function(i18n) {
type: 'text', type: 'text',
reset: 'PRIVATE_GALAXY_URL', reset: 'PRIVATE_GALAXY_URL',
}, },
PRIVATE_GALAXY_USERNAME: {
type: 'text',
reset: 'PRIVATE_GALAXY_USERNAME',
},
PRIVATE_GALAXY_PASSWORD: {
type: 'sensitive',
hasShowInputButton: true,
reset: 'PRIVATE_GALAXY_PASSWORD',
},
PRIVATE_GALAXY_TOKEN: {
type: 'sensitive',
hasShowInputButton: true,
reset: 'PRIVATE_GALAXY_TOKEN',
},
AWX_TASK_ENV: { AWX_TASK_ENV: {
type: 'textarea', type: 'textarea',
reset: 'AWX_TASK_ENV', reset: 'AWX_TASK_ENV',