I'm testing some Ansible deployment and need to add ansible user to sudoers. Instead of editing I just every time copy this script:
echo 'ansible ALL=(ALL) NOPASSWD: ALL' | sudo EDITOR='tee -a' visudo
Which is adds ansible ALL=(ALL) NOPASSWD: ALL
to the end of file.
How to add it after root line to make it like this via script?
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
ansible ALL=(ALL) NOPASSWD: ALL