community.proxmox.proxmox_subnet module – Create/Update/Delete subnets from SDN

Note

This module is part of the community.proxmox collection (version 1.4.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.proxmox. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: community.proxmox.proxmox_subnet.

New in community.proxmox 1.4.0

Synopsis

  • Create, update, or delete subnets in Proxmox SDN.

Requirements

The below requirements are needed on the host that executes this module.

  • proxmoxer >= 2.0

  • requests

Parameters

Parameter

Comments

api_host

string / required

Specify the target host of the Proxmox VE cluster.

Uses the PROXMOX_HOST environment variable if not specified.

api_password

string

Specify the password to authenticate with.

Uses the PROXMOX_PASSWORD environment variable if not specified.

api_port

integer

Specify the target port of the Proxmox VE cluster.

Uses the PROXMOX_PORT environment variable if not specified.

api_token_id

string

Specify the token ID.

Uses the PROXMOX_TOKEN_ID environment variable if not specified.

api_token_secret

string

Specify the token secret.

Uses the PROXMOX_TOKEN_SECRET environment variable if not specified.

api_user

string / required

Specify the user to authenticate with.

Uses the PROXMOX_USER environment variable if not specified.

delete

string

A list of settings you want to delete.

dhcp_dns_server

string

IP address for the DNS server.

dhcp_range

list / elements=dictionary

Range of IP addresses for DHCP.

end

string / required

Ending IP address of the DHCP range.

start

string / required

Starting IP address of the DHCP range.

dhcp_range_update_mode

string

Only applicable for state=present and it will honor and only make changes when update=true

If set to append and new dhcp_range passed it will just append to existing ranges.

And If no dhcp_range passed and there are existing ranges it will just ignore existing ranges and only update other params if needed

If set to overwrite and new dhcp_range passed it will overwrite existing ranges.

If no dhcp_range passed and there are existing ranges it will delete all dhcp_ranges

Choices:

  • "append" ← (default)

  • "overwrite"

dnszoneprefix

string

Prefix for the DNS zone.

gateway

string

Subnet Gateway. Will be assign on vnet for layer3 zones.

lock_token

string

the token for unlocking the global SDN configuration.

snat

boolean

Enable Source NAT for the subnet.

Choices:

  • false ← (default)

  • true

state

string

Desired state of the subnet configuration.

Choices:

  • "present" ← (default)

  • "absent"

subnet

string / required

Subnet CIDR.

update

boolean

If state=present then it will update the subnet if needed.

Choices:

  • false

  • true ← (default)

validate_certs

boolean

If false, SSL certificates will not be validated.

This should only be used on personally controlled sites using self-signed certificates.

Uses the PROXMOX_VALIDATE_CERTS environment variable if not specified.

Choices:

  • false ← (default)

  • true

vnet

string / required

The virtual network to which the subnet belongs.

zone

string

Vnet Zone.

Attributes

Attribute

Support

Description

action_group

Action group: community.proxmox.proxmox

Use group/community.proxmox.proxmox in module_defaults to set defaults for this module.

check_mode

Support: none

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: none

Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode.

Examples

- name: Create a subnet
  community.proxmox.proxmox_subnet:
    api_user: "{{ pc.proxmox.api_user }}"
    api_token_id: "{{ pc.proxmox.api_token_id }}"
    api_token_secret: "{{ vault.proxmox.api_token_secret }}"
    api_host: "{{ pc.proxmox.api_host }}"
    validate_certs: false
    vnet: test
    subnet: 10.10.2.0/24
    zone: ans1
    state: present
    dhcp_range:
      - start: 10.10.2.5
        end: 10.10.2.50
      - start: 10.10.2.100
        end: 10.10.2.150
    snat: true

- name: Delete a subnet
  community.proxmox.proxmox_subnet:
    api_user: "{{ pc.proxmox.api_user }}"
    api_token_id: "{{ pc.proxmox.api_token_id }}"
    api_token_secret: "{{ vault.proxmox.api_token_secret }}"
    api_host: "{{ pc.proxmox.api_host }}"
    validate_certs: false
    vnet: test
    subnet: 10.10.2.0/24
    zone: ans1
    state: absent

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

subnet

string

Subnet ID which was created/updated/deleted

Returned: on success

Sample: "ans1-10.10.2.0-24"

Authors

  • Jana Hoch