Documentation

ali_security_group_facts - Gather facts on security group of Alibaba Cloud ECS.

New in version 2.8.

Synopsis

  • This module fetches data from the Open API in Alicloud. The module must be called from within the ECS security group itself.

Requirements

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

  • footmark >= 1.7.0
  • 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
filters
A dict of filters to apply. Each dict item consists of a filter key and a filter value. The filter keys can be all of request parameters. See https://www.alibabacloud.com/help/doc-detail/25556.htm for parameter details. Filter keys can be same as request parameter name or be lower case and use underscores ("_") or dashes ("-") to connect different words in one parameter. "Tag.n.Key" and "Tag.n.Value" use new filter tags instead and it should be a dict. "SecurityGroupIds" should be a list and it will be appended to group_ids automatically.
group_ids
A list of ECS security group IDs.

aliases: ids
group_name
(Deprecated) Name of the security group. New option `name_prefix` instead.

aliases: name
name_prefix
Use a Security Group name prefix to filter security group.
tags
A hash/dictionaries of security group tags. {"key":"value"}

Notes

Note

  • 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

# Note: These examples do not set authentication details, see the Alibaba Cloud Guide for details.

# Gather facts about all security groups
- ali_security_group_facts:

# Gather facts about all security groups in a specific VPC
- ali_security_group_facts:
    filters:
      vpc-id: vpc-12345678

# Gather facts about a security group using a name_prefix
- ali_security_group_facts:
    name_prefix: example

# Gather facts about a security group by id
- ali_security_group_facts:
    group_ids:
      - sg-12345678
      - sg-cnqwu234

# Gather facts about any security group with a tag key Name and value Example.
- ali_security_group_facts:
    tags:
      name: Example
      env: dev

Return Values

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

Key Returned Description
groups
complex
always
Returns an array of complex objects as described below.

  description
string
always
The Security Group description.

Sample:
my ansible group
  tags
dict
always
Tags associated with the security group

  permissions_egress
list
always
Outbound rules associated with the security group.

Sample:
[{'ip_protocol': -1, 'ip_ranges': [{'nic_type': 'intranet', 'direction': 'egress', 'dest_cidr_ip': '192.168.0.54/32', 'description': 'NOne', 'create_time': '2018-06-28T08:45:59Z', 'source_cidr_ip': 'None', 'ip_protocol': 'TCP', 'source_group_owner_account': 'None', 'dest_group_owner_account': 'None', 'dest_group_name': 'None', 'priority': 1, 'port_range': '80/80', 'source_group_id': 'None', 'policy': 'Accept', 'source_group_name': 'None', 'dest_group_id': 'None'}]}]
  group_name
string
always
Security group name

Sample:
my-ansible-group
  inner_access_policy
bool
always
Whether can access each other in one security group.

Sample:
True
  vpc_id
string
always
ID of VPC to which the security group belongs

Sample:
vpc-abcd1234
  group_id
string
always
Security group id

Sample:
sg-abcd1234
  id
string
always
Alias of "group_id".

Sample:
sg-abcd1234
  permissions
list
always
Inbound rules associated with the security group.

Sample:
[{'nic_type': 'intranet', 'direction': 'ingress', 'dest_cidr_ip': 'None', 'description': 'None', 'create_time': '2018-06-28T08:45:58Z', 'source_cidr_ip': '0.0.0.0/0', 'ip_protocol': 'TCP', 'source_group_owner_account': 'None', 'dest_group_owner_account': 'None', 'dest_group_name': 'None', 'priority': 1, 'port_range': '22/22', 'source_group_id': 'None', 'policy': 'Accept', 'source_group_name': 'None', 'dest_group_id': 'None'}]
ids
list
always
list IDs of security groups

Sample:
['sg-2ze12578be1ls4wcjhfd', 'sg-2ze28n1vj1iqztxp7p6h']


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.