Ошибка nginx при запуске ANSIBLE PlayBook - PullRequest
0 голосов
/ 13 октября 2019

Я использую виртуальную коробку для виртуальной машины. Мой хозяин MacOS. Я запускаю команду vagrant up , все работает нормально. Но при запуске ANSIBLE PlayBook все задачи завершаются успешно, но выдает ошибку при запуске nginx

Ошибка:

RUNNING HANDLER [webtier : restart nginx] **************************************
fatal: [vagrant]: FAILED! => {"changed": false, "msg": "Unable to restart service nginx: Failed to restart nginx.service: Connection timed out\nSee system logs and 'systemctl status nginx.service' for details.\n"}

RUNNING HANDLER [webtier : reload nginx] ***************************************

RUNNING HANDLER [webtier : restart gunicorn] ***********************************

RUNNING HANDLER [webtier : restart webapp] *************************************

NO MORE HOSTS LEFT *************************************************************

PLAY RECAP *********************************************************************
vagrant                    : ok=142  changed=101  unreachable=0    failed=1    skipped=121  rescued=0    ignored=1   

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

Я выполнил vagrant ssh и смог получить файл nginx.conf с виртуальной машины vagrant, это выглядит следующим образом:

#Ansible managed
user              www-data  www-data;

worker_processes  1;

pid        /var/run/nginx.pid;

worker_rlimit_nofile 1024;

include /etc/nginx/modules-enabled/*.conf;


events {
        worker_connections 512;
}


http {

        include /etc/nginx/mime.types;
        default_type application/octet-stream;
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        server_tokens off;
        access_log "/var/log/nginx/access.log";
        error_log "/var/log/nginx/error.log" error;

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}

Моя ошибка в nginx-error.log:

2019/10/13 15:07:00 [crit] 20509#20509: *1 connect() to unix:/home/vagrant/petalandstem/run/petalandstem.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.22.1, server: api.petalandstem.local, request: "GET /favicon.ico HTTP/1.1", upstream: "http://unix:/home/vagrant/petalandstem/run/petalandstem.sock:/favicon.ico", host: "api.petalandstem.local", referrer: "http://api.petalandstem.local/"

При запуске http://api.petalandstem.local/, выдает следующую ошибку:

502 Bad Gateway
nginx

Файл nginx-access.log:

192.168.22.1 - - [13/Oct/2019:15:05:59 +0000] "GET / HTTP/1.1" 502 568 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36"

Мой файл config.d:

" ============================================================================
" Netrw Directory Listing                                        (netrw v155)
"   /etc/nginx/conf.d
"   Sorted by      name
"   Sort sequence: [\/]$,\<core\%(\.\d\+\)\=\>,\.h$,\.c$,\.cpp$,\~\=\*$,*,\.o$,\.obj$,\.info$,\.swp$,\.bak$,\~$
"   Quick Help: <F1>:help  -:go up dir  D:delete  R:rename  s:sort-by  x:special
" ==============================================================================
../
./
stream/
gzip.conf
upstream.conf   

Файл gzip:


#Ansible managed

gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 1000;
gzip_types text/plain text/html text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript image/png image/gif image/jpeg image/x-icon image/bmp;
~                                                                   

upstream.conf file

#Ansible managed

upstream petalandstem_webapp  {
     server localhost:3000;
    keepalive 64;

}
upstream petalandstem_api  {
     server unix:/home/vagrant/petalandstem/run/petalandstem.sock fail_timeout=0;

}
...