Documentation

ali_route_entry - Manage route entry for Alicloud virtual private cloud,

New in version 1.5.0.

Synopsis

  • Manage route entry for Alicloud virtual private cloud. Create or Delete route entry in one route table.

Requirements

The below requirements are needed on the host that executes this module.

  • footmark >= 1.1.16
  • python >= 2.6

Parameters

Parameter Choices/Defaults Comments
alicloud_access_key
Aliyun Cloud access key. If not set then the value of environment variable ALICLOUD_ACCESS_KEY, ALICLOUD_ACCESS_KEY_ID will be used instead.

aliases: access_key_id, access_key
alicloud_region
The Aliyun Cloud region to use. If not specified then the value of environment variable ALICLOUD_REGION, ALICLOUD_REGION_ID will be used instead.

aliases: region, region_id
alicloud_secret_key
Aliyun Cloud secret key. If not set then the value of environment variable ALICLOUD_SECRET_KEY, ALICLOUD_SECRET_ACCESS_KEY will be used instead.

aliases: secret_access_key, secret_key
alicloud_security_token
The Aliyun Cloud security token. If not specified then the value of environment variable ALICLOUD_SECURITY_TOKEN will be used instead.

aliases: security_token
destination_cidrblock
The destination CIDR or Ip address of route entry. Such as:192.168.0.0/24 or 192.168.0.1. There is not the same destination cidr_block in the same route table. It is required when creating route entry.

aliases: dest_cidrblock, cidr_block
nexthop_id
The next hop ID of route entry. It is required when creating a route entry.

aliases: hop_id
nexthop_type
    Choices:
  • Instance ←
  • Tunnel
  • HaVip
  • RouterInterface
  • VpnGateway
The next hop type of route entry.

aliases: hop_type
router_id
required
The ID of virtual router to which route entry belongs.
state
    Choices:
  • present ←
  • absent
Whether or not to create, delete route entry.

Notes

Note

  • The max items of route entry no more than 48 in the same route table.
  • The destination_cidrblock can’t have the same cidr block as vswitch and can’t belong to its in the same vpc.
  • The destination_cidrblock can’t be 100.64.0.0/10 and can’t belong to it.
  • When state is ‘list’, the parameters ‘route_table_id’, ‘destination_cidrblock’ and ‘nexthop_id’ are optional.
  • If parameters are not set within the module, the following environment variables can be used in decreasing order of precedence ALICLOUD_ACCESS_KEY or ALICLOUD_ACCESS_KEY_ID, ALICLOUD_SECRET_KEY or ALICLOUD_SECRET_ACCESS_KEY, ALICLOUD_REGION or ALICLOUD_REGION_ID, ALICLOUD_SECURITY_TOKEN
  • ALICLOUD_REGION or ALICLOUD_REGION_ID can be typically be used to specify the ALICLOUD region, when required, but this can also be configured in the footmark config file

Examples

# basic provisioning example to create custom route
- name: create route entry
  hosts: localhost
  connection: local
  vars:
    alicloud_region: cn-hongkong
    state: present
    cidr_block: '192.168.4.0/24'
    nexthop_id: 'xxxxxxxxxx'
    router_id: 'XXXXXXXX'
  tasks:
    - name: create route entry
      ali_route_entry:
        alicloud_region: '{{ alicloud_region }}'
        state: '{{ state }}'
        destination_cidrblock: '{{ cidr_block }}'
        nexthop_id: '{{ nexthop_id }}'
        router_id: 'XXXXXXXX'
      register: result
    - debug: var=result

# basic provisioning example to delete custom route
- name: delete route entry
  hosts: localhost
  connection: local
  vars:
    alicloud_region: cn-hongkong
    destination_cidrblock: "192.168.4.0/24"
    next_hop_id: "xxxxxxxxxx"
    router_id: 'XXXXXXXX'
    state: present
  tasks:
    - name: delete route
      ali_route_entry:
        alicloud_region: '{{ alicloud_region }}'
        destination_cidrblock: '{{ cidr_block }}'
        nexthop_id: '{{ nexthop_id }}'
        router_id: 'XXXXXXXX'
        state: '{{ state }}'
      register: result
    - debug: var=result

# basic provisioning example to querying route entries
- name: get route entry list
  hosts: localhost
  connection: local
  vars:
    alicloud_region: cn-hongkong
    router_id: xxxxxxxxxx
    state: list
  tasks:
    - name: get vrouter list
      ali_route_entry:
        alicloud_region: '{{ alicloud_region }}'
        router_id: '{{ router_id }}'
        state: '{{ state }}'
      register: result
    - debug: var=result

Return Values

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

Key Returned Description
destination_cidrblock
string
on present and absent
the destination CIDR block of route entry

Sample:
10.0.14.0/24
destination_cidrblocks
list
on list
the list destination CIDR blocks of route entries in one route table

Sample:
['10.0.14.0/24', '10.0.13.0/24', '100.64.0.0/10']
route_entries
list
on list
Details about the ecs route entries that were retrieved in one route table.

Sample:
[{'status': 'Available', 'destination_cidrblock': '10.0.14.0/24', 'nexthop_id': 'i-2zejbnp5zv525per4g84', 'route_table_id': 'vtb-2zeeokge820zn0kqawmi9', 'type': 'Custom', 'nexthop_type': 'Instance'}, {'status': 'Available', 'destination_cidrblock': '10.0.13.0/24', 'nexthop_id': '', 'route_table_id': 'vtb-2zeeokge820zn0kqawmi9', 'type': 'System', 'nexthop_type': 'local'}]
route_entry
dict
on present
Details about the ecs route entry that was created.

Sample:
{'status': 'Available', 'destination_cidrblock': '10.0.14.0/24', 'nexthop_id': 'i-2zejbnp5zv525per4g84', 'route_table_id': 'vtb-2zeeokge820zn0kqawmi9', 'type': 'Custom', 'nexthop_type': 'Instance'}
route_table_id
string
on present and absent
the ID of route table to which route entry belongs

Sample:
vtb-2zemlj5nscgoicjnxes7h
total
int
on list
The number of all route entries after retrieving route entry.

Sample:
3


Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

Author

  • He Guimin (@xiaozhu36)

Hint

If you notice any issues in this documentation you can edit this document to improve it.