ansible: add config for minimal vm

This commit is contained in:
tylen 2025-04-03 19:49:50 +00:00
parent ef6dc0acd5
commit a5e16cac00
3 changed files with 47 additions and 0 deletions

View File

@ -14,6 +14,7 @@ common_base_packages:
- ca-certificates - ca-certificates
- cifs-utils - cifs-utils
- curl - curl
- cups
- exa - exa
- git - git
- python3-pip - python3-pip

View File

@ -2,3 +2,6 @@
vm-media-100-55 ansible_host=192.168.100.55 ansible_user=tylen vm-media-100-55 ansible_host=192.168.100.55 ansible_user=tylen
vm-tools-100-65 ansible_host=192.168.100.65 ansible_user=tylen vm-tools-100-65 ansible_host=192.168.100.65 ansible_user=tylen
vm-network-100-75 ansible_host=192.168.100.75 ansible_user=tylen vm-network-100-75 ansible_host=192.168.100.75 ansible_user=tylen
[misc]
vm-printer-100-20 ansible_host=192.168.100.20 ansible_user=tylen

View File

@ -0,0 +1,43 @@
---
- name: Initialise worker VM
hosts: misc
become: yes
vars_files:
- worker_vars.yaml
- ../common_vars.yaml
tasks:
- name: Install essentials
apt:
name: "{{ common_base_packages }}"
state: latest
update_cache: true
ignore_errors: yes
- name: Create a login user
user:
name: "{{ vm_username }}"
password: "$6$OhH/TOtjPdxJgC9i$1ytWcV0yBuv5b4Momkka57tErCc4UqvG0zqydyyGQm3OXSaWPHTLHxvPjeCdA9B8T0./eXawj62xZ7gVtzokG/"
groups:
- sudo
state: present
shell: /usr/bin/bash
- name: Copy authorized keys
authorized_key:
user: "{{ vm_username }}"
key: "{{ lookup('file', '{{ ssh_access_keys }}') }}"
- name: Download rc files
get_url:
url: "{{ item.url }}"
dest: "{{ item.dest }}"
mode: '0644'
loop:
- { url: '{{ bashrc_file_url }}', dest: '{{ bashrc_mount_path }}' }
- { url: '{{ vimrc_file_url }}', dest: '{{ vimrc_mount_path }}' }