community.general.one_vnet module – Manages OpenNebula virtual networks

Note

This module is part of the community.general collection (version 10.1.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.general. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: community.general.one_vnet.

New in community.general 9.4.0

Synopsis

  • Manages virtual networks in OpenNebula.

Requirements

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

  • pyone

Parameters

Parameter

Comments

api_password

aliases: api_token

string

The password or token for XMLRPC authentication.

If not specified then the value of the ONE_PASSWORD environment variable, if any, is used.

api_url

aliases: api_endpoint

string

The ENDPOINT URL of the XMLRPC server.

If not specified then the value of the ONE_URL environment variable, if any, is used.

api_username

string

The name of the user for XMLRPC authentication.

If not specified then the value of the ONE_USERNAME environment variable, if any, is used.

id

integer

A id of the network you would like to manage.

If not set then a new network will be created with the given name.

name

string

A name of the network you would like to manage. If a network with the given name does not exist it will be created, otherwise it will be managed by this module.

state

string

present - state that is used to manage the network.

absent - delete the network.

Choices:

  • "present" ← (default)

  • "absent"

template

string

A string containing the network template contents.

validate_certs

boolean

Whether to validate the TLS/SSL certificates or not.

This parameter is ignored if PYTHONHTTPSVERIFY environment variable is used.

Choices:

  • false

  • true ← (default)

wait_timeout

integer

Time to wait for the desired state to be reached before timeout, in seconds.

Default: 300

Attributes

Attribute

Support

Description

check_mode

Support: partial

Note that check mode always returns changed=true for existing networks, even if the network would not actually change.

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: Make sure the network is present by ID
  community.general.one_vnet:
    id: 0
    state: present
  register: result

- name: Make sure the network is present by name
  community.general.one_vnet:
    name: opennebula-bridge
    state: present
  register: result

- name: Create a new or update an existing network
  community.general.one_vnet:
    name: bridge-network
    template: |
      VN_MAD  = "bridge"
      BRIDGE  = "br0"
      BRIDGE_TYPE  = "linux"
      AR=[
        TYPE  = "IP4",
        IP    = 192.0.2.50,
        SIZE  = "20"
      ]
      DNS     = 192.0.2.1
      GATEWAY = 192.0.2.1

- name: Delete the network by ID
  community.general.one_vnet:
    id: 0
    state: absent

Return Values

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

Key

Description

ar_pool

list / elements=string

The network’s list of ar_pool.

Returned: when state=present

Sample: [{"ar_id": 0, "ip": "192.0.2.1", "mac": "6c:1e:46:01:cd:d1", "size": 20, "type": "IP4"}, {"allocated": 0, "ar_id": 1, "ip": "198.51.100.1", "mac": "5d:9b:c0:9e:f6:e5", "size": 20, "type": "IP4"}]

bridge

string

The network’s bridge interface.

Returned: when state=present

Sample: "br0"

bridge_type

string

The network’s bridge type.

Returned: when state=present

Sample: "linux"

clusters

list / elements=string

The network’s clusters.

Returned: when state=present

Sample: [0, 100]

group_id

integer

The network’s group id.

Returned: when state=present

Sample: 1

group_name

string

The network’s group name.

Returned: when state=present

Sample: "one-users"

id

integer

The network id.

Returned: when state=present

Sample: 153

name

string

The network name.

Returned: when state=present

Sample: "app1"

outer_vlan_id

integer

The network’s outer VLAN tag.

Returned: when state=present

Sample: 1000

owner_id

integer

The network’s owner id.

Returned: when state=present

Sample: 143

owner_name

string

The network’s owner name.

Returned: when state=present

Sample: "ansible-test"

parent_network_id

integer

The network’s parent network id.

Returned: when state=present

Sample: 1

permissions

dictionary

The network’s permissions.

Returned: when state=present

Sample: {"group_a": 0, "group_m": 0, "group_u": 0, "other_a": 0, "other_m": 0, "other_u": 0, "owner_a": 0, "owner_m": 0, "owner_u": 1}

group_a

string

The network’s group ADMIN permissions.

Returned: success

Sample: "0"

group_m

string

The network’s group MANAGE permissions.

Returned: success

Sample: "0"

group_u

string

The network’s group USAGE permissions.

Returned: success

Sample: "0"

other_a

string

The network’s other users ADMIN permissions

Returned: success

Sample: "0"

other_m

string

The network’s other users MANAGE permissions.

Returned: success

Sample: "0"

other_u

string

The network’s other users USAGE permissions.

Returned: success

Sample: "0"

owner_a

string

The network’s owner ADMIN permissions.

Returned: success

Sample: "0"

owner_m

string

The network’s owner MANAGE permissions.

Returned: success

Sample: "0"

owner_u

string

The network’s owner USAGE permissions.

Returned: success

Sample: "1"

phydev

string

The network’s physical device (NIC).

Returned: when state=present

Sample: "eth0"

template

dictionary

The parsed network template.

Returned: when state=present

Sample: {"BRIDGE": "onebr.1000", "BRIDGE_TYPE": "linux", "DESCRIPTION": "sampletext", "PHYDEV": "eth0", "SECURITY_GROUPS": 0, "VLAN_ID": 1000, "VN_MAD": "802.1Q"}

user_id

integer

The network’s user name.

Returned: when state=present

Sample: 1

user_name

string

The network’s user id.

Returned: when state=present

Sample: "oneadmin"

vlan_id

integer

The network’s VLAN tag.

Returned: when state=present

Sample: 1000

vn_mad

string

The network’s VN_MAD.

Returned: when state=present

Sample: "bridge"

vrouters

list / elements=string

The network’s list of virtual routers IDs.

Returned: when state=present

Sample: [0, 1]

Authors

  • Alexander Bakanovskii (@abakanovskii)