Hi
Two things, related.
Firstly, I currently run my ansible playbook with --ask-sudo-pass, otherwise as some of my tasks include:
become: yes
user: root
I get the error:
fatal: [localhost]: FAILED! => {“changed”: false, “failed”: true, “module_stderr”: “sudo: a password is required\n”, “module_stdout”: “”, “msg”: “MODULE FAILURE”}
(I am currently learning how to write Ansible playbooks, and using it to control the software installed on my local machine, which is working fine).
Secondly, if I instead use:
become: yes
user: myusername
I get:
fatal: [localhost]: FAILED! => {“changed”: false, “failed”: true, “msg”: “This command has to be run under the root user.”}
This error is in relation to a dnf, for example:
- name: install vim
dnf: name=vim state=latest
become: yes
become_user: root
Perhaps, since the flag is --ask-sudo-pass, and not “ask su pass” or “ask root pass” or something like that, my playbook is already using sudo on my account, and I just don’t realize.
But, barring that possibility, what is a better way for me to do this?
Thanks very much. I searched for information regarding this before posting here, but could not find clear guidance.