start nginx service报错

来源:3-7 Ansible playbooks常用模块案例操作

慕码人4277038

2022-07-10

[deploy@MiWiFi-RA72-srv test_playbooks]$ ansible-playbook -i inventory/testenv ./deploy.yml

PLAY [testservers] ********************************************************************************************************************

TASK [Gathering Facts] ****************************************************************************************************************
ok: [test.example.com]

TASK [print server name and user to remmove testbox] **********************************************************************************
changed: [test.example.com]

TASK [testbox : create a file] ********************************************************************************************************
changed: [test.example.com]

TASK [testbox : copy a file] **********************************************************************************************************
ok: [test.example.com]

TASK [testbox : check if foo.sh exists] ***********************************************************************************************
ok: [test.example.com]

TASK [testbox : debug] ****************************************************************************************************************
ok: [test.example.com] => {
“msg”: “foo.sh exists”
}

TASK [testbox : run the script] *******************************************************************************************************
changed: [test.example.com]

TASK [testbox : write the nginx config file] ******************************************************************************************
ok: [test.example.com]

TASK [testbox : ensure nginx is at the latest version] ********************************************************************************
changed: [test.example.com]

TASK [testbox : start nginx service] **************************************************************************************************
fatal: [test.example.com]: FAILED! => {“changed”: false, “msg”: “Unable to start service nginx: Job for nginx.service failed because the control process exited with error code. See “systemctl status nginx.service” and “journalctl -xe” for details.\n”}

PLAY RECAP ****************************************************************************************************************************
test.example.com : ok=9 changed=4 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

[deploy@MiWiFi-RA72-srv test_playbooks]$ vi inventory/testenv
[deploy@MiWiFi-RA72-srv test_playbooks]$ vi roles/testbox/tasks/main.yml
[deploy@MiWiFi-RA72-srv test_playbooks]$ vi roles/testbox/tasks/main.yml
[deploy@MiWiFi-RA72-srv test_playbooks]$ su
密码:
[root@MiWiFi-RA72-srv test_playbooks]# yum install nginx
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile


[deploy@MiWiFi-RA72-srv test_playbooks]$ systemctl status nginx
● nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since 日 2022-07-10 13:42:34 CST; 6min ago
Docs: http://nginx.org/en/docs/
Process: 37456 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=1/FAILURE)

老师,这里看起来是没有nginx.service文件

写回答

1回答

一路向北

2022-07-12

检查一下这台机器的nginx日志,看有什么错误输出
0
0

Jenkins+Ansible+Gitlab-三剑合璧掌握自动化部署

整合三大工具解决自动化部署&持续交付问题

1290 学习 · 319 问题

查看课程