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

New warning about connection plugin #307

Closed
AlanCoding opened this issue Mar 16, 2022 · 2 comments · Fixed by #297
Closed

New warning about connection plugin #307

AlanCoding opened this issue Mar 16, 2022 · 2 comments · Fixed by #297
Labels
bug Something isn't working docker-plain plain Docker (no swarm, no compose, no stack)

Comments

@AlanCoding
Copy link

SUMMARY

Using Ansible core devel branch, I see a warning:

[WARNING]: The "community.docker.docker" connection plugin has an improperly configured remote target value, forcing "inventory_hostname" templated value instead of the string

This issues proposes to fix whatever this message is advising to fix.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

plugins/connection/docker.py

ANSIBLE VERSION
$ ansible --version
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or
trying out features under development. This is a rapidly changing source of code and can become unstable at any point.
ansible [core 2.13.0.dev0] (devel 27923aad7e) last updated 2022/03/08 09:03:09 (GMT -400)
  config file = /home/alancoding/repos/playbooks/ansible.cfg
  configured module search path = ['/home/alancoding/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/alancoding/repos/ansible/lib/ansible
  ansible collection location = /home/alancoding/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/alancoding/repos/awx/env/bin/ansible
  python version = 3.10.1 (main, Jan 10 2022, 00:00:00) [GCC 11.2.1 20211203 (Red Hat 11.2.1-7)]
  jinja version = 3.0.3
  libyaml = True
COLLECTION VERSION
$ ansible-galaxy collection list
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or
trying out features under development. This is a rapidly changing source of code and can become unstable at any point.

# /home/alancoding/.ansible/collections/ansible_collections
Collection                      Version
------------------------------- -------
ansible_runner.display_callback 1.0.0  
awx.awx                         19.4.0 
cloud.common                    2.0.3  
community.docker                2.2.1  
community.kubernetes            2.0.0  
containers.podman               1.9.1  
kubernetes.core                 2.0.2  
openstack.cloud                 1.7.0  

# /usr/share/ansible/collections/ansible_collections
Collection Version
---------- -------
awx.awx    19.4.1 
CONFIGURATION

defaults

OS / ENVIRONMENT

Fedora host machine, CentOS stream derived target containers.

STEPS TO REPRODUCE

My inventory looks like this:

$ ansible-inventory ~/repos/tower-qa/playbooks/inventory-docker.py --list --export
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or
trying out features under development. This is a rapidly changing source of code and can become unstable at any point.
{
    "_meta": {
        "hostvars": {
            "127.0.0.1": {
                "ansible_connection": "local",
                "ansible_python_interpreter": "/home/alancoding/repos/awx/env/bin/python3"
            },
            "tools_awx_1": {
                "ansible_connection": "community.docker.docker",
                "ansible_user": "0"
            }
        }
    },
    "all": {
        "children": [
            "automationcontroller",
            "execution_nodes",
            "local",
            "sso",
            "tower",
            "ungrouped"
        ]
    },
    "automationcontroller": {
        "hosts": [
            "tools_awx_1"
        ]
    },
    "local": {
        "hosts": [
            "127.0.0.1"
        ]
    },
    "tower": {
        "hosts": [
            "tools_awx_1"
        ]
    }
}

No warnings are raised parsing the inventory.

Let's run a playbook that does work against those containers. I'm running https://github.com/AlanCoding/playbooks/blob/devel/image_distribute.yml

ansible-playbook image_distribute.yml --tags list

(ultimately, you'll get the same result with any comand: task, the problem appears to be in the hostvars as the connection plugin gets used)

EXPECTED RESULTS

Works with no warnings

ACTUAL RESULTS

Works but has warnings

TASK [Get the images on the system, double-check your work] **********************************************************************************************
[WARNING]: The "community.docker.docker" connection plugin has an improperly configured remote target value, forcing "inventory_hostname" templated value
instead of the string
changed: [tools_awx_1]

This warning comes from

https://github.com/ansible/ansible/blob/56edbd2bbb372a61dae2017923f1d8e33d1922d9/lib/ansible/playbook/play_context.py#L300-L305

Introduced in ansible/ansible#77005

The Ansible issue ansible/ansible#77001 gives a little bit more description of the problem. Mentioned in that issue:

I suspect i messed up the default play_context.remote_addr and the docker connection plugin is still using that instead of 'get_option'. That we get the error as module output makes no sense.

It is true, this collection sets this option:

remote_addr:
description:
- The name of the container you want to access.
default: inventory_hostname
vars:
- name: ansible_host
- name: ansible_docker_host

@felixfontein
Copy link
Collaborator

resolved_by_pr #297

@felixfontein felixfontein added bug Something isn't working docker-plain plain Docker (no swarm, no compose, no stack) labels Mar 16, 2022
@felixfontein
Copy link
Collaborator

This also applies to the docker_api connection plugin. That's fixed in #308.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working docker-plain plain Docker (no swarm, no compose, no stack)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants