Hi - I'm new to Ansible and struggling
I have 2 playbooks for training/demo purposes. One to install Tree and Nano
and another to remove them again. My control and destination servers are
both Centos7
My webservers_latest.yml playbook for installing is...
---
- hosts webservers
remote_user: myuser
tasks:
- name: ensure tree is at the latest version
yum:
name: tree
state: latest
- name: ensure nano is at the latest version
yum:
name: nano
state: latest
This works absolutely fine. when run with ansible-playbook
webservers_latest.yml I am asked for sudo password and it completes OK.
However when I try to run this webservers_*absent*.yml playbook to remove
tree and nano....
---
- hosts webservers
remote_user: myuser
tasks:
- name: ensure tree is absent
yum:
name: tree
state: *absent*
- name: ensure nano is absent
yum:
name: nano
state: *absent*
I get
failed: [*myuser@ipaddress*] => {"changed": false, "failed": true, "rc": 1,
"results": ["Loaded plugins: fastestmirros\n"]}
msg: You need to be root to perform this command.
FATAL: all hosts have already failed -- aborting
I can perform the sudo yum remove nano tree manually on the destination
host without problem. I have tried all sorts of combinations of sudo_user:
myuser, sudo: yes etc but I get the same result. What, presumably, obvious
thing am I missing here?
Thanks
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/8003abcf-d3a9-471e-9369-18f2d1bb8c14%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.