127 lines
4.5 KiB
YAML
127 lines
4.5 KiB
YAML
- name: "LOCALHOST: adding new config to default profile of {{ incus.project.name | default('pxe') }} project"
|
|
hebergemoi.incus.incus_profile:
|
|
merge_profile: true
|
|
name: "{{ incus.profile.name | default('pxe') }}"
|
|
project: "{{ incus.project.name | default('pxe') }}"
|
|
state: present
|
|
config:
|
|
boot.autostart: "false"
|
|
security.secureboot: "false"
|
|
devices:
|
|
root:
|
|
path: /
|
|
size: 10GiB
|
|
type: disk
|
|
pool: default
|
|
eth0:
|
|
type: nic
|
|
network: "{{ incus.bridge.name | default('pxebr1') }}"
|
|
name: eth0
|
|
|
|
- name: "LOCALHOST: create {{ incus.instance.server.name | default('pxeServer') }} container"
|
|
hebergemoi.incus.incus_container:
|
|
name: "{{ incus.instance.server.name | default('pxeServer') }}"
|
|
project: "{{ incus.project.name | default('pxe') }}"
|
|
state: started
|
|
ephemeral: "true"
|
|
wait_for_ipv4_addresses: "true"
|
|
devices:
|
|
eth0:
|
|
type: nic
|
|
network: "{{ incus.bridge.name | default('pxebr1') }}"
|
|
ipv4.address: "{{ incus.instance.server.addr_v4 | default('10.35.182.2') }}"
|
|
source:
|
|
type: image
|
|
alias: debian/bookworm
|
|
protocol: simplestreams
|
|
profiles: ["{{ incus.profile.name | default('pxe') }}"]
|
|
|
|
- name: "LOCALHOST: refresh ansible_facts"
|
|
setup:
|
|
- name: "LOCALHOST: refresh inventory"
|
|
meta: refresh_inventory
|
|
|
|
- hosts: "{{ hostvars.localhost.incus.instance.server.name | default('pxeServer') }}"
|
|
tasks:
|
|
- name: "{{ hostvars.localhost.incus.instance.server.name | default('pxeServer') }}: include config vars"
|
|
ansible.builtin.include_vars:
|
|
dir: ../config
|
|
extensions:
|
|
- "yml"
|
|
- "yaml"
|
|
ignore_unknown_extensions: true
|
|
|
|
- name: "{{ incus.instance.server.name | default('pxeServer') }}: install packages"
|
|
ansible.builtin.package:
|
|
name:
|
|
- make
|
|
- gcc
|
|
- binutils
|
|
- git
|
|
- perl
|
|
- liblzma-dev
|
|
- mtools
|
|
- mkisofs
|
|
- syslinux
|
|
- isolinux
|
|
- nginx
|
|
- dnsmasq
|
|
state: present
|
|
|
|
- name: "{{ incus.instance.server.name | default('pxeServer') }}: clone ipxe repository"
|
|
ansible.builtin.git:
|
|
repo: https://github.com/ipxe/ipxe.git
|
|
dest: /opt/ipxe
|
|
|
|
- name: "{{ incus.instance.server.name | default('pxeServer') }}: make ipxe binary"
|
|
community.general.make:
|
|
chdir: /opt/ipxe/src
|
|
target: bin-x86_64-efi/ipxe.efi
|
|
jobs: 4
|
|
|
|
- name: "{{ incus.instance.server.name | default('pxeServer') }}: create {{ incus.instance.server.services.dnsmasq.tftp_root }} directory"
|
|
ansible.builtin.file:
|
|
path: "{{ incus.instance.server.services.dnsmasq.tftp_root | default('/srv/tftp') }}"
|
|
state: directory
|
|
|
|
- name: "{{ incus.instance.server.name | default('pxeServer') }}: copy ipxe binary into tftp directory service"
|
|
ansible.builtin.copy:
|
|
remote_src: true
|
|
src: /opt/ipxe/src/bin-x86_64-efi/ipxe.efi
|
|
dest: "{{ incus.instance.server.services.dnsmasq.tftp_root | default('/srv/tftp') }}/ipxe.efi"
|
|
owner: dnsmasq
|
|
|
|
- name: "{{ incus.instance.server.name | default('pxeServer') }}: configure dnsmasq tftp service"
|
|
ansible.builtin.template:
|
|
src: templates/dnsmasq/tftp.conf.j2
|
|
dest: /etc/dnsmasq.d/tftp.conf
|
|
|
|
- name: "{{ incus.instance.server.name | default('pxeServer') }}: configure dnsmasq dhcp service if enabled"
|
|
ansible.builtin.template:
|
|
src: templates/dnsmasq/dhcp.conf.j2
|
|
dest: /etc/dnsmasq.d/dhcp.conf
|
|
when: incus.instance.server.services.dnsmasq.dhcp
|
|
|
|
- name: "{{ incus.instance.server.name | default('pxeServer') }}: remove dnsmasq dhcp service file if disabled"
|
|
ansible.builtin.file:
|
|
state: absent
|
|
path: /etc/dnsmasq.d/dhcp.conf
|
|
when: not incus.instance.server.services.dnsmasq.dhcp
|
|
|
|
- name: "{{ incus.instance.server.name | default('pxeServer') }}: activate dnsmasq systemd service"
|
|
ansible.builtin.systemd:
|
|
name: dnsmasq
|
|
state: started
|
|
|
|
- hosts: localhost
|
|
tasks:
|
|
- name: "LOCALHOST: create empty virtual machine {{ incus.instance.client.name | default('vmTest') }} for pxebooting"
|
|
hebergemoi.incus.incus_container:
|
|
type: virtual-machine
|
|
name: "{{ incus.instance.client.name | default('vmTest') }}"
|
|
project: "{{ incus.project.name | default('pxe') }}"
|
|
ephemeral: "true"
|
|
state: started
|
|
source:
|
|
type: none
|
|
profiles: ["{{ incus.profile.name | default('pxe') }}"]
|