8000 SSH mux does not distinguish different inventory files · Issue #84148 · ansible/ansible · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
SSH mux does not distinguish different inventory files #84148
Open
@yuxiaolejs

Description

@yuxiaolejs

Summary

I have to run an Ansible playbook on two sets of machines; each of them has an inventory.ini file that identifies them using their SSH config (the rest is the same).

When I actually ran it, I found that it ended up as the same playbook was run twice on the same set of machines (first inventory file used). After digging using Wireshark, I saw it only established a connection to the bastion of the first set of machines, and I could only see one ssh mux process in the background.

Issue Type

Bug Report

Component Name

ssh

Ansible Version

$ ansible --version

ansible [core 2.16.3]
  config file = None
  configured module search path = ['/home/unics/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/unics/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.12.3 (main, Sep 11 2024, 14:17:37) [GCC 13.2.0] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True


### Configuration

```console
# 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
PAGER(env: PAGER) = less

OS / Environment

Ubuntu 24.04

Steps to Reproduce

Playbook:

- name: Install openvpn
  hosts: bastion
  gather_facts: true
  become: true
  tasks:
    - name: debug host
      debug:
        var: ansible_ssh_common_args
    - name: Check if openvpn@bastion service exists
      systemd:
        name: openvpn@bastion
        state: started 
      register: service_status
      ignore_errors: yes 

    - debug:
        var: service_status

Inventory files (two are the same except ssh_conf path)

[all:vars]
ansible_ssh_common_args="-F ./vpc-unics-office/ssh_config -o ControlMaster=no"
global_comm_password="xxxx"
global_comm_ip="34.221.xx.xx"
vpc_cidr="10.1.0.0/16"
bastion_ip="10.1.100.10"

[static]
router ansible_host=router ansible_user=ubuntu
bastion ansible_host=bastion ansible_user=ubuntu
logger ansible_host=logger ansible_user=ubuntu

SSH config (two are the same except public IP and identity file)

Host *
   StrictHostKeyChecking no
   UserKnownHostsFile=/dev/null
   User ubuntu

Host bastion 52.27.xx.xx
    HostName 52.27.xx.xx
    IdentityFile ./vpc-unics-office/id_rsa

Shell script for running it

ANSIBLE_FACT_CACHING=none ansible-playbook --inventory vpc-unics-office/inventory.ini inf/ansible/vpn_openvpn.yml --extra-vars vpc=unics-office --ssh-common-args='-o ControlMaster=no'
ANSIBLE_FACT_CACHING=none ansible-playbook --inventory vpc-unics-cloud/inventory.ini inf/ansible/vpn_openvpn.yml --extra-vars vpc=unics-cloud --flush-cache --ssh-common-args='-o ControlMaster=no'

I have OpenVPN up and running on one of the host but not even installed on the other. This shell script always gives the same result, both running or both dne, depending on which inventory used first.

Expected Results

It should connect to the correct machine and give the true result. For the machine that has OpenVPN running, it should say OK, and for the machine without OpenVPN installed, it should report the error detail but not failing (since I set it to ignore errors). Since I have configured OpenVPN only on one machine, the result shouldn't be the same.

Actual Results

They are the same; either both are shown as running or both are shown as doesn't exist, which is not the truth. Due to the concern for private info in the -vvvv output, I'd rather not post it here.

Code of Conduct

  • I agree to follow the Ansible Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects_2.16bugThis issue/PR relates to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0