cloudscale_ch.cloud.floating_ip – Manages floating IPs on the cloudscale.ch IaaS service

Note

This plugin is part of the cloudscale_ch.cloud collection (version 1.3.1).

To install it use: ansible-galaxy collection install cloudscale_ch.cloud.

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

New in version 1.0.0: of cloudscale_ch.cloud

Synopsis

  • Create, assign and delete floating IPs on the cloudscale.ch IaaS service.

Parameters

Parameter Choices/Defaults Comments
api_timeout
integer
Default:
30
Timeout in seconds for calls to the cloudscale.ch API.
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 1.3.0 of cloudscale_ch.cloud
Default:
"https://api.cloudscale.ch/v1"
cloudscale.ch API URL.
This can also be passed in the CLOUDSCALE_API_URL environment variable.
ip_version
integer
    Choices:
  • 4
  • 6
IP protocol version of the floating IP.
Required when assigning a new floating IP.
name
string
added in 1.3.0 of cloudscale_ch.cloud
Name to identifiy the floating IP address for idempotency.
One of network or name is required to identify the floating IP.
Note: name will be required for assigning a new floating IP beginning of version 2.0.0.
network
string
Floating IP address to change.
One of network or name is required to identify the floating IP.

aliases: ip
prefix_length
integer
    Choices:
  • 56
Only valid if ip_version is 6.
Prefix length for the IPv6 network. Currently only a prefix of /56 can be requested. If no prefix_length is present, a single address is created.
region
string
Region in which the floating IP resides (e.g. lgp or rma). If omitted, the region of the project default zone is used. This parameter must be omitted if type is set to global.
reverse_ptr
string
Reverse PTR entry for this address.
You cannot set a reverse PTR entry for IPv6 floating networks. Reverse PTR entries are only allowed for single addresses.
server
string
UUID of the server assigned to this floating IP.
state
string
    Choices:
  • present ←
  • absent
State of the floating IP.
tags
dictionary
added in 1.1.0 of cloudscale_ch.cloud
Tags associated with the floating IP. Set this to {} to clear any tags.
type
string
    Choices:
  • regional ←
  • global
The type of the floating IP.

Notes

Note

  • Once a floating_ip is created, all parameters except server, reverse_ptr and tags are read-only.

  • 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

# Request a new floating IP without assignment to a server
- name: Request a floating IP
  cloudscale_ch.cloud.floating_ip:
    name: IP to my server
    ip_version: 4
    reverse_ptr: my-server.example.com
    api_token: xxxxxx

# Request a new floating IP with assignment
- name: Request a floating IP
  cloudscale_ch.cloud.floating_ip:
    name: web
    ip_version: 4
    server: 47cec963-fcd2-482f-bdb6-24461b2d47b1
    reverse_ptr: my-server.example.com
    api_token: xxxxxx

# Assign an existing floating IP to a different server by its IP address
- name: Move floating IP to backup server
  cloudscale_ch.cloud.floating_ip:
    ip: 192.0.2.123
    server: ea3b39a3-77a8-4d0b-881d-0bb00a1e7f48
    api_token: xxxxxx

# Assign an existing floating IP to a different server by name
- name: Move floating IP to backup server
  cloudscale_ch.cloud.floating_ip:
    name: IP to my server
    server: ea3b39a3-77a8-4d0b-881d-0bb00a1e7f48
    api_token: xxxxxx

# Request a new floating IPv6 network
- name: Request a floating IP
  cloudscale_ch.cloud.floating_ip:
    name: IPv6 to my server
    ip_version: 6
    prefix_length: 56
    server: 47cec963-fcd2-482f-bdb6-24461b2d47b1
    api_token: xxxxxx
    region: lpg1

# Assign an existing floating network to a different server
- name: Move floating IP to backup server
  cloudscale_ch.cloud.floating_ip:
    ip: '{{ floating_ip.ip }}'
    server: ea3b39a3-77a8-4d0b-881d-0bb00a1e7f48
    api_token: xxxxxx

# Remove a floating IP
- name: Release floating IP
  cloudscale_ch.cloud.floating_ip:
    ip: 192.0.2.123
    state: absent
    api_token: xxxxxx

# Remove a floating IP by name
- name: Release floating IP
  cloudscale_ch.cloud.floating_ip:
    name: IP to my server
    state: absent
    api_token: xxxxxx

Return Values

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

Key Returned Description
href
string
success when state == present
The API URL to get details about this floating IP.

Sample:
https://api.cloudscale.ch/v1/floating-ips/2001:db8::cafe
ip
string
success when state == present
The floating IP address.

Sample:
185.98.122.176
name
string
added in 1.3.0 of cloudscale_ch.cloud
success
The name of the floating IP.

Sample:
my floating ip
network
string
success
The CIDR notation of the network that is routed to your server.

Sample:
2001:db8::cafe/128
next_hop
string
success when state == present
Your floating IP is routed to this IP address.

Sample:
2001:db8:dead:beef::42
region
dictionary
success when state == present
The region of the floating IP.

Sample:
{'slug': 'lpg'}
reverse_ptr
string
success when state == present
The reverse pointer for this floating IP address.

Sample:
185-98-122-176.cust.cloudscale.ch
server
string
success when state == present
The floating IP is routed to this server.

Sample:
47cec963-fcd2-482f-bdb6-24461b2d47b1
state
string
success
The current status of the floating IP.

Sample:
present
tags
dictionary
added in 1.1.0 of cloudscale_ch.cloud
success
Tags assosiated with the floating IP.

Sample:
{'project': 'my project'}


Authors

  • Gaudenz Steinlin (@gaudenz)

  • Denis Krienbühl (@href)

  • René Moser (@resmo)