Interview Prep/Ansible/Vault, Privilege Escalation and Error Handling

What are common problems when becoming a non-root user?

AdvancedConceptVault, Privilege Escalation and Error Handling
Answer

When Ansible becomes an unprivileged user such as postgres, that user must be able to read the temporary module files the connecting user created. If not, you see:

Failed to set permissions on the temporary files Ansible needs to create when becoming an unprivileged user

Fixes, in order of preference:

  • Install the acl package on the target, so Ansible can use setfacl to grant access.
  • Enable pipelining (pipelining = True), so no temp file is needed. It requires requiretty disabled in sudoers.
  • As a last resort allow_world_readable_tmpfiles = true, which has security downsides.

Also remember become_user plus sudo needs a sudoers rule allowing that user, and become_flags can set -H or -i for the right environment.

All Ansible questions Roadmap: Ansible

More on Vault, Privilege Escalation and Error Handling