Issue
ansible-playbook demo_playbook.yml -i demo_ansible.ini --user=user-name --extra-vars "ansible_sudo_pass=password"
PLAY [This demo playbook] *******************************************************************************************************************************************************************
TASK [Gathering Facts] **********************************************************************************************************************************************************************
ok: [localhost]
TASK [This is to install nginx software] ****************************************************************************************************************************************************
changed: [localhost]
TASK [This is restart the nginx service] ****************************************************************************************************************************************************
fatal: [localhost]: 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 -xe\" for details.\n"}
PLAY RECAP **********************************************************************************************************************************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
systemctl status nginx.service
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2022-03-13 05:03:15 PDT; 2min 13s ago
Docs: man:nginx(8)
Process: 9296 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 9297 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
Mar 13 05:03:13 ubuntu nginx[9297]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Mar 13 05:03:13 ubuntu nginx[9297]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Mar 13 05:03:14 ubuntu nginx[9297]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Mar 13 05:03:14 ubuntu nginx[9297]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Mar 13 05:03:14 ubuntu nginx[9297]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Mar 13 05:03:14 ubuntu nginx[9297]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
Mar 13 05:03:15 ubuntu nginx[9297]: nginx: [emerg] still could not bind()
Mar 13 05:03:15 ubuntu systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Mar 13 05:03:15 ubuntu systemd[1]: nginx.service: Failed with result 'exit-code'.
Mar 13 05:03:15 ubuntu systemd[1]: Failed to start A high performance web server and a reverse proxy server.
cat /var/log/nginx/error.log
2022/03/13 05:03:12 [emerg] 9297#9297: bind() to 0.0.0.0:80 failed (98: Address already in use)
2022/03/13 05:03:12 [emerg] 9297#9297: bind() to [::]:80 failed (98: Address already in use)
2022/03/13 05:03:12 [emerg] 9297#9297: bind() to 0.0.0.0:80 failed (98: Address already in use)
2022/03/13 05:03:12 [emerg] 9297#9297: bind() to [::]:80 failed (98: Address already in use)
2022/03/13 05:03:12 [emerg] 9297#9297: bind() to 0.0.0.0:80 failed (98: Address already in use)
2022/03/13 05:03:12 [emerg] 9297#9297: bind() to [::]:80 failed (98: Address already in use)
2022/03/13 05:03:12 [emerg] 9297#9297: bind() to 0.0.0.0:80 failed (98: Address already in use)
2022/03/13 05:03:12 [emerg] 9297#9297: bind() to [::]:80 failed (98: Address already in use)
2022/03/13 05:03:12 [emerg] 9297#9297: bind() to 0.0.0.0:80 failed (98: Address already in use)
2022/03/13 05:03:12 [emerg] 9297#9297: bind() to [::]:80 failed (98: Address already in use)
2022/03/13 05:03:12 [emerg] 9297#9297: still could not bind()
Troubleshoot
vim /etc/nginx/sites-enabled/default
server {
listen 80 default_server;
listen [::]:80 default_server;
#change to
server {
listen 5601 default_server;
listen [::]:5601 default_server;