how to use ansible to restart an apache2 server on ubuntu 20.04, if by remotely you can only access it with a specific user before you can login as root or do a sudo command to restart the apache2 or other services?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hello,
You can add
become: true
to define that tasks should be executed with privilege escalation (sudo) by default.Can you share your playbook here?
For more information I could also suggest this step-by-step tutorial here:
https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-20-04
Best,
Bobby