Set up hypervisor host for virtualization

This commit is contained in:
Sho Ishida 2026-07-16 05:52:13 +00:00
parent d51bc2c510
commit 93bbd9dff8
5 changed files with 94 additions and 0 deletions

11
ansible/ansible.cfg Normal file
View File

@ -0,0 +1,11 @@
[defaults]
inventory = ./my_inventory/hosts
roles_path = roles
retry_files_enabled = false
callbacks_enabled = timer, profile_tasks
host_key_checking = False
vault_password_file = .vault_pass
[ssh_connection]
pipelining = True
ssh_args = -o ControlMaster=auto -o ControlPersist=60s -o ForwardAgent=yes

View File

@ -0,0 +1,22 @@
---
domain_name: "lab.local"
realm_name: "LAB.LOCAL"
timezone: "Asia/Seoul"
lan_subnet: "172.30.1.0/24"
host_ip: "172.30.1.200"
gateway_ip: "172.30.1.254"
freeipa_ip: "172.30.1.85"
portfolio_ip: "172.30.1.93"
minecraft_ip: "172.30.1.91"
navidrome_ip: "172.30.1.92"
dns_servers:
- "172.30.1.85"
- "1.1.1.1"
admin_user: "sho"
ipa_admin_password: "ChangeMeIPAAdmin123!"
ipa_directory_manager_password: "ChangeMeIPAAdmin123!"

View File

@ -0,0 +1,2 @@
[hypervisor]
hypervisor.lab.local ansible_host=172.30.1.200 ansible_user=sho

View File

@ -0,0 +1,26 @@
---
- name: Prepare Hypervisor Host
hosts: hypervisor
gather_facts: true
tasks:
- name: Enable EPEL repository
become: true
ansible.builtin.dnf:
name: epel-release
state: present
- name: Install utility tools
become: true
ansible.builtin.dnf:
name:
- htop
- tmux
- git
- curl
state: present
- name: Configure system timezone
become: true
ansible.builtin.command: timedatectl set-timezone {{ timezone }}
changed_when: false

View File

@ -0,0 +1,33 @@
---
- name: Setup KVM Hypervisor and Cockpit
hosts: hypervisor
gather_facts: true
tasks:
- name: Install virtualization packages and Cockpit
become: true
ansible.builtin.dnf:
name:
- qemu-kvm
- libvirt
- virt-install
- cockpit
- cockpit-machines
state: present
- name: Add user to libvirt group
become: true
ansible.builtin.user:
name: "{{ admin_user }}"
groups: libvirt
append: true
- name: Ensure virtualization and cockpit services are active
become: true
ansible.builtin.systemd_service:
name: "{{ item }}"
state: started
enabled: true
loop:
- libvirtd
- cockpit.socket