refactor(ansible): refactor common role application and improve vm ssh config

Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@tudattr.dev>
This commit is contained in:
Tuan-Dat Tran
2025-04-27 17:46:41 +02:00
parent 591342f580
commit 7fcee3912f
7 changed files with 34 additions and 27 deletions

View File

@@ -1,14 +1,14 @@
---
- name: Set a hostname
ansible.builtin.hostname:
name: "{{ host.hostname }}"
name: "{{ inventory_hostname }}"
become: true
- name: Update /etc/hosts to reflect the new hostname
ansible.builtin.lineinfile:
path: /etc/hosts
regexp: '^127\.0\.1\.1'
line: "127.0.1.1 {{ host.hostname }}"
line: "127.0.1.1 {{ inventory_hostname }}"
state: present
backup: true
become: true

View File

@@ -0,0 +1,15 @@
common_packages:
- build-essential
- curl
- git
- iperf3
- neovim
- rsync
- smartmontools
- sudo
- systemd-timesyncd
- tree
- screen
- bat
- fd-find
- ripgrep

View File

@@ -51,9 +51,12 @@
Host {{ vm.name }}
HostName {{ vm_found_ip }}
Port 22
User tudattr
IdentityFile /media/veracrypt1/genesis
User {{ user }}
IdentityFile {{ pk_path }}
IdentityFile ~/.ssh/id_ed25519
IdentityFile ~/.ssh/id_ed25519-cert.pub
ProxyJump {{ vm.node }}
StrictHostKeyChecking no
- name: Append new VM to SSH config
ansible.builtin.blockinfile: