From cb5644c7f30dd2030573a7894bdf0eb779cfaea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauri=20V=C3=B5sandi?= Date: Fri, 19 Jul 2024 12:55:40 +0300 Subject: [PATCH] Ansible SSH multiplexing fixes --- ansible-update-ssh-config.yaml | 2 +- ansible.cfg | 9 +++--- inventory.yml | 2 +- known_hosts | 2 +- ssh_config | 50 +++++++++++++++++----------------- 5 files changed, 33 insertions(+), 32 deletions(-) diff --git a/ansible-update-ssh-config.yaml b/ansible-update-ssh-config.yaml index 4f6c2d5..cf2e577 100644 --- a/ansible-update-ssh-config.yaml +++ b/ansible-update-ssh-config.yaml @@ -20,7 +20,7 @@ content: | # Use `ansible-playbook ansible-update-ssh-config.yml` to update this file {% for host in groups['all'] | sort %} - Host {{ host }} + Host {{ [host, hostvars[host].get('ansible_host', host)] | unique | join(' ') }} User root Hostname {{ hostvars[host].get('ansible_host', host) }} GlobalKnownHostsFile known_hosts diff --git a/ansible.cfg b/ansible.cfg index 62f5e28..968f177 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -1,12 +1,13 @@ [defaults] -ansible_managed = This file is managed by Ansible, manual changes will be overwritten. inventory = inventory.yml nocows = 1 -pipelining = True -pattern = +pattern = deprecation_warnings = False fact_caching = jsonfile fact_caching_connection = ~/.ansible/k-space-fact-cache +remote_user = root [ssh_connection] -ssh_args = -F ssh_config -M -S ~/.ssh/cm-%r@%h:%p +control_path = %(directory)s/%%r@%%h:%%p +ssh_args = -o ControlMaster=auto -o ControlPersist=8h -F ssh_config +pipelining = True diff --git a/inventory.yml b/inventory.yml index fe6da06..53a8285 100644 --- a/inventory.yml +++ b/inventory.yml @@ -3,7 +3,7 @@ all: misc: hosts: ns1.k-space.ee: - ansible_host: 172.23.0.2 + ansible_host: 172.20.0.2 nas.k-space.ee: ansible_host: 172.23.0.7 proxmox: diff --git a/known_hosts b/known_hosts index 0db40af..eabdfac 100644 --- a/known_hosts +++ b/known_hosts @@ -9,7 +9,7 @@ 172.21.3.62 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLveng7H/2Gek+HYDYRWFD0Dy+4l/zjrbF2mnnkBI5CFOtqK0zwBh41IlizkpmmI5fqEIXwhLFHZEWXbUvev5oo= # mon2.kube.k-space.ee 172.21.3.63 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBMMgOIL43dgCYlwAI2O269iHxo7ymweG7NoXjnk2F529G5mP+mp5We4lDZEJVyLYtemvhQ2hEHI/WVPWy3SNiuM= # mon3.kube.k-space.ee 172.23.0.7 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBC15tWIbuBqd4UZLaRbpb6oTlwniS4cg2IYZYe5ys352azj2kzOnvtCGiPo0fynFadwfDHtge9JjK6Efwl87Wgc= # nas.k-space.ee -172.23.0.2 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEP6i24/mo42DXrg5Mc8tZXvqZSqVP/7YqNWlK8oavtcOyfLBq2YuVMhQCDrCm5Hs4FM+qbdcPwEg55mhRJlQXg= # ns1.k-space.ee +172.20.0.2 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBO77ffkJi903aA6cM7HnFfSyYbPP4jkydI/+/tIGeMv+c9BYOE27n+ylNERaEhYkyddIx93MB4M6GYRyQOjLWSc= # ns1.k-space.ee 172.21.20.1 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBHLHc3T/J5G1CIf33XeniJk5+D0cpaXe0OkHmpCQ3DoZC3KkFBpA+/U1mlo+qb8xf/GrMj6BMMMLXKSUxbEVGaU= # pve1 172.21.20.2 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBFGSRetFdHExRT69pHJAcuhqzAu+Xx4K2AEmWJhUZ2JYF7aa0JbltiYQs58Bpx9s9NA793tiHLZXABy56dI+D9Q= # pve2 172.21.20.8 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBMzNvX3ga56EELcI9gV7moyFdKllSwb81V2tCWIjhFVSFTo3QKH/gX/MBnjcs+RxeVV3GF7zIIv8492bCvgiO9s= # pve8 diff --git a/ssh_config b/ssh_config index a5bac02..efe1ead 100644 --- a/ssh_config +++ b/ssh_config @@ -1,120 +1,120 @@ # Use `ansible-playbook ansible-update-ssh-config.yml` to update this file -Host backdoor +Host backdoor 100.102.3.3 User root Hostname 100.102.3.3 GlobalKnownHostsFile known_hosts UserKnownHostsFile /dev/null -Host frontdoor +Host frontdoor 100.102.3.2 User root Hostname 100.102.3.2 GlobalKnownHostsFile known_hosts UserKnownHostsFile /dev/null -Host grounddoor +Host grounddoor 100.102.3.1 User root Hostname 100.102.3.1 GlobalKnownHostsFile known_hosts UserKnownHostsFile /dev/null -Host master1.kube.k-space.ee +Host master1.kube.k-space.ee 172.21.3.51 User root Hostname 172.21.3.51 GlobalKnownHostsFile known_hosts UserKnownHostsFile /dev/null -Host master2.kube.k-space.ee +Host master2.kube.k-space.ee 172.21.3.52 User root Hostname 172.21.3.52 GlobalKnownHostsFile known_hosts UserKnownHostsFile /dev/null -Host master3.kube.k-space.ee +Host master3.kube.k-space.ee 172.21.3.53 User root Hostname 172.21.3.53 GlobalKnownHostsFile known_hosts UserKnownHostsFile /dev/null -Host mon1.kube.k-space.ee +Host mon1.kube.k-space.ee 172.21.3.61 User root Hostname 172.21.3.61 GlobalKnownHostsFile known_hosts UserKnownHostsFile /dev/null -Host mon2.kube.k-space.ee +Host mon2.kube.k-space.ee 172.21.3.62 User root Hostname 172.21.3.62 GlobalKnownHostsFile known_hosts UserKnownHostsFile /dev/null -Host mon3.kube.k-space.ee +Host mon3.kube.k-space.ee 172.21.3.63 User root Hostname 172.21.3.63 GlobalKnownHostsFile known_hosts UserKnownHostsFile /dev/null -Host nas.k-space.ee +Host nas.k-space.ee 172.23.0.7 User root Hostname 172.23.0.7 GlobalKnownHostsFile known_hosts UserKnownHostsFile /dev/null -Host ns1.k-space.ee +Host ns1.k-space.ee 172.20.0.2 User root - Hostname 172.23.0.2 + Hostname 172.20.0.2 GlobalKnownHostsFile known_hosts UserKnownHostsFile /dev/null -Host pve1 +Host pve1 172.21.20.1 User root Hostname 172.21.20.1 GlobalKnownHostsFile known_hosts UserKnownHostsFile /dev/null -Host pve2 +Host pve2 172.21.20.2 User root Hostname 172.21.20.2 GlobalKnownHostsFile known_hosts UserKnownHostsFile /dev/null -Host pve8 +Host pve8 172.21.20.8 User root Hostname 172.21.20.8 GlobalKnownHostsFile known_hosts UserKnownHostsFile /dev/null -Host pve9 +Host pve9 172.21.20.9 User root Hostname 172.21.20.9 GlobalKnownHostsFile known_hosts UserKnownHostsFile /dev/null -Host storage1.kube.k-space.ee +Host storage1.kube.k-space.ee 172.20.3.71 User root Hostname 172.20.3.71 GlobalKnownHostsFile known_hosts UserKnownHostsFile /dev/null -Host storage2.kube.k-space.ee +Host storage2.kube.k-space.ee 172.20.3.72 User root Hostname 172.20.3.72 GlobalKnownHostsFile known_hosts UserKnownHostsFile /dev/null -Host storage3.kube.k-space.ee +Host storage3.kube.k-space.ee 172.20.3.73 User root Hostname 172.20.3.73 GlobalKnownHostsFile known_hosts UserKnownHostsFile /dev/null -Host storage4.kube.k-space.ee +Host storage4.kube.k-space.ee 172.20.3.74 User root Hostname 172.20.3.74 GlobalKnownHostsFile known_hosts UserKnownHostsFile /dev/null -Host worker1.kube.k-space.ee +Host worker1.kube.k-space.ee 172.20.3.81 User root Hostname 172.20.3.81 GlobalKnownHostsFile known_hosts UserKnownHostsFile /dev/null -Host worker2.kube.k-space.ee +Host worker2.kube.k-space.ee 172.20.3.82 User root Hostname 172.20.3.82 GlobalKnownHostsFile known_hosts UserKnownHostsFile /dev/null -Host worker3.kube.k-space.ee +Host worker3.kube.k-space.ee 172.20.3.83 User root Hostname 172.20.3.83 GlobalKnownHostsFile known_hosts UserKnownHostsFile /dev/null -Host worker4.kube.k-space.ee +Host worker4.kube.k-space.ee 172.20.3.84 User root Hostname 172.20.3.84 GlobalKnownHostsFile known_hosts UserKnownHostsFile /dev/null -Host workshopdoor +Host workshopdoor 100.102.3.4 User root Hostname 100.102.3.4 GlobalKnownHostsFile known_hosts