cloudscale_ch.cloud.interface module – Manages network interfaces on the cloudscale.ch IaaS service

Note

This module is part of the cloudscale_ch.cloud collection (version 2.6.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 cloudscale_ch.cloud.

To use it in a playbook, specify: cloudscale_ch.cloud.interface.

New in cloudscale_ch.cloud 2.6.0

Synopsis

  • Create and remove network interfaces attached to routers.

Parameters

Parameter

Comments

addresses

list / elements=dictionary

List of address configurations for the interface.

Required when state=present.

address

string / required

The IP address to assign.

subnet

string / required

UUID of the subnet.

api_timeout

integer

Timeout in seconds for calls to the cloudscale.ch API.

This can also be passed in the CLOUDSCALE_API_TIMEOUT environment variable.

Default: 45

api_token

string / required

cloudscale.ch API token.

This can also be passed in the CLOUDSCALE_API_TOKEN environment variable.

api_url

string

added in cloudscale_ch.cloud 1.3.0

cloudscale.ch API URL.

This can also be passed in the CLOUDSCALE_API_URL environment variable.

Default: "https://api.cloudscale.ch/v1"

network

string / required

UUID of the network to attach.

Used as the idempotency key to identify the interface within the router.

router

string / required

UUID of the router to attach the interface to.

state

string

State of the interface.

Choices:

  • "present" ← (default)

  • "absent"

Notes

Note

  • Updates are not supported. Changing any parameter requires deleting and recreating the interface.

  • All operations are performed using the cloudscale.ch public API v1.

  • For details consult the full API documentation: https://www.cloudscale.ch/en/api/v1.

  • A valid API token is required for all operations. You can create as many tokens as you like using the cloudscale.ch control panel at https://control.cloudscale.ch.

Examples

---
- name: Ensure router exists
  cloudscale_ch.cloud.router:
    name: "{{ resource_prefix }}-router"
    zone: "{{ cloudscale_zone }}"
    internet_gateway: false
  register: router

- name: Attach a network interface with a specific IP address
  cloudscale_ch.cloud.interface:
    router: '{{ router.uuid }}'
    network: '{{ network.uuid }}'
    addresses:
      - subnet: '{{ subnet.uuid }}'
        address: '172.16.0.1'
    api_token: xxxxxx

- name: Remove a network interface from a router
  cloudscale_ch.cloud.interface:
    router: '{{ router.uuid }}'
    network: '{{ network.uuid }}'
    state: absent
    api_token: xxxxxx

Return Values

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

Key

Description

addresses

complex

List of address objects assigned to this interface.

Returned: success when not state == absent

address

string

The IP address assigned to the interface.

Returned: success

Sample: "172.16.0.1"

reverse_ptr

string

The reverse DNS pointer (PTR) for the address.

Returned: success

Sample: "185-98-122-176.cust.cloudscale.ch"

subnet

complex

The subnet the address belongs to.

Returned: success

cidr

string

The CIDR of the subnet.

Returned: success

Sample: "172.16.0.0/24"

href

string

API URL to get details about the subnet.

Returned: success

Sample: "https://api.cloudscale.ch/v1/subnets/33333333-1864-4608-853a-0771b6885a3"

uuid

string

The unique identifier for the subnet.

Returned: success

Sample: "33333333-1864-4608-853a-0771b6885a3"

version

integer

The IP version of the address (4 or 6).

Returned: success

Sample: 4

mac_address

string

The MAC address of the interface.

Returned: success when not state == absent

Sample: "fa:16:3e:b9:2c:8a"

network

complex

The network this interface is attached to.

Returned: success when not state == absent

href

string

API URL to get details about the network.

Returned: success

Sample: "https://api.cloudscale.ch/v1/networks/33333333-1864-4608-853a-0771b6885a3"

name

string

The name of the network.

Returned: success

Sample: "my-network"

uuid

string

The unique identifier for the network.

Returned: success

Sample: "33333333-1864-4608-853a-0771b6885a3"

state

string

State of the interface.

Returned: success

Sample: "present"

type

string

The type of the interface (e.g. private).

Returned: success when not state == absent

Sample: "private"

uuid

string

The unique identifier for the interface.

Returned: success when not state == absent

Sample: "cfde831a-4e87-4a75-960f-89b0148aa2cc"

Authors

  • Michael Weibel (@mweibel)