Proxmox VE vswitch automation

vienuj

New Member
Dec 12, 2024
2
0
1
Hi community,

I would like to automate the creation of vswitch in bridge mode on a particular pve node with ansible.
I have no cluster. We are testing proxmox in our lab to hosts many virtual router, that pve will be a virtualization of a full Service Provider network environement, with many interconection between all virtual routers.
I have already a playbook to create many virtual routers working but until now, i am not able to have a working playbook to create vswitch in bridge mode.
Does someone have it and would be kind enough to share or give a path?
Do you think that using a "standard" debian network creation will work?

Many thanks.

Vienuj.
 
Hi community,

I would like to automate the creation of vswitch in bridge mode on a particular pve node with ansible.
I have no cluster. We are testing proxmox in our lab to hosts many virtual router, that pve will be a virtualization of a full Service Provider network environement, with many interconection between all virtual routers.
I have already a playbook to create many virtual routers working but until now, i am not able to have a working playbook to create vswitch in bridge mode.
Does someone have it and would be kind enough to share or give a path?
Do you think that using a "standard" debian network creation will work?

Many thanks.

Vienuj.
You can automate vSwitch (Linux Bridge) creation on a single Proxmox node using Ansible. Since you're not using a cluster, you can manage the network manually via /etc/network/interfaces.

1️ Example Ansible Playbook for Creating a vSwitch (Linux Bridge Mode)

Create a playbook vswitch-bridge.yml:
YAML:
- name: Configure vSwitch (Bridge Mode) on Proxmox
  hosts: proxmox
  become: true
  tasks:

    - name: Ensure bridge-utils is installed
      apt:
        name: bridge-utils
        state: present

    - name: Add Linux Bridge to /etc/network/interfaces
      blockinfile:
        path: /etc/network/interfaces
        block: |
          auto vmbr1
          iface vmbr1 inet manual
              bridge_ports none
              bridge_stp off
              bridge_fd 0
        marker: "# {mark} ANSIBLE MANAGED BLOCK FOR VSWITCH"

    - name: Restart networking service
      command: systemctl restart networking

2️ How to Run the Playbook

  1. Add your Proxmox nodeto Ansible inventory (/etc/ansible/hosts):
    INI:
    [proxmox]
    pve-node ansible_host=192.168.1.10 ansible_user=root ansible_password=your_password

  2. Run the playbook:
    Bash:
    ansible-playbook -i /etc/ansible/hosts vswitch-bridge.yml

3️ Will a Standard Debian Network Configuration Work?

Yes, Proxmox networking is based on Debian, so the standard Debian method (/etc/network/interfaces) will work fine. However, if you need OVS (Open vSwitch) instead of Linux Bridge, you must install openvswitch-switch and modify the configuration accordingly.