community.general.cs_ip_address (0.1.1) — module

Manages public IP address associations on Apache CloudStack based clouds.

Authors: Darren Worrall (@dazworrall), René Moser (@resmo)

stableinterface | supported by community

Install collection

Install with ansible-galaxy collection install community.general:==0.1.1


Add to requirements.yml

  collections:
    - name: community.general
      version: 0.1.1

Description

Acquires and associates a public IP to an account or project.

Due to API limitations this is not an idempotent call, so be sure to only conditionally call this when I(state=present).

Tagging the IP address can also make the call idempotent.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Associate an IP address conditionally
  cs_ip_address:
    network: My Network
  register: ip_address
  when: instance.public_ip is undefined
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Disassociate an IP address
  cs_ip_address:
    ip_address: 1.2.3.4
    state: absent
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Associate an IP address with tags
  cs_ip_address:
    network: My Network
    tags:
      - key: myCustomID
      - value: 5510c31a-416e-11e8-9013-02000a6b00bf
  register: ip_address
  delegate_to: localhost
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Disassociate an IP address with tags
  cs_ip_address:
    state: absent
    tags:
      - key: myCustomID
      - value: 5510c31a-416e-11e8-9013-02000a6b00bf
  delegate_to: localhost

Inputs

    
vpc:
    description:
    - VPC the IP address is related to.
    - Mutually exclusive with I(network).
    type: str

tags:
    aliases:
    - tag
    description:
    - List of tags. Tags are a list of dictionaries having keys I(key) and I(value).
    - Tags can be used as an unique identifier for the IP Addresses.
    - In this case, at least one of them must be unique to ensure idempotency.
    type: list

zone:
    description:
    - Name of the zone in which the IP address is in.
    - If not set, default zone is used.
    type: str

state:
    choices:
    - present
    - absent
    default: present
    description:
    - State of the IP address.
    type: str

domain:
    description:
    - Domain the IP address is related to.
    type: str

account:
    description:
    - Account the IP address is related to.
    type: str

api_key:
    description:
    - API key of the CloudStack API.
    - If not given, the C(CLOUDSTACK_KEY) env variable is considered.
    - As the last option, the value is taken from the ini config file, also see the notes.
    type: str

api_url:
    description:
    - URL of the CloudStack API e.g. https://cloud.example.com/client/api.
    - If not given, the C(CLOUDSTACK_ENDPOINT) env variable is considered.
    - As the last option, the value is taken from the ini config file, also see the notes.
    type: str

network:
    description:
    - Network the IP address is related to.
    - Mutually exclusive with I(vpc).
    type: str

project:
    description:
    - Name of the project the IP address is related to.
    type: str

api_region:
    default: cloudstack
    description:
    - Name of the ini section in the C(cloustack.ini) file.
    - If not given, the C(CLOUDSTACK_REGION) env variable is considered.
    type: str

api_secret:
    description:
    - Secret key of the CloudStack API.
    - If not set, the C(CLOUDSTACK_SECRET) env variable is considered.
    - As the last option, the value is taken from the ini config file, also see the notes.
    type: str

ip_address:
    description:
    - Public IP address.
    - Required if I(state=absent) and I(tags) is not set.
    type: str

poll_async:
    default: true
    description:
    - Poll async jobs until job has finished.
    type: bool

api_timeout:
    description:
    - HTTP timeout in seconds.
    - If not given, the C(CLOUDSTACK_TIMEOUT) env variable is considered.
    - As the last option, the value is taken from the ini config file, also see the notes.
    - Fallback value is 10 seconds if not specified.
    type: int

api_http_method:
    choices:
    - get
    - post
    description:
    - HTTP method used to query the API endpoint.
    - If not given, the C(CLOUDSTACK_METHOD) env variable is considered.
    - As the last option, the value is taken from the ini config file, also see the notes.
    - Fallback value is C(get) if not specified.
    type: str

Outputs

account:
  description: Account the IP address is related to.
  returned: success
  sample: example account
  type: str
domain:
  description: Domain the IP address is related to.
  returned: success
  sample: example domain
  type: str
id:
  description: UUID of the Public IP address.
  returned: success
  sample: a6f7a5fc-43f8-11e5-a151-feff819cdc9f
  type: str
ip_address:
  description: Public IP address.
  returned: success
  sample: 1.2.3.4
  type: str
project:
  description: Name of project the IP address is related to.
  returned: success
  sample: Production
  type: str
tags:
  description: List of resource tags associated with the IP address.
  returned: success
  sample: '[ { "key": "myCustomID", "value": "5510c31a-416e-11e8-9013-02000a6b00bf"
    } ]'
  type: dict
  version_added: '2.6'
  version_added_collection: community.general
zone:
  description: Name of zone the IP address is related to.
  returned: success
  sample: ch-gva-2
  type: str