Automation HUB fail to configure symlink nginx snippets.
Environment
- Ansible Automation Platform 2.1
Issue
-
When installing Ansible Automation Platform Automation Hub, the installer fails with the following error.
TASK [pulp.pulp_installer.pulp_webserver : Symlink nginx snippets] ************* failed: [tower.hostname] (item={'changed': False, 'rc': 0, 'stdout': '\r\n/usr/lib/python3.8/site-packages/pulp_container/app/webserver_snippets/nginx.conf\r\n\x1b[0m', 'stdout_lines': ['', '/usr/lib/python3.8/site-packages/pulp_container/app/webserver_snippets/nginx.conf', '\x1b[0m'], 'stderr': 'Shared connection to tower.hostname closed.\r\n', 'stderr_lines': ['Shared connection to tower.hostname closed.'], 'failed': False, 'failed_when_result': False, '__pulp_webserver_plugin': {'key': 'pulp-container', 'value': {}}, 'ansible_loop_var': '__pulp_webserver_plugin'}) => {"__pulp_webserver_snippet": {"__pulp_webserver_plugin": {"key": "pulp-container", "value": {}}, "ansible_loop_var": "__pulp_webserver_plugin", "changed": false, "failed": false, "failed_when_result": false, "rc": 0, "stderr": "Shared connection to tower.hostname closed.\r\n", "stderr_lines": ["Shared connection to tower.hostname closed."], "stdout": "\r\n/usr/lib/python3.8/site-packages/pulp_container/app/webserver_snippets/nginx.conf\r\n\u001b[0m", "stdout_lines": ["", "/usr/lib/python3.8/site-packages/pulp_container/app/webserver_snippets/nginx.conf", "\u001b[0m"]}, "ansible_loop_var": "__pulp_webserver_snippet", "changed": false, "gid": 0, "group": "root", "mode": "0777", "msg": "Error while replacing: [Errno 2] No such file or directory: b'' -> b'/etc/nginx/pulp/.456598.1641839344.5096357.tmp'", "owner": "root", "path": "/etc/nginx/pulp/pulp_container.conf", "secontext": "unconfined_u:object_r:httpd_config_t:s0", "size": 81, "state": "link", "uid": 0} failed: [tower.hostname] (item={'changed': False, 'rc': 0, 'stdout': '\r\n/usr/lib/python3.8/site-packages/pulp_ansible/app/webserver_snippets/nginx.conf\r\n\x1b[0m', 'stdout_lines': ['', '/usr/lib/python3.8/site-packages/pulp_ansible/app/webserver_snippets/nginx.conf', '\x1b[0m'], 'stderr': 'Shared connection to tower.hostname closed.\r\n', 'stderr_lines': ['Shared connection to tower.hostname closed.'], 'failed': False, 'failed_when_result': False, '__pulp_webserver_plugin': {'key': 'pulp-ansible', 'value': {}}, 'ansible_loop_var': '__pulp_webserver_plugin'}) => {"__pulp_webserver_snippet": {"__pulp_webserver_plugin": {"key": "pulp-ansible", "value": {}}, "ansible_loop_var": "__pulp_webserver_plugin", "changed": false, "failed": false, "failed_when_result": false, "rc": 0, "stderr": "Shared connection to tower.hostname closed.\r\n", "stderr_lines": ["Shared connection to tower.hostname closed."], "stdout": "\r\n/usr/lib/python3.8/site-packages/pulp_ansible/app/webserver_snippets/nginx.conf\r\n\u001b[0m", "stdout_lines": ["", "/usr/lib/python3.8/site-packages/pulp_ansible/app/webserver_snippets/nginx.conf", "\u001b[0m"]}, "ansible_loop_var": "__pulp_webserver_snippet", "changed": false, "msg": "Error while linking: [Errno 2] No such file or directory: b'' -> b'/etc/nginx/pulp/pulp_ansible.conf'", "path": "/etc/nginx/pulp/pulp_ansible.conf"} failed: [tower.hostname] (item={'changed': False, 'rc': 0, 'stdout': '\r\n/usr/lib/python3.8/site-packages/galaxy_ng/app/webserver_snippets/nginx.conf\r\n\x1b[0m', 'stdout_lines': ['', '/usr/lib/python3.8/site-packages/galaxy_ng/app/webserver_snippets/nginx.conf', '\x1b[0m'], 'stderr': 'Shared connection to tower.hostname closed.\r\n', 'stderr_lines': ['Shared connection to tower.hostname closed.'], 'failed': False, 'failed_when_result': False, '__pulp_webserver_plugin': {'key': 'galaxy-ng', 'value': {'collectstatic': False, 'version': '4.4.0'}}, 'ansible_loop_var': '__pulp_webserver_plugin'}) => {"__pulp_webserver_snippet": {"__pulp_webserver_plugin": {"key": "galaxy-ng", "value": {"collectstatic": false, "version": "4.4.0"}}, "ansible_loop_var": "__pulp_webserver_plugin", "changed": false, "failed": false, "failed_when_result": false, "rc": 0, "stderr": "Shared connection to tower.hostname closed.\r\n", "stderr_lines": ["Shared connection to tower.hostname closed."], "stdout": "\r\n/usr/lib/python3.8/site-packages/galaxy_ng/app/webserver_snippets/nginx.conf\r\n\u001b[0m", "stdout_lines": ["", "/usr/lib/python3.8/site-packages/galaxy_ng/app/webserver_snippets/nginx.conf", "\u001b[0m"]}, "ansible_loop_var": "__pulp_webserver_snippet", "changed": false, "gid": 0, "group": "root", "mode": "0777", "msg": "Error while replacing: [Errno 2] No such file or directory: b'' -> b'/etc/nginx/pulp/.457026.1641839345.6191723.tmp'", "owner": "root", "path": "/etc/nginx/pulp/galaxy_ng.conf", "secontext": "unconfined_u:object_r:httpd_config_t:s0", "size": 76, "state": "link", "uid": 0}
Resolution
-
To work around this issue, let us apply the following change to the file
<$INSTALER_DIR>/collections/ansible_collections/pulp/pulp_installer/roles/pulp_webserver/tasks/nginx.yml
at the taskSymlink nginx snippets
.49 - name: Symlink nginx snippets 50 file: - 51 src: "{{ __pulp_webserver_snippet.stdout_lines | first }}" <====== Remove this line + 51 src: "{{ __pulp_webserver_snippet.stdout_lines | reject('match', '^$')| first }}" <====== Include this line 52 dest: "/etc/nginx/pulp/{{ __pulp_webserver_snippet.__pulp_webserver_plugin.key | regex_replace('-', '_') }}.conf" 53 state: link 54 loop: '{{ snippets.results }}' 55 loop_control: 56 loop_var: __pulp_webserver_snippet 57 when: __pulp_webserver_snippet.rc == 0 58 notify: reload nginx
Root Cause
- The installer uses the first item from the expected array, in some cases, the array can contain an empty value as a first item that can cause this issue.
Diagnostic Steps
-
The
stdout_lines
array contains an empty value.'stdout_lines': [ '', '/usr/lib/python3.8/site-packages/pulp_container/app/webserver_snippets/nginx.conf', '\x1b[0m']
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments