Reputation: 1145
Ansible 2.9, Linux Ubuntu 18.
I'm getting the following error with Ansible, when trying to change the status of a service with 'systemd'.
failed: [host.domain.com] (item=service_1) => {"ansible_loop_var": "item", "changed": false, "item": "service_1", "module_stderr": "Shared connection to host.domain.com closed.\r\n", "module_stdout": "\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
- name: Stop services
ansible.builtin.systemd:
name: "{{ serv }}"
state: stopped
with_servs:
- service_1
- service_2
- service_3
become: yes
/bin/systemctl * service_1*
, /bin/systemctl * service_2*
, /bin/systemctl * service_3*
Which sudo permissions are needed to run ansible.builtin.systemd? I'm trying to find out what command Ansible sends to the device to check if I gave the right permissions to the account, but no success on finding that yet (any hints?).
Upvotes: 0
Views: 672
Reputation: 15
At first change your with_servs
to loop:
ist much easier to writes playbooks with loop. Set become
as a globall var for playbook. Workaround for this can be exec. a coomand by module commands
but it's not recomennded because, in every sitatuion it will be executing this commands even when service is stopped.
Upvotes: 0