gcore.cloud.subnet (1.0.1) — module

Manages subnets

Authors: GCore (@GCore)

Install collection

Install with ansible-galaxy collection install gcore.cloud:==1.0.1


Add to requirements.yml

  collections:
    - name: gcore.cloud
      version: 1.0.1

Description

Create/update or delete subnet

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create new subnet
  gcore.cloud.subnet:
    api_key: "{{ api_key }}"
    region_id: "{{ region_id }}"
    project_id: "{{ project_id }}"
    command: create
    name: "{{ subnet_name }}"
    network_id: "{{ network_id }}"
    cidr: "{{ cidr }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Update subnet
  gcore.cloud.subnet:
    api_key: "{{ api_key }}"
    region_id: "{{ region_id }}"
    project_id: "{{ project_id }}"
    command: update
    subnet_id: "{{ subnet_id }}"
    name: "{{ new_subnet_name }}"
    dns_nameservers: "{{ dns_nameservers }}"
    enable_dhcp: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Update routes for subnet
  gcore.cloud.subnet:
    api_key: "{{ api_key }}"
    region_id: "{{ region_id }}"
    project_id: "{{ project_id }}"
    command: update
    subnet_id: "{{ subnet_id }}"
    host_routes: "{{ host_routes }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete subnet
  gcore.cloud.subnet:
    api_key: "{{ api_key }}"
    region_id: "{{ region_id }}"
    project_id: "{{ project_id }}"
    command: delete
    subnet_id: "{{ subnet_id }}"

Inputs

    
cidr:
    description:
    - CIDR.
    - Required if I(command) is create
    required: false
    type: str

name:
    description:
    - Subnet name.
    - Required if I(command) is create
    - Used if I(command) is update
    required: false
    type: str

api_key:
    description:
    - GCore API auth key
    - Can be passed as I(CLOUD_API_KEY) environment variable.
    type: str

command:
    choices:
    - create
    - update
    - delete
    description:
    - Operation to perform.
    required: true
    type: str

api_host:
    default: https://api.gcore.com/cloud
    description:
    - GCore API base host
    - Can be passed as I(CLOUD_API_HOST) environment variable.
    type: str

metadata:
    description:
    - Create one or more metadata items for a subnet
    - Used if I(command) is create
    required: false
    type: dict

region_id:
    description:
    - GCore API region ID
    - Required if I(region_name) is not passed
    - Can be passed as I(CLOUD_REGION_ID) environment variable.
    type: int

subnet_id:
    description:
    - Subnet ID
    - Required if I(command) is update or delete
    required: false
    type: str

gateway_ip:
    description:
    - Default GW IPv4 address to advertise in DHCP routes in this subnet.
    - Omit this field to let the cloud backend allocate it automatically.
    - I(connect_to_network_router) must be false when gateway_ip is null.
    - Used if I(command) is create or update
    required: false
    type: str

network_id:
    description:
    - Network ID.
    - Required if I(command) is create.
    required: false
    type: str

project_id:
    description:
    - GCore API project ID
    - Required if I(project_name) is not passed
    - Can be passed as I(CLOUD_PROJECT_ID) environment variable.
    type: int

api_timeout:
    default: 30
    description:
    - Timeout in seconds to polling GCore API
    type: int

enable_dhcp:
    description:
    - True if DHCP should be enabled.
    - Used if I(command) is create or update
    required: false
    type: bool

host_routes:
    description:
    - List of custom static routes to advertise via DHCP.
    - Used if I(command) is or update
    elements: dict
    required: false
    type: list

region_name:
    description:
    - GCore API region name
    - Required if I(region_id) is not passed
    - Can be passed as I(CLOUD_REGION_NAME) environment variable.
    type: str

project_name:
    description:
    - GCore API project name
    - Required if I(project_id) is not passed
    - Can be passed as I(CLOUD_PROJECT_NAME) environment variable.
    type: str

dns_nameservers:
    description:
    - List IP addresses of DNS servers to advertise via DHCP.
    - Used if I(command) is create or update
    elements: str
    required: false
    type: list

connect_to_network_router:
    description:
    - True if the network's router should get a gateway in this subnet.
    - Must be explicitly false when gateway_ip is null.
    - Used if I(command) is create
    required: false
    type: bool

Outputs

subnet:
  contains:
    available_ips:
      description: Number of available ips in subnet
      returned: always
      sample: 250
      type: int
    cidr:
      description: CIDR
      returned: always
      sample: 192.168.13.0/24
      type: str
    connect_to_network_router:
      description: Connecto to router
      returned: if available
      sample: true
      type: bool
    created_at:
      description: Datetime when the subnet was created
      returned: always
      sample: 2020-08-17T12:39:02+0000
      type: str
    creator_task_id:
      description: Task that created this entity
      returned: if available
      sample: 5cc890da-d031-4a23-ac31-625edfa22812
      type: str
    dns_nameservers:
      description: List IP addresses of a DNS resolver reachable from the network
      elements: str
      returned: always
      sample:
      - 8.8.8.8
      - 8.8.4.4
      type: list
    enable_dhcp:
      description: True if DHCP should be enabled
      returned: always
      sample: true
      type: bool
    gateway_ip:
      description:
      - Default GW IPv4 address, advertised in DHCP routes of this subnet.
      - If null, no gateway is advertised by this subnet
      returned: always
      sample: 192.168.13.1
      type: str
    has_router:
      description: Subnet has router attached to it
      returned: if available
      sample: false
      type: bool
    host_routes:
      description: List of custom static routes to advertise via DHCP
      elements: dict
      returned: always
      sample: []
      type: list
    id:
      description: Subnet ID
      returned: always
      sample: b39792c3-3160-4356-912e-ba396c95cdcf
      type: str
    ip_version:
      description: IP version
      returned: always
      sample: 4
      type: int
    metadata:
      description: Metadata
      elements: dict
      returned: always
      sample:
      - key: key1
        read_only: false
        value: value1
      type: list
    name:
      description: Subnet name
      returned: always
      sample: subnet_1
      type: str
    network_id:
      description: Network ID
      returned: always
      sample: b30d0de7-bca2-4c83-9c57-9e645bd2cc92
      type: str
    project_id:
      description: Project ID
      returned: always
      sample: 1
      type: int
    region:
      description: Region name
      returned: always
      sample: Luxembourg 1
      type: str
    region_id:
      description: Region ID
      returned: always
      sample: 1
      type: int
    task_id:
      description: Active task. If None, action has been performed immediately in
        the request itself
      returned: always
      sample: 907a87b0-7b63-4fd5-beb3-5ab4ba445c93
      type: str
    total_ips:
      description: Total number of ips in subnet
      returned: always
      sample: 253
      type: int
    updated_at:
      description: Datetime when the subnet was updated
      returned: always
      sample: 2020-08-17T12:39:02+0000
      type: str
  description:
  - Response depends of I(command).
  - Resource dictionary.
  returned: always
  type: complex

See also