proxmox ansible bootstrapping

This commit is contained in:
plasmagoat 2025-06-07 19:41:15 +02:00
parent 2d1a363a50
commit bdf3bc6b02
20 changed files with 481 additions and 4 deletions

View file

@ -0,0 +1,2 @@
# On your Proxmox server (via SSH or console)
sudo cp /etc/network/interfaces /etc/network/interfaces.bak_ansible_pre_change_$(date +%Y%m%d%H%M)

View file

@ -0,0 +1,4 @@
- name: Restart networking
ansible.builtin.service:
name: networking
state: restarted

View file

@ -0,0 +1,57 @@
- name: Backup current /etc/network/interfaces before making changes
ansible.builtin.copy:
src: /etc/network/interfaces
dest: "/etc/network/interfaces.bak_ansible_{{ ansible_date_time.iso8601_basic }}"
remote_src: yes
owner: root
group: root
mode: "0644"
delegate_to: "{{ inventory_hostname }}" # Ensure this runs on the remote host
- name: Render and deploy /etc/network/interfaces from template
ansible.builtin.template:
src: interfaces.j2
dest: /etc/network/interfaces
owner: root
group: root
mode: "0644"
notify: Restart networking
# - name: Ensure network interfaces file exists
# ansible.builtin.copy:
# content: |
# source /etc/network/interfaces.d/*
# dest: /etc/network/interfaces
# owner: root
# group: root
# mode: '0644'
# - name: Configure bond0
# ansible.builtin.copy:
# content: |
# auto bond0
# iface bond0 inet manual
# bond-slaves eno1 eno2 # Replace with your actual interfaces
# bond-mode active-backup
# bond-miimon 100
# bond-primary eno1
# dest: /etc/network/interfaces.d/bond0
# owner: root
# group: root
# mode: '0644'
# notify: Restart networking
# - name: Configure vmbr0 using bond0
# ansible.builtin.copy:
# content: |
# auto vmbr0
# iface vmbr0 inet static
# address 192.168.1.10/24
# gateway 192.168.1.1
# bridge-ports bond0
# bridge-stp off
# bridge-fd 0
# dest: /etc/network/interfaces.d/vmbr0_bond
# owner: root
# group: root
# mode: '0644'
# notify: Restart networking

View file

@ -0,0 +1,22 @@
# /etc/network/interfaces -- used by ifup(8) and ifdown(8)
#
# Include files from /etc/network/interfaces.d:
source /etc/network/interfaces.d/*
auto lo
iface lo inet loopback
auto vmbr0
iface vmbr0 inet static
address {{ proxmox_network_ip }}/{{ proxmox_network_cidr }}
gateway {{ proxmox_network_gateway }}
bridge-ports {{ proxmox_physical_nic }}
bridge-stp off
bridge-fd 0
# Your ethtool post-up line
post-up ethtool -K {{ proxmox_physical_nic }} tso off gso off
auto eno2
iface eno2 inet manual
# Your ethtool post-up line for eno2
post-up ethtool -K eno2 tso off gso off