All the Ansible playbooks used to deploy k3s, argo server, admiralty and minio

This commit is contained in:
pb
2025-09-26 14:12:01 +02:00
parent 140bd63559
commit 2ede262abe
32 changed files with 2019 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
- name: Deploys VM based on local debian image
hosts: localhost
gather_facts: true
become: true
vars:
# debian_image: "/var/lib/libvirt/images"
# vm: "{{ item }}"
ssh_pub_key: "/home/pierre/.ssh/id_rsa.pub"
root: root
os: https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-generic-amd64.qcow2
checksum: ""
xml_template: debian_template
machines:
- name: control_test
ip: 192.168.122.80
# - name: DC01_test
# ip: 192.168.122.81
# - name: DC02_test
# ip: 192.168.122.82
tasks:
- name: Is os image present
ansible.builtin.fail:
msg: You did not provide an image to build from
when:
os == ""
- name: Is XML template present
ansible.builtin.stat:
path: "create_kvm/templates/{{ xml_template }}.xml.j2"
register: xml_present
- name: XML not present
ansible.builtin.fail:
msg: You did not provide a valid xml template
when: not (xml_present.stat.exists)
- name: KVM Provision role
ansible.builtin.include_role:
name: create_kvm
vars:
# libvirt_pool_dir: "{{ pool_dir }}"
os_image: "{{ os }}"
template_file: "{{ xml_template }}.xml.j2"
vm_name: "{{ item.name }}"
ssh_key: "{{ ssh_pub_key }}"
root_pwd: "{{ root }}"
loop:
"{{ machines }}"
- name: Set up the wanted IP
ansible.builtin.include_tasks:
file: setup_vm_ip.yml
loop:
"{{ machines }}"
# for control,dc01,dc02
# 192.168.122.70 + 1
# /var/lib/libvirt/images/debian11-2-1-clone.qcow2

View File

@@ -0,0 +1,32 @@
- name: Installation k3s
hosts: "{{ host_prompt }}"
user: "{{ user_prompt }}"
tasks:
- name: install package
become: true
ansible.builtin.package:
name:
- mosquitto
- mosquitto-clients
state: present
- name: configure mosquitto conf
become: true
ansible.builtin.lineinfile:
path: /etc/mosquitto/conf.d/mosquitto.conf
line: allow_anonymous true
create: true
- name: configure mosquitto conf
become: true
ansible.builtin.lineinfile:
path: /etc/mosquitto/conf.d/mosquitto.conf
line: listener 1883 0.0.0.0
- name: restart mosquitto
become: true
ansible.builtin.service:
name: mosquitto
state: restarted

View File

@@ -0,0 +1,15 @@
- name: Retrieve network info
ansible.builtin.command:
cmd: virsh domifaddr "{{ item.name }}"
register: output_domifaddr
- name: Extract vm's current ip
vars:
pattern: '(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})'
ansible.builtin.set_fact:
current_ip: "{{ output_domifaddr.stdout | regex_search(pattern, '\\1') }}"
- name: Show ip
ansible.builtin.debug:
msg: "{{ current_ip.0 }}"