mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
Enable innocuous but valid config for rsyslog if disabled
This commit is contained in:
parent
e740340793
commit
470159b4d7
@ -166,7 +166,7 @@ class SettingLoggingTest(GenericAPIView):
|
||||
# Error if logging is not enabled
|
||||
enabled = getattr(settings, 'LOG_AGGREGATOR_ENABLED', False)
|
||||
if not enabled:
|
||||
return Response({'error': 'Logging not enabled'}, status=status.HTTP_400_BAD_REQUEST)
|
||||
return Response({'error': 'Logging not enabled'}, status=status.HTTP_409_CONFLICT)
|
||||
|
||||
# Send test message to configured logger based on db settings
|
||||
logging.getLogger('awx').error('AWX Connection Test Message')
|
||||
@ -183,7 +183,11 @@ class SettingLoggingTest(GenericAPIView):
|
||||
else:
|
||||
# if http/https by this point, domain is reacheable
|
||||
return Response(status=status.HTTP_202_ACCEPTED)
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
|
||||
if protocol is 'udp':
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
else:
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
try:
|
||||
s.settimeout(.5)
|
||||
s.connect((hostname, int(port)))
|
||||
|
||||
@ -26,8 +26,10 @@ def construct_rsyslog_conf_template(settings=settings):
|
||||
port = parsed.port
|
||||
except ValueError:
|
||||
port = settings.LOG_AGGREGATOR_PORT
|
||||
|
||||
parts.extend([
|
||||
'$WorkDirectory /var/lib/awx/rsyslog',
|
||||
'$IncludeConfig /etc/rsyslog.d/*.conf',
|
||||
'$ModLoad imuxsock',
|
||||
'input(type="imuxsock" Socket="' + settings.LOGGING['handlers']['external_logger']['address'] + '" unlink="on")',
|
||||
'template(name="awx" type="string" string="%msg%")',
|
||||
])
|
||||
@ -63,10 +65,14 @@ def construct_rsyslog_conf_template(settings=settings):
|
||||
parts.append(
|
||||
f'action(type="omfwd" target="{host}" port="{port}" protocol="{protocol}" action.resumeRetryCount="-1" template="awx")' # noqa
|
||||
)
|
||||
parts.extend([
|
||||
'$WorkDirectory /var/lib/awx/rsyslog',
|
||||
'$IncludeConfig /etc/rsyslog.d/*.conf'
|
||||
])
|
||||
else:
|
||||
# If logging is disabled, add a valid config and discard all messages
|
||||
parts = [
|
||||
'$WorkDirectory /var/lib/awx/rsyslog',
|
||||
'$IncludeConfig /etc/rsyslog.d/*.conf',
|
||||
'*.* stop'
|
||||
f'action(type="omfwd" target="localhost" port="9000" protocol="udp")'
|
||||
]
|
||||
tmpl = '\n'.join(parts)
|
||||
return tmpl
|
||||
|
||||
|
||||
@ -123,7 +123,7 @@ ADD tools/docker-compose/entrypoint.sh /
|
||||
ADD tools/scripts/awx-python /usr/bin/awx-python
|
||||
|
||||
# Pre-create things that we need to write to
|
||||
RUN for dir in /var/lib/awx/rsyslog /var/run/tower/rsyslog /var/log/tower/ /var/lib/awx/projects /.ansible /var/log/nginx /var/lib/nginx /.local; \
|
||||
RUN for dir in /var/lib/awx/rsyslog /var/run/rsyslog /var/log/tower/ /var/lib/awx/projects /.ansible /var/log/nginx /var/lib/nginx /.local; \
|
||||
do mkdir -p $dir; chmod -R g+rwx $dir; chgrp -R root $dir; done && \
|
||||
\
|
||||
for file in /etc/passwd /etc/supervisord.conf /venv/awx/lib/python3.6/site-packages/awx.egg-link /var/run/nginx.pid; \
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user