mitogen icon indicating copy to clipboard operation
mitogen copied to clipboard

Regression: limit option for playbooks causes mitogen to mix connection args between hosts

Open polski-g opened this issue 3 years ago • 1 comments

If you run a playbook with delegation and limit the hosts to use, the SSH connection parameters seems to be mixed together between hosts.

In case of execution run 2 (see below), you will see that the ssh arguments created by mitogen will be attempting to use those assigned for remote1 for the nagios1 host. You will see the ProxyCommand arguments in your ssh execution for nagios1. This is the bug. You should only see ProxyCommand being used for the connection to remote1

I unfortunately cannot provide exact logs; the execution environment is very isolated.

Versions

ansible 2.12.2 mitogen 0.3.2

Minimum test bed

hosts

[myhosts]
nagios1   ansible_host=10.1.1.1    ansible_port=22   ansible_user=root ansible_ssh_private_key_file=./nagios1.key
remote1   ansible_host=23.23.23.23 ansible_port=2233 ansible_user=lord ansible_ssh_private_key_file=./remote1.key ansible_ssh_common_args="-o ProxyCommand=\"nc -x 10.2.2.2:1080 -X 4 %h %p\""

playbook1.yml

---
- hosts: all
  tasks:
    - ping:
       delegate_to: nagios1
    - ping:

Run cases

_local_py=$( python -c 'import sys; print("\n".join(sys.path))' | grep site-packages | head -n1 )
export ANSIBLE_STRATEGY_PLUGINS="${_local_py}/ansible_mitogen/plugins/strategy"

# (1) this will work
export ANSIBLE_STRATEGY=linear
ansible-playbook -i hosts playbook1.yml -vvv -l remote1

# (2) this will FAIL
export ANSIBLE_STRATEGY=mitogen_linear
ansible-playbook -i hosts playbook1.yml -vvv -l remote1

polski-g avatar Feb 15 '22 19:02 polski-g

Sorry for the wait. This might have been fixed in master. I see the same output with linear, and mitogen_linear.

➜  mitogen2 git:(master) ✗ venv/bin/ansible-playbook -i hosts.ini issue902.yml

PLAY [issue902]

TASK [debug]
  ansible_ssh_common_args: VARIABLE IS NOT DEFINED!
ok: [host2] => 
  ansible_ssh_common_args: -x

TASK [debug]
ok: [host1 -> host2(1.2.3.4)] => 
  ansible_ssh_common_args: -x
ok: [host2] => 
  ansible_ssh_common_args: -x

PLAY RECAP
host1                      : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
host2                      : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

➜  mitogen2 git:(master) ✗ ANSIBLE_STRATEGY_PLUGINS=ansible_mitogen/plugins/strategy ANSIBLE_STRATEGY=mitogen_linear venv/bin/ansible-playbook -i hosts.ini issue902.yml

PLAY [issue902]

TASK [debug]
ok: [host1] => 
  ansible_ssh_common_args: VARIABLE IS NOT DEFINED!
ok: [host2] => 
  ansible_ssh_common_args: -x

TASK [debug]
ok: [host1 -> host2(1.2.3.4)] => 
  ansible_ssh_common_args: -x
ok: [host2] => 
  ansible_ssh_common_args: -x

PLAY RECAP
host1                      : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
host2                      : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

➜  mitogen2 git:(master) ✗ venv/bin/ansible-playbook --version
ansible-playbook [core 2.12.4]
  config file = /Users/alex/.ansible.cfg
  configured module search path = ['/Users/alex/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/alex/src/mitogen2/venv/lib/python3.10/site-packages/ansible
  ansible collection location = /Users/alex/.ansible/collections:/usr/share/ansible/collections
  executable location = venv/bin/ansible-playbook
  python version = 3.10.2 (main, Feb  2 2022, 05:51:25) [Clang 13.0.0 (clang-1300.0.29.3)]
  jinja version = 3.1.1
  libyaml = True

Inventory, and playbook

[issue902]
host1   ansible_host=192.168.1.105 ansible_user=alex
host2   ansible_host=1.2.3.4 ansible_user=ubuntu ansible_ssh_common_args=-x
- hosts: issue902
  gather_facts: false
  tasks:
    - debug:
        var: ansible_ssh_common_args
    - debug:
        var: ansible_ssh_common_args
      delegate_to: host2

moreati avatar Apr 23 '22 18:04 moreati