<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><span></span></div><div><meta http-equiv="Content-Type" content="text/html charset=utf-8"><meta http-equiv="Content-Type" content="text/html charset=utf-8">Hi all,<div class=""><br class=""></div><div class="">I’ve met with a rather unpleasant behaviour of nginx validation process (the one triggered by '-t’ command line option): it creates a pid file at the path from the configuration it validate, and leave this file alone.</div><div class=""><br class=""></div><div class="">It sounds rather inoffensively until you step in a RHEL7 with SELinux and wanted to use Ansible role for installing nginx there.</div><div class=""><br class=""></div><div class="">If you call ‘nginx -t -c /etc/nginx/nginx.conf’, then it creates a pid file with wrong SELinux context and the presence of this pid file breaks the next call to '<font color="#333333" face="Consolas, Liberation Mono, Menlo, Courier, monospace" class="">systemctl start nginx’. </font>Which while failing to start nginx service, removes the pid file. So next calls to ‘systemctl start nginx’ will succeed.</div><div class=""><br class=""></div><div class="">Here is the proof log:</div><div class=""><br class=""></div><div class=""><pre style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; margin-top: 0px; line-height: 1.45; padding: 16px; background-color: rgb(247, 247, 247); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-wrap: normal; color: rgb(51, 51, 51); margin-bottom: 0px !important;" class=""><code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; padding: 0px; margin: 0px; background-color: transparent; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal; border: 0px; display: inline; line-height: inherit; word-wrap: normal;" class="">[root@SRV2-ELOG-VM58 ~]# ls -Z /run/nginx.pid
ls: cannot access /run/nginx.pid: No such file or directory
[root@SRV2-ELOG-VM58 ~]# systemctl start nginx
[root@SRV2-ELOG-VM58 ~]# ls -Z /run/nginx.pid
-rw-r--r--. root root system_u:object_r:httpd_var_run_t:s0 /run/nginx.pid
[root@SRV2-ELOG-VM58 ~]# systemctl stop nginx
[root@SRV2-ELOG-VM58 ~]# ls -Z /run/nginx.pid
ls: cannot access /run/nginx.pid: No such file or directory
[root@SRV2-ELOG-VM58 ~]# /usr/sbin/nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@SRV2-ELOG-VM58 ~]# ls -Z /run/nginx.pid
-rw-r--r--. root root unconfined_u:object_r:var_run_t:s0 /run/nginx.pid
[root@SRV2-ELOG-VM58 ~]# systemctl start nginx
Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details.
[root@SRV2-ELOG-VM58 ~]# ls -Z /run/nginx.pid
ls: cannot access /run/nginx.pid: No such file or directory
[root@SRV2-ELOG-VM58 ~]# systemctl start nginx
[root@SRV2-ELOG-VM58 ~]# ls -Z /run/nginx.pid
-rw-r--r--. root root system_u:object_r:httpd_var_run_t:s0 /run/nginx.pid
[root@SRV2-ELOG-VM58 ~]#</code></pre><div class=""><br class=""></div><div class="">Is there a way to ask nginx to remove the pid file it created during the validation process or not to create it at all?</div><div class=""><br class=""></div><div class="">Some additional info is here: <a href="https://github.com/geerlingguy/ansible-role-nginx/issues/41" class="">https://github.com/geerlingguy/ansible-role-nginx/issues/41</a></div></div><div class=""><br class=""></div><div class="">With all the best,</div><div class="">Alex Vinokurov</div></div></body></html>