community.docker
community.docker copied to clipboard
docker transporter sets ansible_os_family to hosts value instead of undefined.
SUMMARY
When dynamically adding a host to the inventory using community.docker.docker and ansible.builtin.add_host the value of ansible_os_family is inherited from the host instead of being set to undefined
ISSUE TYPE
- Bug Report
COMPONENT NAME
community.docker.docker
ANSIBLE VERSION
ansible [core 2.17.2]
config file = /home/user/git/ansible.cfg
configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/user/git/venv/lib/python3.12/site-packages/ansible
ansible collection location = /home/user/git
executable location = /home/user/git/venv/bin/ansible
python version = 3.12.4 (main, Jun 7 2024, 06:33:07) [GCC 14.1.1 20240522] (/home/user/git/venv/bin/python)
jinja version = 3.1.4
libyaml = True
COLLECTION VERSION
# /home/user/git/ansible_collections
Collection Version
---------------- -------
community.docker 3.12.0
CONFIGURATION
ANSIBLE_PIPELINING(/home/user/git/ansible.cfg) = True
BECOME_ALLOW_SAME_USER(/home/user/git/ansible.cfg) = True
CACHE_PLUGIN(/home/user/git/ansible.cfg) = ansible.builtin.jsonfile
CACHE_PLUGIN_CONNECTION(/home/user/git/ansible.cfg) = ./fact_cache
COLLECTIONS_PATHS(/home/user/git/ansible.cfg) = ['/home/user/git']
CONFIG_FILE() = /home/user/git/ansible.cfg
DEFAULT_BECOME(/home/user/git/ansible.cfg) = True
DEFAULT_FORCE_HANDLERS(/home/user/git/ansible.cfg) = True
DEFAULT_FORKS(/home/user/git/ansible.cfg) = 50
DEFAULT_GATHERING(/home/user/git/ansible.cfg) = smart
DEFAULT_LOG_PATH(/home/user/git/ansible.cfg) = /home/user/git/logs
DEFAULT_MANAGED_STR(/home/user/git/ansible.cfg) = This file is managed by ansible - local changes will be lost
DEFAULT_REMOTE_USER(/home/user/git/ansible.cfg) = root
DEFAULT_TRANSPORT(/home/user/git/ansible.cfg) = ssh
DEFAULT_VAULT_PASSWORD_FILE(/home/user/git/ansible.cfg) = /home/user/git/.vpass
DEPRECATION_WARNINGS(/home/user/git/ansible.cfg) = True
RETRY_FILES_ENABLED(/home/user/git/ansible.cfg) = False
SHOW_CUSTOM_STATS(/home/user/git/ansible.cfg) = True
SYSTEM_WARNINGS(/home/user/git/ansible.cfg) = True
USE_PERSISTENT_CONNECTIONS(/home/user/git/ansible.cfg) = True
OS / ENVIRONMENT
ArchLinux
STEPS TO REPRODUCE
Spanw a debian container and store it's name in container_name.
- name: Add container to inventory
ansible.builtin.add_host:
host: '{{ container_name }}'
ansible_connection: community.docker.docker
ansible_docker_extra_args: '-H {{ dockerhost }}'
ansible_become: false
changed_when: false
- name: Check ansible pre requirements inside container
delegate_to: '{{ container_name }}'
delegate_facts: true
ansible.builtin.import_role:
name: some_role
And the main.yml of some_role is:
- ansible.builtin.debug:
msg: >-
ansible_os_family is set to '{{ ansible_os_family|default("UNDEFINED") }}'
Note: The setup module has not yet been ran in this case, the ssh transporter in these cases results in ansible_os_family being undefined.
EXPECTED RESULTS
Debug message of ansible_os_family is set to "UNDEFINED"
ACTUAL RESULTS
ansible_os_family is set to Archlinux
The connection doesn't set any variables. If anyone is doing this, it's ansible-core.