mnussbaum / ansible-yay

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

Yay can now be run from root using become_user #7

Closed LarssonOliver closed 2 years ago

LarssonOliver commented 2 years ago

Hi!

I'm not sure if you want any PRs but here goes...

What

With this PR, ansible-yay can be run using Ansible from the root user when become: true and become_user: <user> are specified.

Background

I am developing a playbook for myself that sets up an entire system from a very minimal arch install. I want this to be run from the root user as part of the script is setting up user(s) etc. In the current state, ansible-yay will run installation as sudo -u root yay ... which obviously won't work. I thus want to be able to run ansible-yay using the newly created user, example:

- yay: 
    name: "[...]"
    state: present
  become: true
  become_user: "{{ username }}"

This PR implements the change I made to solve this issue.

mnussbaum commented 2 years ago

Thanks for the contribution!