diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg new file mode 100644 index 0000000..9ff5b35 --- /dev/null +++ b/ansible/ansible.cfg @@ -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 diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml new file mode 100644 index 0000000..035a346 --- /dev/null +++ b/ansible/group_vars/all.yml @@ -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!" diff --git a/ansible/my_inventory/hosts b/ansible/my_inventory/hosts new file mode 100644 index 0000000..9bc84ac --- /dev/null +++ b/ansible/my_inventory/hosts @@ -0,0 +1,2 @@ +[hypervisor] +hypervisor.lab.local ansible_host=172.30.1.200 ansible_user=sho diff --git a/ansible/playbooks/01_host_prep.yml b/ansible/playbooks/01_host_prep.yml new file mode 100644 index 0000000..5718a54 --- /dev/null +++ b/ansible/playbooks/01_host_prep.yml @@ -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 diff --git a/ansible/playbooks/02_kvm_setup.yml b/ansible/playbooks/02_kvm_setup.yml new file mode 100644 index 0000000..0628464 --- /dev/null +++ b/ansible/playbooks/02_kvm_setup.yml @@ -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