geerlingguy / ansible-role-nginx

Ansible Role - Nginx

Home Page:https://galaxy.ansible.com/geerlingguy/nginx/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nginx on Arch

peterbabic opened this issue · comments

Hello.

It looks like there is a problem with this role, when managing Arch.
The role does run sometimes (I was not able to isolate 100%, usually after completely removing nginx package), but then won't run again.

TASK [geerlingguy.nginx : Ensure nginx service is running as configured.] ***************
fatal: [5.189.129.182]: FAILED! => {"changed": false, "msg": "Unable to start service nginx: Job for nginx.service failed because the control process exited with error code.\nSee \"systemctl status nginx.service\" and \"journalctl -xeu nginx.service\" for details.\n"}

The reason is that nginx won't restart with a provided nginx.conf template.

sudo systemctl restart nginx # fail
sudo journalctl -xeu nginx

The journal contains:

[emerg] 870#870: "pid" directive is duplicate in /etc/nginx/nginx.conf:4

When commenting the line 4 nginx restarts flawlessly.

pid {{ nginx_pidfile }};

The reason for this is that PID is also referenced in /usr/lib/systemd/system/nginx.service as a line:

ExecStart=/usr/bin/nginx -g 'pid /run/nginx.pid; error_log stderr;'

If I understand it correctly, there is no need for L4 in nginx.conf when managing Arch. More relevant information at https://bugs.archlinux.org/task/46500

- include_tasks: setup-Archlinux.yml
when: ansible_os_family == 'Archlinux'
# Vhost configuration.
- import_tasks: vhosts.yml
# Nginx setup.
- name: Copy nginx configuration in place.
template:
src: "{{ nginx_conf_template }}"
dest: "{{ nginx_conf_file_path }}"

The setup-Archlinux.yml is run before nginx.conf template is copied over. Should there be another Arch related task below the after "Copy" but before "Ensure running", or perhaps should there be an Arch specific template for nginx.conf file?

UPDATE:

user {{ nginx_user }};
error_log {{ nginx_error_log }};
pid {{ nginx_pidfile }};
{% block worker %}

Templating is impractical here, as L3-L4 lines are the only lines that are not inside a block, so I propose to put them in a in a jinja2 block as well as a path of least resistance. Not sure about the L1 (not in a block but no issue reported).

commented

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

commented

This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.