Open yuxiaolejs opened 1 month ago
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.
After some investigation, I noticed that my particular setup led to this problem due to the two features of ansible:
Thus, the second command of that shell script will reuse the ssh connection of the first one (as designed) since they have the same control path.
For my specific case, the solution ended up very straightforward; I just set the control path dir manually to make sure they were different. The modified script looks like this:
ANSIBLE_SSH_CONTROL_PATH_DIR="ansiblecp1" ansible-playbook --inventory vpc-unics-office/inventory.ini inf/ansible/vpn_openvpn.yml --extra-vars vpc=unics-office
ANSIBLE_SSH_CONTROL_PATH_DIR="ansiblecp2" ansible-playbook --inventory vpc-unics-cloud/inventory.ini inf/ansible/vpn_openvpn.yml --extra-vars vpc=unics-cloud
Before edit, I was only setting control path instead of control path dir, which lead it to a crash when a playbook is meant to be ran on multiple hosts.
Could we find a better way of calculating the control path? (For example, should we include the ssh_common_args in the hash or resolve the real IP of the server instead of only the alias?)
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
OS / Environment
Ubuntu 24.04
Steps to Reproduce
Playbook:
Inventory files (two are the same except ssh_conf path)
SSH config (two are the same except public IP and identity file)
Shell script for running it
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
Code of Conduct