Move SSH transport to ssh_config and shared group_vars
hosts.yml repeated the same authentication block for 13 LXC hosts and carried 13 byte-identical copies of the ru-vps ProxyCommand. Describe the transport once in ansible/ssh_config instead: jump host, per-host users, keys, and the fact that pbs and ovpn-mini are reached directly rather than through ru-vps. Ansible loads that file through ansible_ssh_common_args in group_vars/all/main.yml, where the path is derived from inventory_dir so it depends on neither the current directory nor the clone location. The same file makes `ssh gitea` work from a plain terminal once ~/.ssh/config includes it. hosts.yml drops from 209 to 137 lines and now holds only addresses and per-host facts. Verified equivalent: ansible-inventory --list before and after differ only by the removed ansible_ssh_common_args, with group membership and ordering byte-identical. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GTocXkGUUazHdKKd3r9k71
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
---
|
||||
# Общие переменные для всех управляемых хостов.
|
||||
# SSH-транспорт (ProxyJump, порты, ключи по хостам) описан в ansible/ssh_config.
|
||||
# Путь считается от каталога inventory, поэтому работает из любого cwd
|
||||
# и не ломается при клоне репозитория в другое место.
|
||||
ansible_ssh_common_args: "-F {{ inventory_dir }}/../ssh_config"
|
||||
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
ansible_user: ansible
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519_homelab_ansible
|
||||
ansible_become: true
|
||||
|
||||
homelab_lan_cidr: 192.168.1.0/24
|
||||
homelab_service_range: 192.168.1.5-192.168.1.40
|
||||
|
||||
openvpn_network_cidr: 10.78.0.0/30
|
||||
openvpn_listen_port: 8443
|
||||
openvpn_forwarded_services:
|
||||
- name: satisfactory
|
||||
protocol: udp
|
||||
public_port: 7777
|
||||
target_host: 192.168.1.100
|
||||
target_port: 7777
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
# LXC-контейнеры управляются напрямую под root, sudo не требуется.
|
||||
|
||||
ansible_user: root
|
||||
ansible_become: false
|
||||
ansible_ssh_private_key_file: ~/.ssh/id_ed25519_homelab
|
||||
Reference in New Issue
Block a user