Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker transporter sets ansible_os_family to hosts value instead of undefined. #951

Open
agowa opened this issue Aug 10, 2024 · 1 comment
Labels
docker-plain plain Docker (no swarm, no compose, no stack) not-a-bug This is not a bug, but a problem with the user's environment, a wrong usage, or intended behavior question Further information is requested

Comments

@agowa
Copy link

agowa commented Aug 10, 2024

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

@felixfontein
Copy link
Collaborator

The connection doesn't set any variables. If anyone is doing this, it's ansible-core.

@felixfontein felixfontein added question Further information is requested docker-plain plain Docker (no swarm, no compose, no stack) not-a-bug This is not a bug, but a problem with the user's environment, a wrong usage, or intended behavior labels Aug 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docker-plain plain Docker (no swarm, no compose, no stack) not-a-bug This is not a bug, but a problem with the user's environment, a wrong usage, or intended behavior question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants