ERROR: "sudo: a password is required\n" while running playbook.

I got the following error while running the playbook for the first time. I followed the ‘Galaxy installation with Ansible’ tutorial up to running the playbook in the PostgreSQL part (Galaxy Installation with Ansible) and after running the ‘ansible-galaxy galaxy.yml’ command I got the following error:

fatal: []: FAILED! => {"ansible_facts": {}, "changed": false, "failed_modules": {"ansible.legacy.setup": {"failed": true, "module_stderr": "sudo: a password is required\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}}, "msg": "The following modules failed to execute: ansible.legacy.setup\n"}

I found that the problem was in the "sudo: a password is required\n" part. Running a sudo command before running the ‘ansible-galaxy galaxy.yml’ command gives the expected output. However, I was wondering if there is a permanent solution for this problem and why this error occurs in the first place. I made an ansible-galaxy server on Ubuntu before and never got this error.
Any help is appreciated.
Thanks in advance!

Hi @cbass – let’s keep these questions in a single topic since they are probably related. I’ll link the two for cross-reference error content, and close this one out.