I want to have a user that is only able to start/stop/restart/status a service via an Ansible playbook.
The playbook looks like this:
host: my-server
remote_user: my-user
tasks:
- name: "Start my-service"
service:
name: my-service
state: started
daemon_reload: yes
become: true
I've tried using the sudoers file to restrict the privileges of my-admin
but this does not works as the command Ansible is runnning is (simplified):
sudo /bin/sh -c "python /tmp/ansible-xxxxxx.py"
Obviously, I can't allow my-admin
to run /bin/sh
as root as this would allow everything to be run as root.
What configuration should I ? What should I change ?