mnussbaum / ansible-yay

Ansible module to install AUR packages with yay
MIT License
57 stars 14 forks source link

Could not update package db: Please avoid running yay as root/sudo. #2

Closed Bouni closed 5 years ago

Bouni commented 5 years ago

Hi,

if I run the task without become:yes it stops without going any furthe, otherwise I get the error "could not update package db: Please avoid running yay as root/sudo."

If I run yay manually I get the same error if I prepend it with sudo, otherwise I get a prompt [sudo] password for <user>:

Any idea what I'm doing wrong?

Edit: This is my task:

- name: Update system
  #become: yes
  yay:
    update_cache: yes
    upgrade: yes
mnussbaum commented 5 years ago

I successfully use your task without become on a regular basis:

- yay:
    update_cache: yes
    upgrade: yes

Any chance the long delay could be yay actually installing a bunch of packages?

Bouni commented 5 years ago

Hi, I just tried to run the Ansible task again and it hangs. Then I ssh'd into the machine and run yay manually:

yay -Syu
[sudo] password for bouni:

yay found updates for two packages which took just second to download and install.

Then I thought that my sudoers config might be the problem, so I added this line to the end of my /etc/sudoers:

bouni ALL=(ALL) NOPASSWD: /usr/bin/yay

But yay still asks me for my password!?

If I run the ansible task and wait long enough, I finally get this error message:

[sudo] password for bouni: {\"msg\": \"could not update package db: sudo: timed out reading password\", \"failed\": true .....
Bouni commented 5 years ago

I finally figured out how to solve this! Because yay is a pacman wrapper, I needed to allow pacman to be run without password as well!

So my /etc/sudoers file has now this line:

bouni ALL=(ALL) NOPASSWD: /usr/bin/yay, /usr/bin/pacman