-
I have a working playbook that when run in molecule-docker fails to get ansible_env.USER. When I run in verbose mode I see [Gathering Facts] runs on converge successfully and get other variables, but not USER. When I run the same playbook in my machine it gets the user. Does anyone know the reason for this difference? If so, how should I test it with molecule? If interested in checking the playbook, the code with molecule is here: staticdev/linux-workstation-playbook#316 |
Beta Was this translation helpful? Give feedback.
Replies: 0 comments 7 replies
-
@ssbarnea maybe you have an idea on this one? |
Beta Was this translation helpful? Give feedback.
-
If you have to use
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: instance
image: xxx
# image: x
pre_build_image: true
env:
USER: root
It's because the ansible connection is different. When you run playbook in real target server, the connection plugin must be When using No $ docker run --rm --entrypoint env geerlingguy/docker-debian11-ansible:latest
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=dd4d52ad805a
pip_packages=ansible cryptography
HOME=/root As we can see, no |
Beta Was this translation helpful? Give feedback.
If you have to use
{{ ansible_env.USER }}
, both work for your case."{{ ansible_facts.user_id }}"
in your role.molecule.yml
as below.It's because the ansible connection is different.
When you run playbook in real target server, the connection plugin must be
ssh
while when inmolecule
withdocker
plugin, the connection iscommunity.docker.docker
. By default, the user…