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