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

"'ansible connection' is undefined." when templating conditionals in meta tasks. #82793

Open
1 task done
DMNh opened this issue Mar 7, 2024 · 3 comments
Open
1 task done
Labels
affects_2.16 bug This issue/PR relates to a bug. docs This issue/PR relates to or includes documentation. module This issue/PR relates to a module.

Comments

@DMNh
Copy link

DMNh commented Mar 7, 2024

Summary

When using the ansible.builtin.meta module with a when: condition which includes the ansible_connection variable, Ansible fails to evaluate the conditional, instead reporting that "'ansible_connection' is undefined".

The debug module shows that the variable is defined and other modules do not seem to have the same problem.

Issue Type

Bug Report

Component Name

meta

Ansible Version

$ ansible --version
ansible [core 2.16.3]
  config file = None
  configured module search path = ['/home/dmn/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.11/site-packages/ansible
  ansible collection location = /home/dmn/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.11.7 (main, Jan 29 2024, 16:03:57) [GCC 13.2.1 20230801] (/usr/bin/python)
  jinja version = 3.1.3
  libyaml = True

Configuration

# if using a version older than ansible-core 2.12 you should omit the '-t all'
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
EDITOR(env: EDITOR) = vim

OS / Environment

Arch Linux
Linux 6.7.6-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 23 Feb 2024 16:31:48 +0000 x86_64 GNU/Linux

Steps to Reproduce

Configure a minimal test host with Python 3 and SSH. I tested against a Debian 12 container.

Then run the following playbook:

---

- hosts:
    - 172.17.0.3
  tasks:
    - name: "Debug"
      ansible.builtin.debug:
        var: "ansible_connection"
      when:
        - "ansible_connection != 'docker'"

    - name: "Meta task"
      ansible.builtin.meta: end_play
      when:
        - "ansible_connection != 'docker'"

With:

ansible-playbook -i "172.17.0.3," -e 'ansible_user=root' ./test.yml

Replacing the IP as necessary. Note that the example uses the end_play command with ansible.builtin.meta, but the other commands exhibit the same behaviour.

Expected Results

The conditional is evaluated correctly and the value of ansible_connection is tested.

Actual Results

ansible-playbook [core 2.16.3]
  config file = None
  configured module search path = ['/home/dmn/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.11/site-packages/ansible
  ansible collection location = /home/dmn/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible-playbook
  python version = 3.11.7 (main, Jan 29 2024, 16:03:57) [GCC 13.2.1 20230801] (/usr/bin/python)
  jinja version = 3.1.3
  libyaml = True
No config file found; using defaults
setting up inventory plugins
Loading collection ansible.builtin from
Parsed 172.17.0.3, inventory source with host_list plugin
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python3.11/site-packages/ansible/plugins/callback/default.py
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: test.yml ***********************************************************************
Positional arguments: ./test.yml
verbosity: 4
connection: ssh
become_method: sudo
tags: ('all',)
inventory: ('172.17.0.3,',)
extra_vars: ('ansible_user=root',)
forks: 5
1 plays in ./test.yml

PLAY [172.17.0.3] ************************************************************************

TASK [Gathering Facts] *******************************************************************
task path: /tmp/tmp.yJxXPtD5N4/test.yml:3
<172.17.0.3> ESTABLISH SSH CONNECTION FOR USER: root
<172.17.0.3> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o 'ControlPath="/home/dmn/.ansible/cp/499371f37a"' 172.17.0.3 '/bin/sh -c '"'"'echo ~root && sleep 0'"'"''
<172.17.0.3> (0, b'/root\n', b"OpenSSH_9.6p1, OpenSSL 3.2.1 30 Jan 2024\r\ndebug1: Reading configuration data /home/dmn/.ssh/config\r\ndebug1: /home/dmn/.ssh/config line 51: Applying options for 172.17.0.*\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 2: include /etc/ssh/ssh_config.d/*.conf matched no files\r\ndebug2: resolve_canonicalize: hostname 172.17.0.3 is address\r\ndebug1: hostname canonicalisation enabled, will re-parse configuration\r\ndebug1: re-parsing configuration\r\ndebug1: Reading configuration data /home/dmn/.ssh/config\r\ndebug1: /home/dmn/.ssh/config line 51: Applying options for 172.17.0.*\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 2: include /etc/ssh/ssh_config.d/*.conf matched no files\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/dmn/.ssh/known_hosts'\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/dmn/.ssh/known_hosts2'\r\ndebug1: auto-mux: Trying existing master at '/home/dmn/.ansible/cp/499371f37a'\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 703710\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet_timeout: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n")
<172.17.0.3> ESTABLISH SSH CONNECTION FOR USER: root
<172.17.0.3> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o 'ControlPath="/home/dmn/.ansible/cp/499371f37a"' 172.17.0.3 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir "` echo /root/.ansible/tmp/ansible-tmp-1709819051.1516669-704634-205607261149334 `" && echo ansible-tmp-1709819051.1516669-704634-205607261149334="` echo /root/.ansible/tmp/ansible-tmp-1709819051.1516669-704634-205607261149334 `" ) && sleep 0'"'"''
<172.17.0.3> (0, b'ansible-tmp-1709819051.1516669-704634-205607261149334=/root/.ansible/tmp/ansible-tmp-1709819051.1516669-704634-205607261149334\n', b"OpenSSH_9.6p1, OpenSSL 3.2.1 30 Jan 2024\r\ndebug1: Reading configuration data /home/dmn/.ssh/config\r\ndebug1: /home/dmn/.ssh/config line 51: Applying options for 172.17.0.*\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 2: include /etc/ssh/ssh_config.d/*.conf matched no files\r\ndebug2: resolve_canonicalize: hostname 172.17.0.3 is address\r\ndebug1: hostname canonicalisation enabled, will re-parse configuration\r\ndebug1: re-parsing configuration\r\ndebug1: Reading configuration data /home/dmn/.ssh/config\r\ndebug1: /home/dmn/.ssh/config line 51: Applying options for 172.17.0.*\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 2: include /etc/ssh/ssh_config.d/*.conf matched no files\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/dmn/.ssh/known_hosts'\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/dmn/.ssh/known_hosts2'\r\ndebug1: auto-mux: Trying existing master at '/home/dmn/.ansible/cp/499371f37a'\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 703710\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet_timeout: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n")
<172.17.0.3> Attempting python interpreter discovery
<172.17.0.3> ESTABLISH SSH CONNECTION FOR USER: root
<172.17.0.3> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o 'ControlPath="/home/dmn/.ansible/cp/499371f37a"' 172.17.0.3 '/bin/sh -c '"'"'echo PLATFORM; uname; echo FOUND; command -v '"'"'"'"'"'"'"'"'python3.12'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python3.11'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python3.10'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python3.9'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python3.8'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python3.7'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python3.6'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'/usr/bin/python3'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'/usr/libexec/platform-python'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python2.7'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'/usr/bin/python'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python'"'"'"'"'"'"'"'"'; echo ENDFOUND && sleep 0'"'"''
<172.17.0.3> (0, b'PLATFORM\nLinux\nFOUND\n/usr/bin/python3.11\n/usr/bin/python3\nENDFOUND\n', b"OpenSSH_9.6p1, OpenSSL 3.2.1 30 Jan 2024\r\ndebug1: Reading configuration data /home/dmn/.ssh/config\r\ndebug1: /home/dmn/.ssh/config line 51: Applying options for 172.17.0.*\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 2: include /etc/ssh/ssh_config.d/*.conf matched no files\r\ndebug2: resolve_canonicalize: hostname 172.17.0.3 is address\r\ndebug1: hostname canonicalisation enabled, will re-parse configuration\r\ndebug1: re-parsing configuration\r\ndebug1: Reading configuration data /home/dmn/.ssh/config\r\ndebug1: /home/dmn/.ssh/config line 51: Applying options for 172.17.0.*\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 2: include /etc/ssh/ssh_config.d/*.conf matched no files\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/dmn/.ssh/known_hosts'\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/dmn/.ssh/known_hosts2'\r\ndebug1: auto-mux: Trying existing master at '/home/dmn/.ansible/cp/499371f37a'\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 703710\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet_timeout: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n")
<172.17.0.3> ESTABLISH SSH CONNECTION FOR USER: root
<172.17.0.3> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o 'ControlPath="/home/dmn/.ansible/cp/499371f37a"' 172.17.0.3 '/bin/sh -c '"'"'/usr/bin/python3.11 && sleep 0'"'"''
<172.17.0.3> (0, b'{"platform_dist_result": [], "osrelease_content": "PRETTY_NAME=\\"Debian GNU/Linux 12 (bookworm)\\"\\nNAME=\\"Debian GNU/Linux\\"\\nVERSION_ID=\\"12\\"\\nVERSION=\\"12 (bookworm)\\"\\nVERSION_CODENAME=bookworm\\nID=debian\\nHOME_URL=\\"https://www.debian.org/\\"\\nSUPPORT_URL=\\"https://www.debian.org/support\\"\\nBUG_REPORT_URL=\\"https://bugs.debian.org/\\"\\n"}\n', b"OpenSSH_9.6p1, OpenSSL 3.2.1 30 Jan 2024\r\ndebug1: Reading configuration data /home/dmn/.ssh/config\r\ndebug1: /home/dmn/.ssh/config line 51: Applying options for 172.17.0.*\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 2: include /etc/ssh/ssh_config.d/*.conf matched no files\r\ndebug2: resolve_canonicalize: hostname 172.17.0.3 is address\r\ndebug1: hostname canonicalisation enabled, will re-parse configuration\r\ndebug1: re-parsing configuration\r\ndebug1: Reading configuration data /home/dmn/.ssh/config\r\ndebug1: /home/dmn/.ssh/config line 51: Applying options for 172.17.0.*\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 2: include /etc/ssh/ssh_config.d/*.conf matched no files\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/dmn/.ssh/known_hosts'\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/dmn/.ssh/known_hosts2'\r\ndebug1: auto-mux: Trying existing master at '/home/dmn/.ansible/cp/499371f37a'\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 703710\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet_timeout: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n")
Using module file /usr/lib/python3.11/site-packages/ansible/modules/setup.py
<172.17.0.3> PUT /home/dmn/.ansible/tmp/ansible-local-704631krqkqxg9/tmplpgayege TO /root/.ansible/tmp/ansible-tmp-1709819051.1516669-704634-205607261149334/AnsiballZ_setup.py
<172.17.0.3> SSH: EXEC sftp -b - -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o 'ControlPath="/home/dmn/.ansible/cp/499371f37a"' '[172.17.0.3]'
<172.17.0.3> (0, b'sftp> put /home/dmn/.ansible/tmp/ansible-local-704631krqkqxg9/tmplpgayege /root/.ansible/tmp/ansible-tmp-1709819051.1516669-704634-205607261149334/AnsiballZ_setup.py\n', b'OpenSSH_9.6p1, OpenSSL 3.2.1 30 Jan 2024\r\ndebug1: Reading configuration data /home/dmn/.ssh/config\r\ndebug1: /home/dmn/.ssh/config line 51: Applying options for 172.17.0.*\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 2: include /etc/ssh/ssh_config.d/*.conf matched no files\r\ndebug2: resolve_canonicalize: hostname 172.17.0.3 is address\r\ndebug1: hostname canonicalisation enabled, will re-parse configuration\r\ndebug1: re-parsing configuration\r\ndebug1: Reading configuration data /home/dmn/.ssh/config\r\ndebug1: /home/dmn/.ssh/config line 51: Applying options for 172.17.0.*\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 2: include /etc/ssh/ssh_config.d/*.conf matched no files\r\ndebug3: expanded UserKnownHostsFile \'~/.ssh/known_hosts\' -> \'/home/dmn/.ssh/known_hosts\'\r\ndebug3: expanded UserKnownHostsFile \'~/.ssh/known_hosts2\' -> \'/home/dmn/.ssh/known_hosts2\'\r\ndebug1: auto-mux: Trying existing master at \'/home/dmn/.ansible/cp/499371f37a\'\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 703710\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug2: Remote version: 3\r\ndebug2: Server supports extension "posix-rename@openssh.com" revision 1\r\ndebug2: Server supports extension "statvfs@openssh.com" revision 2\r\ndebug2: Server supports extension "fstatvfs@openssh.com" revision 2\r\ndebug2: Server supports extension "hardlink@openssh.com" revision 1\r\ndebug2: Server supports extension "fsync@openssh.com" revision 1\r\ndebug2: Server supports extension "lsetstat@openssh.com" revision 1\r\ndebug2: Server supports extension "limits@openssh.com" revision 1\r\ndebug2: Server supports extension "expand-path@openssh.com" revision 1\r\ndebug2: Server supports extension "copy-data" revision 1\r\ndebug2: Unrecognised server extension "home-directory"\r\ndebug2: Server supports extension "users-groups-by-id@openssh.com" revision 1\r\ndebug3: Sent message limits@openssh.com I:1\r\ndebug3: Received limits reply T:201 I:1\r\ndebug3: server upload/download buffer sizes 261120 / 261120; using 261120 / 261120\r\ndebug3: server handle limit 1019; using 64\r\ndebug2: Sending SSH2_FXP_REALPATH "."\r\ndebug3: Sent message fd 3 T:16 I:2\r\ndebug3: SSH2_FXP_REALPATH . -> /root\r\ndebug3: Looking up /home/dmn/.ansible/tmp/ansible-local-704631krqkqxg9/tmplpgayege\r\ndebug2: Sending SSH2_FXP_STAT "/root/.ansible/tmp/ansible-tmp-1709819051.1516669-704634-205607261149334/AnsiballZ_setup.py"\r\ndebug3: Sent message fd 3 T:17 I:3\r\ndebug1: stat remote: No such file or directory\r\ndebug2: sftp_upload: upload local "/home/dmn/.ansible/tmp/ansible-local-704631krqkqxg9/tmplpgayege" to remote "/root/.ansible/tmp/ansible-tmp-1709819051.1516669-704634-205607261149334/AnsiballZ_setup.py"\r\ndebug2: Sending SSH2_FXP_OPEN "/root/.ansible/tmp/ansible-tmp-1709819051.1516669-704634-205607261149334/AnsiballZ_setup.py"\r\ndebug3: Sent dest message SSH2_FXP_OPEN I:4 P:/root/.ansible/tmp/ansible-tmp-1709819051.1516669-704634-205607261149334/AnsiballZ_setup.py M:0x001a\r\ndebug3: Sent message SSH2_FXP_WRITE I:6 O:0 S:261120\r\ndebug3: SSH2_FXP_STATUS 0\r\ndebug3: In write loop, ack for 6 261120 bytes at 0\r\ndebug3: Sent message SSH2_FXP_WRITE I:7 O:261120 S:35145\r\ndebug3: SSH2_FXP_STATUS 0\r\ndebug3: In write loop, ack for 7 35145 bytes at 261120\r\ndebug3: Sent message SSH2_FXP_CLOSE I:5\r\ndebug3: SSH2_FXP_STATUS 0\r\ndebug3: mux_client_read_packet_timeout: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n')
<172.17.0.3> ESTABLISH SSH CONNECTION FOR USER: root
<172.17.0.3> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o 'ControlPath="/home/dmn/.ansible/cp/499371f37a"' 172.17.0.3 '/bin/sh -c '"'"'chmod u+x /root/.ansible/tmp/ansible-tmp-1709819051.1516669-704634-205607261149334/ /root/.ansible/tmp/ansible-tmp-1709819051.1516669-704634-205607261149334/AnsiballZ_setup.py && sleep 0'"'"''
<172.17.0.3> (0, b'', b"OpenSSH_9.6p1, OpenSSL 3.2.1 30 Jan 2024\r\ndebug1: Reading configuration data /home/dmn/.ssh/config\r\ndebug1: /home/dmn/.ssh/config line 51: Applying options for 172.17.0.*\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 2: include /etc/ssh/ssh_config.d/*.conf matched no files\r\ndebug2: resolve_canonicalize: hostname 172.17.0.3 is address\r\ndebug1: hostname canonicalisation enabled, will re-parse configuration\r\ndebug1: re-parsing configuration\r\ndebug1: Reading configuration data /home/dmn/.ssh/config\r\ndebug1: /home/dmn/.ssh/config line 51: Applying options for 172.17.0.*\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 2: include /etc/ssh/ssh_config.d/*.conf matched no files\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/dmn/.ssh/known_hosts'\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/dmn/.ssh/known_hosts2'\r\ndebug1: auto-mux: Trying existing master at '/home/dmn/.ansible/cp/499371f37a'\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 703710\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet_timeout: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n")
<172.17.0.3> ESTABLISH SSH CONNECTION FOR USER: root
<172.17.0.3> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o 'ControlPath="/home/dmn/.ansible/cp/499371f37a"' -tt 172.17.0.3 '/bin/sh -c '"'"'/usr/bin/python3 /root/.ansible/tmp/ansible-tmp-1709819051.1516669-704634-205607261149334/AnsiballZ_setup.py && sleep 0'"'"''
<172.17.0.3> (0, b'\r\n{"ansible_facts": {"ansible_virtualization_type": "docker", "ansible_virtualization_role": "guest", "ansible_virtualization_tech_guest": ["docker", "container"], "ansible_virtualization_tech_host": ["kvm", "virtualbox"], "ansible_ssh_host_key_rsa_public": "AAAAB3NzaC1yc2EAAAADAQABAAABgQCydyuCn8vjVhABWvqgbTR7mPekfr68aClTFIshb+XQz4hkcFg1VujN4iIxhllgSni7IFrYwiPAPele+Vhvk4BIYy1YHXMhbY8dg141cuS34a68tfzL9DWEKeUz64ERq/qo6/yks6w7l47csWVUOqQux7zeZIi5ch7m4z+2vfo9z6W6uTTfWpRaqb2gP3gY4qG548wHjn8Ru23YulcXHFHxjGsqPF/pje4w8TNKzXM4QrIt5TqJKBmp4UZr3LqHcHcyfRj0ap/Rg99tSOpsznHgG+qFtvRlFHjOL68SeT7ICdAwhBKwAVDHl+dGTIC0FyccA93ZJvXPodQX0yf3rgpkxJRxhxpqGUJk3RVmSCIgRwFVsx0gYcaFk2RisjQO3hv6DllsJKYZch1gEU0mOLRlZvZuSm7MqU6JbuhCI3fuvblFnKwU1IX+LVtkhH0wIAkhQcHk7S8AA7lVXOJuqjJlsiSpM+4zkuEwZ/zMYBCICPC5ApKKMh3/Id0SDrKewV8=", "ansible_ssh_host_key_rsa_public_keytype": "ssh-rsa", "ansible_ssh_host_key_ecdsa_public": "AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBBv73uld4+I7brs3FhV6zTReoiFvq5jIKs5qUdH96luLX5KjCd8wUEyvDnaoB6RaePOLRQ6uQYEUEvks7PVOkE0=", "ansible_ssh_host_key_ecdsa_public_keytype": "ecdsa-sha2-nistp256", "ansible_ssh_host_key_ed25519_public": "AAAAC3NzaC1lZDI1NTE5AAAAIJEAQrzyJZBxAUorrWkuiXApzpmX3U2m1CQw1k9jALPA", "ansible_ssh_host_key_ed25519_public_keytype": "ssh-ed25519", "ansible_user_id": "root", "ansible_user_uid": 0, "ansible_user_gid": 0, "ansible_user_gecos": "root", "ansible_user_dir": "/root", "ansible_user_shell": "/bin/bash", "ansible_real_user_id": 0, "ansible_effective_user_id": 0, "ansible_real_group_id": 0, "ansible_effective_group_id": 0, "ansible_system": "Linux", "ansible_kernel": "6.7.6-arch1-1", "ansible_kernel_version": "#1 SMP PREEMPT_DYNAMIC Fri, 23 Feb 2024 16:31:48 +0000", "ansible_machine": "x86_64", "ansible_python_version": "3.11.2", "ansible_fqdn": "dd6bf1057105", "ansible_hostname": "dd6bf1057105", "ansible_nodename": "dd6bf1057105", "ansible_domain": "", "ansible_userspace_bits": "64", "ansible_architecture": "x86_64", "ansible_userspace_architecture": "x86_64", "ansible_machine_id": "2816098d987d498b9e77fab101506687", "ansible_distribution": "Debian", "ansible_distribution_release": "bookworm", "ansible_distribution_version": "12.4", "ansible_distribution_major_version": "12", "ansible_distribution_file_path": "/etc/os-release", "ansible_distribution_file_variety": "Debian", "ansible_distribution_file_parsed": true, "ansible_distribution_minor_version": "4", "ansible_os_family": "Debian", "ansible_is_chroot": false, "ansible_env": {"USER": "root", "SSH_CLIENT": "172.17.0.1 37392 22", "SHLVL": "0", "MOTD_SHOWN": "pam", "HOME": "/root", "SSH_TTY": "/dev/pts/1", "LOGNAME": "root", "_": "/bin/sh", "TERM": "screen-256color", "PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "SHELL": "/bin/bash", "PWD": "/root", "SSH_CONNECTION": "172.17.0.1 37392 172.17.0.3 22", "LC_CTYPE": "C.UTF-8"}, "ansible_lsb": {}, "ansible_hostnqn": "", "ansible_system_capabilities_enforced": "N/A", "ansible_system_capabilities": "N/A", "ansible_iscsi_iqn": "", "ansible_processor": ["0", "GenuineIntel", "Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz", "1", "GenuineIntel", "Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz", "2", "GenuineIntel", "Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz", "3", "GenuineIntel", "Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz", "4", "GenuineIntel", "Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz", "5", "GenuineIntel", "Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz", "6", "GenuineIntel", "Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz", "7", "GenuineIntel", "Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz"], "ansible_processor_count": 1, "ansible_processor_cores": 4, "ansible_processor_threads_per_core": 2, "ansible_processor_vcpus": 8, "ansible_processor_nproc": 8, "ansible_memtotal_mb": 15656, "ansible_memfree_mb": 566, "ansible_swaptotal_mb": 20479, "ansible_swapfree_mb": 17681, "ansible_memory_mb": {"real": {"total": 15656, "used": 15090, "free": 566}, "nocache": {"free": 4018, "used": 11638}, "swap": {"total": 20479, "free": 17681, "used": 2798, "cached": 353}}, "ansible_bios_date": "08/30/2022", "ansible_bios_vendor": "LENOVO", "ansible_bios_version": "N2WET38W (1.28 )", "ansible_board_asset_tag": "Not Available", "ansible_board_name": "20U9CTO1WW", "ansible_board_serial": "L1HF0AB03V7", "ansible_board_vendor": "LENOVO", "ansible_board_version": "SDK0J40697 WIN", "ansible_chassis_asset_tag": "No Asset Information", "ansible_chassis_serial": "PF1TPHDS", "ansible_chassis_vendor": "LENOVO", "ansible_chassis_version": "None", "ansible_form_factor": "Notebook", "ansible_product_name": "20U9CTO1WW", "ansible_product_serial": "PF1TPHDS", "ansible_product_uuid": "28fa87cc-2b8b-11b2-a85c-fd11f30284f1", "ansible_product_version": "ThinkPad X1 Carbon Gen 8", "ansible_system_vendor": "LENOVO", "ansible_devices": {"dm-1": {"virtual": 1, "links": {"ids": [], "uuids": [], "labels": [], "masters": []}, "vendor": null, "model": null, "sas_address": null, "sas_device_handle": null, "removable": "0", "support_discard": "0", "partitions": {}, "rotational": "0", "scheduler_mode": "", "sectors": "41943040", "sectorsize": "512", "size": "20.00 GB", "host": "", "holders": []}, "nvme0n1": {"virtual": 1, "links": {"ids": [], "uuids": [], "labels": [], "masters": []}, "vendor": null, "model": "WDC PC SN730 SDBQNTY-512G-1001", "sas_address": null, "sas_device_handle": null, "serial": "203654804717", "removable": "0", "support_discard": "512", "partitions": {"nvme0n1p1": {"links": {"ids": [], "uuids": [], "labels": [], "masters": []}, "start": "2048", "sectors": "532480", "sectorsize": 512, "size": "260.00 MB", "uuid": null, "holders": []}, "nvme0n1p2": {"links": {"ids": [], "uuids": [], "labels": [], "masters": ["dm-0"]}, "start": "534528", "sectors": "999680655", "sectorsize": 512, "size": "476.68 GB", "uuid": null, "holders": ["cryptlvm"]}}, "rotational": "0", "scheduler_mode": "none", "sectors": "1000215216", "sectorsize": "512", "size": "476.94 GB", "host": "", "holders": []}, "dm-2": {"virtual": 1, "links": {"ids": [], "uuids": [], "labels": [], "masters": []}, "vendor": null, "model": null, "sas_address": null, "sas_device_handle": null, "removable": "0", "support_discard": "0", "partitions": {}, "rotational": "0", "scheduler_mode": "", "sectors": "67108864", "sectorsize": "512", "size": "32.00 GB", "host": "", "holders": []}, "dm-0": {"virtual": 1, "links": {"ids": [], "uuids": [], "labels": [], "masters": ["dm-1", "dm-2", "dm-3"]}, "vendor": null, "model": null, "sas_address": null, "sas_device_handle": null, "removable": "0", "support_discard": "0", "partitions": {}, "rotational": "0", "scheduler_mode": "", "sectors": "999647887", "sectorsize": "512", "size": "476.67 GB", "host": "", "holders": ["cryptvols-swap", "cryptvols-root", "cryptvols-home"]}, "dm-3": {"virtual": 1, "links": {"ids": [], "uuids": [], "labels": [], "masters": []}, "vendor": null, "model": null, "sas_address": null, "sas_device_handle": null, "removable": "0", "support_discard": "0", "partitions": {}, "rotational": "0", "scheduler_mode": "", "sectors": "890593280", "sectorsize": "512", "size": "424.67 GB", "host": "", "holders": []}}, "ansible_device_links": {"ids": {}, "uuids": {}, "labels": {}, "masters": {"dm-0": ["dm-1", "dm-2", "dm-3"], "nvme0n1p2": ["dm-0"]}}, "ansible_uptime_seconds": 321762, "ansible_lvm": "N/A", "ansible_mounts": [{"mount": "/etc/resolv.conf", "device": "/dev/mapper/cryptvols-home", "fstype": "ext4", "options": "rw,relatime,bind", "size_total": 447676506112, "size_available": 132925648896, "block_size": 4096, "block_total": 109296022, "block_available": 32452551, "block_used": 76843471, "inode_total": 27836416, "inode_available": 23518539, "inode_used": 4317877, "uuid": "N/A"}, {"mount": "/etc/hostname", "device": "/dev/mapper/cryptvols-home", "fstype": "ext4", "options": "rw,relatime,bind", "size_total": 447676506112, "size_available": 132925648896, "block_size": 4096, "block_total": 109296022, "block_available": 32452551, "block_used": 76843471, "inode_total": 27836416, "inode_available": 23518539, "inode_used": 4317877, "uuid": "N/A"}, {"mount": "/etc/hosts", "device": "/dev/mapper/cryptvols-home", "fstype": "ext4", "options": "rw,relatime,bind", "size_total": 447676506112, "size_available": 132925648896, "block_size": 4096, "block_total": 109296022, "block_available": 32452551, "block_used": 76843471, "inode_total": 27836416, "inode_available": 23518539, "inode_used": 4317877, "uuid": "N/A"}], "ansible_selinux_python_present": true, "ansible_selinux": {"status": "disabled"}, "ansible_fibre_channel_wwn": [], "ansible_cmdline": {"BOOT_IMAGE": "/vmlinuz-linux", "root": "/dev/cryptvols/root", "rw": true, "loglevel": "3", "quiet": true, "cryptdevice": "UUID=1bf69699-2d2f-4a7c-aa47-20a4f2e39a70:cryptlvm", "resume": "/dev/cryptvols/swap"}, "ansible_proc_cmdline": {"BOOT_IMAGE": "/vmlinuz-linux", "root": ["/dev/mapper/cryptvols-root", "/dev/cryptvols/root"], "rw": true, "loglevel": "3", "quiet": true, "cryptdevice": "UUID=1bf69699-2d2f-4a7c-aa47-20a4f2e39a70:cryptlvm", "resume": "/dev/cryptvols/swap"}, "ansible_loadavg": {"1m": 1.19873046875, "5m": 0.94482421875, "15m": 0.8896484375}, "ansible_python": {"version": {"major": 3, "minor": 11, "micro": 2, "releaselevel": "final", "serial": 0}, "version_info": [3, 11, 2, "final", 0], "executable": "/usr/bin/python3", "has_sslcontext": true, "type": "cpython"}, "ansible_apparmor": {"status": "disabled"}, "ansible_dns": {"domain": "dmn.one", "nameservers": ["192.168.1.1"]}, "ansible_date_time": {"year": "2024", "month": "03", "weekday": "Thursday", "weekday_number": "4", "weeknumber": "10", "day": "07", "hour": "13", "minute": "44", "second": "11", "epoch": "1709819051", "epoch_int": "1709819051", "date": "2024-03-07", "time": "13:44:11", "iso8601_micro": "2024-03-07T13:44:11.875417Z", "iso8601": "2024-03-07T13:44:11Z", "iso8601_basic": "20240307T134411875417", "iso8601_basic_short": "20240307T134411", "tz": "UTC", "tz_dst": "UTC", "tz_offset": "+0000"}, "ansible_local": {}, "ansible_service_mgr": "systemd", "ansible_fips": false, "ansible_pkg_mgr": "apt", "gather_subset": ["all"], "module_setup": true}, "invocation": {"module_args": {"gather_subset": ["all"], "gather_timeout": 10, "filter": [], "fact_path": "/etc/ansible/facts.d"}}}\r\n', b"OpenSSH_9.6p1, OpenSSL 3.2.1 30 Jan 2024\r\ndebug1: Reading configuration data /home/dmn/.ssh/config\r\ndebug1: /home/dmn/.ssh/config line 51: Applying options for 172.17.0.*\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 2: include /etc/ssh/ssh_config.d/*.conf matched no files\r\ndebug2: resolve_canonicalize: hostname 172.17.0.3 is address\r\ndebug1: hostname canonicalisation enabled, will re-parse configuration\r\ndebug1: re-parsing configuration\r\ndebug1: Reading configuration data /home/dmn/.ssh/config\r\ndebug1: /home/dmn/.ssh/config line 51: Applying options for 172.17.0.*\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 2: include /etc/ssh/ssh_config.d/*.conf matched no files\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/dmn/.ssh/known_hosts'\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/dmn/.ssh/known_hosts2'\r\ndebug1: auto-mux: Trying existing master at '/home/dmn/.ansible/cp/499371f37a'\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 703710\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet_timeout: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to 172.17.0.3 closed.\r\n")
<172.17.0.3> ESTABLISH SSH CONNECTION FOR USER: root
<172.17.0.3> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="root"' -o ConnectTimeout=10 -o 'ControlPath="/home/dmn/.ansible/cp/499371f37a"' 172.17.0.3 '/bin/sh -c '"'"'rm -f -r /root/.ansible/tmp/ansible-tmp-1709819051.1516669-704634-205607261149334/ > /dev/null 2>&1 && sleep 0'"'"''
<172.17.0.3> (0, b'', b"OpenSSH_9.6p1, OpenSSL 3.2.1 30 Jan 2024\r\ndebug1: Reading configuration data /home/dmn/.ssh/config\r\ndebug1: /home/dmn/.ssh/config line 51: Applying options for 172.17.0.*\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 2: include /etc/ssh/ssh_config.d/*.conf matched no files\r\ndebug2: resolve_canonicalize: hostname 172.17.0.3 is address\r\ndebug1: hostname canonicalisation enabled, will re-parse configuration\r\ndebug1: re-parsing configuration\r\ndebug1: Reading configuration data /home/dmn/.ssh/config\r\ndebug1: /home/dmn/.ssh/config line 51: Applying options for 172.17.0.*\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 2: include /etc/ssh/ssh_config.d/*.conf matched no files\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/dmn/.ssh/known_hosts'\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/dmn/.ssh/known_hosts2'\r\ndebug1: auto-mux: Trying existing master at '/home/dmn/.ansible/cp/499371f37a'\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 703710\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet_timeout: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n")
ok: [172.17.0.3]

TASK [Debug] *****************************************************************************
task path: /tmp/tmp.yJxXPtD5N4/test.yml:6
ok: [172.17.0.3] => {
    "ansible_connection": "ssh"
}

TASK [Meta task] *************************************************************************
task path: /tmp/tmp.yJxXPtD5N4/test.yml:12
ERROR! The conditional check 'ansible_connection != 'docker'' failed. The error was: error while evaluating conditional (ansible_connection != 'docker'): 'ansible_connection' is undefined. 'ansible_connection' is undefined

The error appears to be in '/tmp/tmp.yJxXPtD5N4/test.yml': line 12, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


    - name: "Meta task"
      ^ here

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibot ansibot added bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. affects_2.16 module This issue/PR relates to a module. labels Mar 7, 2024
@ansibot
Copy link
Contributor

ansibot commented Mar 7, 2024

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the component bot command.

@jborean93 jborean93 added docs This issue/PR relates to or includes documentation. and removed needs_triage Needs a first human triage before being processed. labels Mar 7, 2024
@jborean93
Copy link
Contributor

The meta task is a unique task in Ansible that can bypass the host iterator causing all sorts of problems trying to use conditionals. The documentation states https://meet.google.com/zsh-phfb-kxq?authuser=1&hs=122

Only some options support conditionals and when they do they act ‘bypassing the host loop’, taking the values from first available host

While the docs could be clearer what you are trying to do is not possible with the meta task as it will always apply to all hosts rather than a specific one.

I'll leave this issue open as a placeholder for updating the documentation to be clearer on this.

@DMNh
Copy link
Author

DMNh commented Mar 8, 2024

@jborean93 I didn't notice that in the docs for the meta task, that makes sense though, thanks for the information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects_2.16 bug This issue/PR relates to a bug. docs This issue/PR relates to or includes documentation. module This issue/PR relates to a module.
Projects
None yet
Development

No branches or pull requests

3 participants