I am trying to use a playbook with ansible.builtin.apt but I get a sudo error.
I am using a user, which is not root, that effectively uses sudo in target host.
In /etc/ansible/hosts there is the IP of host with user and password
fatal: [10.1.1.102]: FAILED! => {"changed": false, "msg": "'/usr/bin/apt-get upgrade --with-new-pkgs ' failed: E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)\nE: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?\n", "rc": 100, "stdout": "", "stdout_lines": []}
My playbook is like
name: Update all packages to their latest version
ansible.builtin.apt:
name: “*”
state: latest
I am using a user, which is not root, that effectively uses sudo in target host.
What exactly does “effectively uses sudo” mean?
You have to use “become: true” for this user, and it should be able to use unrestricted sudo.
Anything else will not work.