first commit

This commit is contained in:
2026-02-02 12:44:10 -05:00
commit f2eee63fb7
11 changed files with 583 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
---
- name: Install required packages for Docker
ansible.builtin.apt:
name:
- apt-transport-https
- ca-certificates
- curl
- gnupg
- lsb-release
state: present
update_cache: true
- name: Create keyrings directory
ansible.builtin.file:
path: /etc/apt/keyrings
state: directory
mode: '0755'
- name: Add Docker GPG key
ansible.builtin.get_url:
url: https://download.docker.com/linux/ubuntu/gpg
dest: /etc/apt/keyrings/docker.asc
mode: '0644'
- name: Get system architecture
ansible.builtin.command: dpkg --print-architecture
register: dpkg_arch
changed_when: false
- name: Get Ubuntu codename
ansible.builtin.command: lsb_release -cs
register: ubuntu_codename
changed_when: false
- name: Add Docker repository
ansible.builtin.apt_repository:
repo: "deb [arch={{ dpkg_arch.stdout }} signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu {{ ubuntu_codename.stdout }} stable"
state: present
filename: docker
- name: Install Docker packages
ansible.builtin.apt:
name:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-buildx-plugin
- docker-compose-plugin
state: present
update_cache: true
- name: Ensure Docker service is started and enabled
ansible.builtin.systemd:
name: docker
state: started
enabled: true
- name: Add jenkins user to docker group
ansible.builtin.user:
name: jenkins
groups: docker
append: true
ignore_errors: true

28
roles/nfs/tasks/main.yml Normal file
View File

@@ -0,0 +1,28 @@
---
- name: Install NFS client packages
ansible.builtin.apt:
name:
- nfs-common
state: present
update_cache: true
- name: Create NFS mount directory
ansible.builtin.file:
path: /var/NFSFolder
state: directory
mode: '0755'
- name: Add NFS mount to fstab
ansible.builtin.lineinfile:
path: /etc/fstab
line: "192.168.0.161:/mnt/share1/NFSFolder /var/NFSFolder nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0"
state: present
create: true
- name: Mount NFS share
ansible.posix.mount:
path: /var/NFSFolder
src: "192.168.0.161:/mnt/share1/NFSFolder"
fstype: nfs
opts: "auto,nofail,noatime,nolock,intr,tcp,actimeo=1800"
state: mounted

View File

@@ -0,0 +1,51 @@
---
- name: Get next available VMID
community.general.proxmox_next_id:
api_host: "{{ proxmox_api_host }}"
api_user: "{{ proxmox_api_user }}"
api_token_id: "{{ proxmox_api_token_id }}"
api_token_secret: "{{ proxmox_api_token_secret }}"
register: next_vmid
- name: Clone LXC from template
community.general.proxmox:
api_host: "{{ proxmox_api_host }}"
api_user: "{{ proxmox_api_user }}"
api_token_id: "{{ proxmox_api_token_id }}"
api_token_secret: "{{ proxmox_api_token_secret }}"
node: "{{ target_node }}"
clone: "ubuntu24lxc"
hostname: "{{ vm_hostname }}"
vmid: "{{ next_vmid.vmid }}"
full: true
storage: "local-lvm"
timeout: 300
register: cloned_lxc
- name: Configure LXC resources
community.general.proxmox:
api_host: "{{ proxmox_api_host }}"
api_user: "{{ proxmox_api_user }}"
api_token_id: "{{ proxmox_api_token_id }}"
api_token_secret: "{{ proxmox_api_token_secret }}"
node: "{{ target_node }}"
vmid: "{{ next_vmid.vmid }}"
cores: "{{ cpu_cores }}"
memory: "{{ ram_gb | int * 1024 }}"
netif:
net0: "name=eth0,bridge=vmbr0,ip=dhcp"
state: present
- name: Start the LXC container
community.general.proxmox:
api_host: "{{ proxmox_api_host }}"
api_user: "{{ proxmox_api_user }}"
api_token_id: "{{ proxmox_api_token_id }}"
api_token_secret: "{{ proxmox_api_token_secret }}"
node: "{{ target_node }}"
vmid: "{{ next_vmid.vmid }}"
state: started
- name: Set VMID fact for later use
ansible.builtin.set_fact:
created_vmid: "{{ next_vmid.vmid }}"

View File

@@ -0,0 +1,51 @@
---
- name: Get next available VMID
community.general.proxmox_next_id:
api_host: "{{ proxmox_api_host }}"
api_user: "{{ proxmox_api_user }}"
api_token_id: "{{ proxmox_api_token_id }}"
api_token_secret: "{{ proxmox_api_token_secret }}"
register: next_vmid
- name: Clone VM from template
community.general.proxmox_kvm:
api_host: "{{ proxmox_api_host }}"
api_user: "{{ proxmox_api_user }}"
api_token_id: "{{ proxmox_api_token_id }}"
api_token_secret: "{{ proxmox_api_token_secret }}"
node: "{{ target_node }}"
clone: "ubuntu24vm"
name: "{{ vm_hostname }}"
vmid: "{{ next_vmid.vmid }}"
full: true
storage: "local-lvm"
timeout: 300
register: cloned_vm
- name: Configure VM resources
community.general.proxmox_kvm:
api_host: "{{ proxmox_api_host }}"
api_user: "{{ proxmox_api_user }}"
api_token_id: "{{ proxmox_api_token_id }}"
api_token_secret: "{{ proxmox_api_token_secret }}"
node: "{{ target_node }}"
vmid: "{{ next_vmid.vmid }}"
cores: "{{ cpu_cores }}"
memory: "{{ ram_gb | int * 1024 }}"
net:
net0: "virtio,bridge=vmbr0"
update: true
- name: Start the VM
community.general.proxmox_kvm:
api_host: "{{ proxmox_api_host }}"
api_user: "{{ proxmox_api_user }}"
api_token_id: "{{ proxmox_api_token_id }}"
api_token_secret: "{{ proxmox_api_token_secret }}"
node: "{{ target_node }}"
vmid: "{{ next_vmid.vmid }}"
state: started
- name: Set VMID fact for later use
ansible.builtin.set_fact:
created_vmid: "{{ next_vmid.vmid }}"