gcore.cloud.router (1.0.1) — module

Manages routers

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/delete or attach/detach router

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create new router
  gcore.cloud.router:
    api_key: "{{ api_key }}"
    region_id: "{{ region_id }}"
    project_id: "{{ project_id }}"
    command: create
    name: "my-router"
    external_gateway_info: {'enable_snat': True, 'type': 'default'}
    interfaces: [{'subnet_id': "{{ subnet_id }}", 'type': 'subnet'}]
    routes: [{'destination': '10.0.3.0/24', 'nexthop': '10.0.0.13'}]
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Update router
  gcore.cloud.router:
    api_key: "{{ api_key }}"
    region_id: "{{ region_id }}"
    project_id: "{{ project_id }}"
    command: update
    router_id: "{{ router_id }}"
    name: "new-router-name"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Attach router
  gcore.cloud.router:
    api_key: "{{ api_key }}"
    region_id: "{{ region_id }}"
    project_id: "{{ project_id }}"
    command: attach
    router_id: "{{ router_id }}"
    subnet_id: "{{ subnet_id }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Detach router
  gcore.cloud.router:
    api_key: "{{ api_key }}"
    region_id: "{{ region_id }}"
    project_id: "{{ project_id }}"
    command: detach
    router_id: "{{ router_id }}"
    subnet_id: "{{ subnet_id }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Delete router
  gcore.cloud.router:
    api_key: "{{ api_key }}"
    region_id: "{{ region_id }}"
    project_id: "{{ project_id }}"
    command: delete
    router_id: "{{ router_id }}"

Inputs

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

routes:
    description:
    - List of custom routes.
    - Used if I(command) is create or update
    elements: dict
    required: false
    type: list

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

command:
    choices:
    - create
    - update
    - delete
    - attach
    - detach
    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

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

router_id:
    description:
    - The ID of the router you want to get.
    - Required if I(command) one of create, update, delete, attach or detach
    required: false
    type: str

subnet_id:
    description:
    - Subnet ID.
    - Target IP is identified by it's subnet.
    - Required if I(command) is attach or detach.
    required: false
    type: str

interfaces:
    description:
    - List of interfaces to attach to router immediately after creation.
    - Used if I(command) is create
    elements: dict
    required: false
    type: list

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

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

external_gateway_info:
    description:
    - External gateway info.
    - Used if I(command) is create create or update
    required: false
    type: dict

Outputs

router:
  contains:
    created_at:
      description: Datetime when the router was created
      returned: always
      sample: 2023-11-09T10:34:23+0000
      type: str
    creator_task_id:
      description: Task that created this entity
      returned: always
      sample: 4d7bc56d-9b2e-46be-8a6e-e0f8102c5cc5
      type: str
    external_gateway_info:
      description: State of this router's external gateway
      returned: always
      sample:
        enable_snat: true
        external_fixed_ips:
        - ip_address: 10.94.77.162
          subnet_id: db5ebada-a86a-4702-8a19-00b23a1acb05
        network_id: 340d7d54-e165-4d83-b99c-103ce0e6efa7
      type: dict
    id:
      description: Router ID
      returned: always
      sample: 4d380efe-aecd-4aa1-82a8-573632ed37f9
      type: str
    interfaces:
      description: List of router interfaces
      elements: dict
      returned: always
      sample:
      - subnet_id: d0a6bd13-81b9-415b-8362-b3f711baf6ac
        type: subnet
      type: list
    name:
      description: Router name
      returned: always
      sample: router_1
      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
    routes:
      description: List of custom routes
      elements: dict
      returned: always
      sample:
      - destination: 10.0.3.0/24
        nexthop: 10.0.0.13
      type: list
    status:
      description: Status of the router
      returned: always
      sample: ACTIVE
      type: str
    task_id:
      description: Active task. If None, action has been performed immediately in
        the request itself
      returned: present
      sample: 907a87b0-7b63-4fd5-beb3-5ab4ba445c93
      type: str
    updated_at:
      description: Datetime when the router was last updated
      returned: always
      sample: 2023-11-09T10:34:24+0000
      type: str
  description:
  - Response depends of I(command).
  - Resource dictionary.
  returned: always
  type: complex

See also