mirror of
https://github.com/ansible/awx.git
synced 2026-01-10 15:32:07 -03:30
Added support for defining additional environment variables in settings to pass to the subprocess launched by the celery task, specify HOME and USER in settings by default instead of supervisord configuration.
This commit is contained in:
parent
82a9572df8
commit
c5f2f2bfaf
@ -103,3 +103,7 @@ LOGGING['handlers']['syslog'] = {
|
||||
# 'filename': os.path.join(BASE_DIR, 'awx.log'),
|
||||
# 'formatter': 'simple',
|
||||
#}
|
||||
|
||||
# Define additional environment variables to be passed to subprocess started by
|
||||
# the celery task.
|
||||
#AWX_TASK_ENV['FOO'] = 'BAR'
|
||||
|
||||
@ -84,18 +84,21 @@ class RunJob(Task):
|
||||
env = dict(os.environ.items())
|
||||
# question: when running over CLI, generate a random ID or grab next, etc?
|
||||
# answer: TBD
|
||||
# Add ANSIBLE_* settings to the subprocess environment.
|
||||
for attr in dir(settings):
|
||||
if attr == attr.upper() and attr.startswith('ANSIBLE_'):
|
||||
env[attr] = str(getattr(settings, attr))
|
||||
# Also set environment variables configured in AWX_TASK_ENV setting.
|
||||
for key, value in settings.AWX_TASK_ENV.items():
|
||||
env[key] = str(value)
|
||||
# Set environment variables needed for inventory and job event
|
||||
# callbacks to work.
|
||||
env['JOB_ID'] = str(job.pk)
|
||||
env['INVENTORY_ID'] = str(job.inventory.pk)
|
||||
env['ANSIBLE_CALLBACK_PLUGINS'] = plugin_dir
|
||||
if hasattr(settings, 'ANSIBLE_TRANSPORT'):
|
||||
env['ANSIBLE_TRANSPORT'] = getattr(settings, 'ANSIBLE_TRANSPORT')
|
||||
env['ANSIBLE_NOCOLOR'] = '1' # Prevent output of escape sequences.
|
||||
env['REST_API_URL'] = settings.INTERNAL_API_URL
|
||||
env['REST_API_TOKEN'] = job.task_auth_token or ''
|
||||
env['ANSIBLE_NOCOLOR'] = '1' # Prevent output of escape sequences.
|
||||
# do not want AWX to ask interactive questions and want it to be friendly with reprovisioning
|
||||
env['ANSIBLE_HOST_KEY_CHECKING'] = 'False'
|
||||
# RHEL has too old of an SSH so ansible will select paramiko and this is VERY slow
|
||||
env['ANSIBLE_PARAMIKO_RECORD_HOST_KEYS'] = 'False'
|
||||
return env
|
||||
|
||||
def build_args(self, job, **kwargs):
|
||||
|
||||
@ -245,6 +245,21 @@ CELERYD_TASK_SOFT_TIME_LIMIT = 3540
|
||||
CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler'
|
||||
CELERYBEAT_MAX_LOOP_INTERVAL = 60
|
||||
|
||||
# Any ANSIBLE_* settings will be passed to the subprocess environment by the
|
||||
# celery task.
|
||||
|
||||
# Do not want AWX to ask interactive questions and want it to be friendly with
|
||||
# reprovisioning
|
||||
ANSIBLE_HOST_KEY_CHECKING = False
|
||||
|
||||
# RHEL has too old of an SSH so ansible will select paramiko and this is VERY
|
||||
# .slow
|
||||
ANSIBLE_PARAMIKO_RECORD_HOST_KEYS = False
|
||||
|
||||
# Additional environment variables to be passed to the subprocess started by
|
||||
# the celery task.
|
||||
AWX_TASK_ENV = {}
|
||||
|
||||
if 'devserver' in INSTALLED_APPS:
|
||||
INTERNAL_API_URL = 'http://127.0.0.1:%s' % DEVSERVER_DEFAULT_PORT
|
||||
else:
|
||||
|
||||
@ -105,3 +105,7 @@ LOGGING['handlers']['syslog'] = {
|
||||
# 'filename': os.path.join(BASE_DIR, 'awx.log'),
|
||||
# 'formatter': 'simple',
|
||||
#}
|
||||
|
||||
# Define additional environment variables to be passed to subprocess started by
|
||||
# the celery task.
|
||||
#AWX_TASK_ENV['FOO'] = 'BAR'
|
||||
|
||||
@ -10,5 +10,3 @@ directory = /var/lib/awx
|
||||
log_stderr = true
|
||||
logfile_maxbytes = 50MB
|
||||
logfile_backups = 999
|
||||
environment=HOME=/var/lib/awx/,USER=awx
|
||||
|
||||
|
||||
@ -42,6 +42,9 @@ LOGGING['handlers']['syslog'] = {
|
||||
'formatter': 'simple',
|
||||
}
|
||||
|
||||
AWX_TASK_ENV['HOME'] = '/var/lib/awx'
|
||||
AWX_TASK_ENV['USER'] = 'awx'
|
||||
|
||||
SERVER_EMAIL = 'root@localhost'
|
||||
DEFAULT_FROM_EMAIL = 'webmaster@localhost'
|
||||
EMAIL_SUBJECT_PREFIX = '[AnsibleWorks] '
|
||||
|
||||
@ -42,6 +42,9 @@ LOGGING['handlers']['syslog'] = {
|
||||
'formatter': 'simple',
|
||||
}
|
||||
|
||||
AWX_TASK_ENV['HOME'] = '/var/lib/awx'
|
||||
AWX_TASK_ENV['USER'] = 'awx'
|
||||
|
||||
SERVER_EMAIL = 'root@localhost'
|
||||
DEFAULT_FROM_EMAIL = 'webmaster@localhost'
|
||||
EMAIL_SUBJECT_PREFIX = '[AnsibleWorks] '
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user