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:
@@ -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
|
||||
|
||||
15
roles/common/vars/main.yml
Normal file
15
roles/common/vars/main.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
common_packages:
|
||||
- build-essential
|
||||
- curl
|
||||
- git
|
||||
- iperf3
|
||||
- neovim
|
||||
- rsync
|
||||
- smartmontools
|
||||
- sudo
|
||||
- systemd-timesyncd
|
||||
- tree
|
||||
- screen
|
||||
- bat
|
||||
- fd-find
|
||||
- ripgrep
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user