Initial env var implementation of private galaxy server

This commit is contained in:
AlanCoding
2019-08-23 16:46:48 -04:00
parent 5a5b46aea0
commit c566c332f9
4 changed files with 84 additions and 0 deletions

View File

@@ -410,6 +410,15 @@ register(
category_slug='system',
)
register(
'PROJECT_UPDATE_VVV',
field_class=fields.BooleanField,
label=_('Run Project Updates With Higher Verbosity'),
help_text=_('Adds the CLI -vvv flag to ansible-playbook runs of project_update.yml used for project updates.'),
category=_('Jobs'),
category_slug='jobs',
)
register(
'AWX_ROLES_ENABLED',
field_class=fields.BooleanField,
@@ -430,6 +439,52 @@ register(
category_slug='jobs',
)
register(
'PRIVATE_GALAXY_URL',
field_class=fields.URLField,
label=_('Private Galaxy Server Host'),
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.'),
category=_('Jobs'),
category_slug='jobs',
)
register(
'PRIVATE_GALAXY_USERNAME',
field_class=fields.CharField,
label=_('Private Galaxy Server Username'),
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, '
'this is mutually exclusive with PRIVATE_GALAXY_TOKEN.'),
category=_('Jobs'),
category_slug='jobs',
depends_on=['PRIVATE_GALAXY_URL']
)
register(
'PRIVATE_GALAXY_PASSWORD',
field_class=fields.CharField,
label=_('Private Galaxy Server Password'),
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, '
'this is mutually exclusive with PRIVATE_GALAXY_TOKEN.'),
category=_('Jobs'),
category_slug='jobs',
depends_on=['PRIVATE_GALAXY_URL']
)
register(
'PRIVATE_GALAXY_TOKEN',
field_class=fields.CharField,
label=_('Private Galaxy Server Token'),
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, '
'this is mutually exclusive with corresponding username and password settings.'),
category=_('Jobs'),
category_slug='jobs',
depends_on=['PRIVATE_GALAXY_URL']
)
register(
'STDOUT_MAX_BYTES_DISPLAY',
field_class=fields.IntegerField,

View File

@@ -1883,6 +1883,19 @@ class RunProjectUpdate(BaseTask):
env['TMP'] = settings.AWX_PROOT_BASE_PATH
env['PROJECT_UPDATE_ID'] = str(project_update.pk)
env['ANSIBLE_CALLBACK_PLUGINS'] = self.get_path_to('..', 'plugins', 'callback')
private_galaxy_url = settings.PRIVATE_GALAXY_URL
if private_galaxy_url:
# 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_PRIVATE_GALAXY_URL'] = private_galaxy_url
for key in ('url', 'username', 'password', 'token'):
setting_name = 'PRIVATE_GALAXY_{}'.format(key.upper())
value = getattr(settings, setting_name)
if value:
env_key = 'ANSIBLE_GALAXY_SERVER_PRIVATE_GALAXY_{}'.format(key.upper())
env[env_key] = value
# now set the precedence
env['ANSIBLE_GALAXY_SERVER_LIST'] = 'private_galaxy,galaxy'
return env
def _build_scm_url_extra_vars(self, project_update):

View File

@@ -609,6 +609,9 @@ AWX_REBUILD_SMART_MEMBERSHIP = False
# By default, allow arbitrary Jinja templating in extra_vars defined on a Job Template
ALLOW_JINJA_IN_EXTRA_VARS = 'template'
# Run project updates with extra verbosity
PROJECT_UPDATE_VVV = False
# Enable dynamically pulling roles from a requirement.yml file
# when updating SCM projects
# Note: This setting may be overridden by database settings.
@@ -619,6 +622,12 @@ AWX_ROLES_ENABLED = True
# Note: This setting may be overridden by database settings.
AWX_COLLECTIONS_ENABLED = True
# Settings for private galaxy server, should be set in the UI
PRIVATE_GALAXY_URL = None
PRIVATE_GALAXY_USERNAME = None
PRIVATE_GALAXY_TOKEN = None
PRIVATE_GALAXY_PASSWORD = None
# Enable bubblewrap support for running jobs (playbook runs only).
# Note: This setting may be overridden by database settings.
AWX_PROOT_ENABLED = True

View File

@@ -58,12 +58,19 @@ export default ['i18n', function(i18n) {
type: 'text',
reset: 'ANSIBLE_FACT_CACHE_TIMEOUT',
},
PROJECT_UPDATE_VVV: {
type: 'toggleSwitch',
},
AWX_ROLES_ENABLED: {
type: 'toggleSwitch',
},
AWX_COLLECTIONS_ENABLED: {
type: 'toggleSwitch',
},
PRIVATE_GALAXY_URL: {
type: 'text',
reset: 'PRIVATE_GALAXY_URL',
},
AWX_TASK_ENV: {
type: 'textarea',
reset: 'AWX_TASK_ENV',