feat(proxmox_lxc_provision): support custom bridge, interface name, and VLAN tag
The bridge (vmbr0) and interface name (eth0) were previously hardcoded in the netif string, and there was no way to set an 802.1Q VLAN tag. Expose lxc_bridge, lxc_iface_name, and lxc_vlan_tag (optional) so containers can be attached to non-default bridges or tagged into a VLAN without forking the role. Also drop the misleading 'lxc_ipv6 | default(omit)' filter — default(omit) does not produce omission inside a string context, and lxc_ipv6 always has a default of 'auto' in defaults/main.yml.
This commit is contained in:
@@ -72,6 +72,9 @@ It also includes tasks which may be used individually:
|
||||
| `lxc_ipv6` | The IPv6 address | `auto` |
|
||||
| `lxc_gateway` | The default gateway | `10.0.0.1` |
|
||||
| `lxc_nameserver` | DNS nameserver | `10.0.0.7` |
|
||||
| `lxc_bridge` | Linux bridge on the Proxmox host to attach the container to | `vmbr0` |
|
||||
| `lxc_iface_name` | Interface name inside the container | `eth0` |
|
||||
| `lxc_vlan_tag` | 802.1Q VLAN tag (integer 1-4094). Omitted from netif when unset. | - |
|
||||
| `lxc_pubkey_file` | Path to SSH public key file | `~/.ssh/id_ed25519.pub` |
|
||||
| `lxc_features` | List of container features | `["nesting=1"]` |
|
||||
| `lxc_tags` | Tags for the container | `["ansible-managed"]` |
|
||||
|
||||
@@ -17,6 +17,9 @@ lxc_ipv4: dhcp
|
||||
lxc_ipv6: auto
|
||||
lxc_nameserver: 10.0.0.7
|
||||
lxc_gateway: 10.0.0.1
|
||||
lxc_bridge: vmbr0
|
||||
lxc_iface_name: eth0
|
||||
# lxc_vlan_tag: unset by default; set to an integer (1-4094) to add an 802.1Q tag
|
||||
lxc_pubkey_file: "~/.ssh/id_ed25519.pub"
|
||||
lxc_unprivileged: true
|
||||
lxc_features:
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
swap: "{{ lxc_swap }}"
|
||||
disk: "{{ lxc_disk }}"
|
||||
mounts: "{{ lxc_mounts | default(omit) }}"
|
||||
netif: >
|
||||
{"net0": "name=eth0,gw={{ lxc_gateway }},ip={{ lxc_ipv4 }},ip6={{ lxc_ipv6 | default(omit) }},bridge=vmbr0"}
|
||||
netif: >-
|
||||
{"net0": "name={{ lxc_iface_name }},bridge={{ lxc_bridge }},ip={{ lxc_ipv4 }},gw={{ lxc_gateway }},ip6={{ lxc_ipv6 }}{% if lxc_vlan_tag is defined %},tag={{ lxc_vlan_tag }}{% endif %}"}
|
||||
pubkey: "{{ lookup('file', lxc_pubkey_file) | default(omit) }}"
|
||||
onboot: "{{ lxc_onboot | default(false) }}"
|
||||
startup: "{{ lxc_startup | default(omit) }}"
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
memory: "{{ lxc_memory }}"
|
||||
swap: "{{ lxc_swap }}"
|
||||
disk: "{{ lxc_disk }}"
|
||||
netif: '{"net0": "name=eth0,gw={{ lxc_gateway }},ip={{ lxc_ipv4 }},ip6={{ lxc_ipv6 | default(omit) }},bridge=vmbr0"}'
|
||||
netif: '{"net0": "name={{ lxc_iface_name }},bridge={{ lxc_bridge }},ip={{ lxc_ipv4 }},gw={{ lxc_gateway }},ip6={{ lxc_ipv6 }}{% if lxc_vlan_tag is defined %},tag={{ lxc_vlan_tag }}{% endif %}"}'
|
||||
pubkey: "{{ lookup('file', lxc_pubkey_file) | default(omit) }}"
|
||||
onboot: "{{ lxc_onboot | default(false) }}"
|
||||
startup: "{{ lxc_startup | default(omit) }}"
|
||||
|
||||
Reference in New Issue
Block a user