hwceco.hwcollection.hwc_vpc_security_group_rule – Creates a resource of Vpc/SecurityGroupRule in Huawei Cloud

Note

This plugin is part of the hwceco.hwcollection collection (version 1.0.5).

To install it use: ansible-galaxy collection install hwceco.hwcollection.

To use it in a playbook, specify: hwceco.hwcollection.hwc_vpc_security_group_rule.

New in version 1.0.0: of hwceco.hwcollection

Synopsis

  • Creates and manages a resource of Vpc/SecurityGroupRule in Huawei Cloud.

Requirements

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

  • huaweicloudsdkcore >= 3.0.47

  • huaweicloudsdkvpc >= 3.0.47

Parameters

Parameter Choices/Defaults Comments
access_key
string / required
Specifies the access key of the HuaweiCloud to use.
cloud
string
Default:
"myhuaweicloud.com"
Specifies the endpoint of the cloud. Required if you are using other cloud supported by Huaweicloud.
description
string
Provides supplementary information about the security group rule. The value is a string of no more than 255 characters that can contain letters and digits.
direction
string / required
Specifies the direction of access control. The value can be egress or ingress.
ethertype
string
Specifies the IP protocol version. The value can be IPv4 or IPv6. If you do not set this parameter, IPv4 is used by default.
filters
list / elements=string / required
A list of filters to apply when deciding whether existing resources match and should be altered. The item of filters is the name of input options.
identity_endpoint
string
Default:
"https://iam.myhuaweicloud.com:443/v3"
Specifies the Identity authentication URL. Required if you are using other cloud supported by Huaweicloud.
port_range_max
integer
Specifies the end port number. The value ranges from 1 to 65535. If the protocol is not icmp, the value cannot be smaller than the port_range_min value. An empty value indicates all ports.
port_range_min
integer
Specifies the start port number. The value ranges from 1 to 65535. The value cannot be greater than the port_range_max value. An empty value indicates all ports.
project_id
string / required
Specifies the of ID of the project to login with.
protocol
string
Specifies the protocol type. The value can be icmp, tcp, or udp. If the parameter is left blank, the security group supports all protocols.
region
string / required
Specifies the Huawei Cloud region.
remote_group_id
string
Specifies the ID of the peer security group. The value is exclusive with parameter remote_ip_prefix.
remote_ip_prefix
string
Specifies the remote IP address. If the access control direction is set to egress, the parameter specifies the source IP address. If the access control direction is set to ingress, the parameter specifies the destination IP address. The value can be in the CIDR format or IP addresses. The parameter is exclusive with parameter remote_group_id.
secret_key
string / required
Specifies the secret key of the HuaweiCloud to use.
security_group_id
string / required
Specifies the security group rule ID, which uniquely identifies the security group rule.
state
string
    Choices:
  • present ←
  • absent
Whether the given object should exist in Huawei Cloud.

Notes

Note

  • For authentication, you can set access_key using the `ANSIBLE_HWC_ACCESS_KEY’ env variable.

  • For authentication, you can set secret_key using the `ANSIBLE_HWC_SECRET_KEY’ env variable.

  • For authentication, you can set project_id using the `ANSIBLE_HWC_PROJECT_ID’ env variable.

  • For authentication, you can set region using the `ANSIBLE_HWC_REGION’ env variable.

  • For authentication, you can set identity_endpoint using the `ANSIBLE_HWC_IDENTITY_ENDPOINT’ env variable.

  • For authentication, you can set cloud using the `ANSIBLE_HWC_CLOUD’ env variable.

  • Environment variables values will only be used if the playbook values are not set.

Examples

# create a security group rule
- name: create a security group
  hwc_vpc_security_group:
    name: "ansible_network_security_group_test"
    filters:
      - "name"
  register: sg
- name: create a security group rule
  hwc_vpc_security_group_rule:
    direction: "ingress"
    protocol: "tcp"
    ethertype: "IPv4"
    port_range_max: 22
    security_group_id: "{{ sg.state.id }}"
    port_range_min: 22
    filters:
      - "security_group_id"
    remote_ip_prefix: "0.0.0.0/0"

Return Values

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

Key Returned Description
description
string
success
Provides supplementary information about the security group rule. The value is a string of no more than 255 characters that can contain letters and digits.

direction
string
success
Specifies the direction of access control. The value can be egress or ingress.

ethertype
string
success
Specifies the IP protocol version. The value can be IPv4 or IPv6. If you do not set this parameter, IPv4 is used by default.

port_range_max
integer
success
Specifies the end port number. The value ranges from 1 to 65535. If the protocol is not icmp, the value cannot be smaller than the port_range_min value. An empty value indicates all ports.

port_range_min
integer
success
Specifies the start port number. The value ranges from 1 to 65535. The value cannot be greater than the port_range_max value. An empty value indicates all ports.

protocol
string
success
Specifies the protocol type. The value can be icmp, tcp, or udp. If the parameter is left blank, the security group supports all protocols.

remote_group_id
string
success
Specifies the ID of the peer security group. The value is exclusive with parameter remote_ip_prefix.

remote_ip_prefix
string
success
Specifies the remote IP address. If the access control direction is set to egress, the parameter specifies the source IP address. If the access control direction is set to ingress, the parameter specifies the destination IP address. The value can be in the CIDR format or IP addresses. The parameter is exclusive with parameter remote_group_id.

security_group_id
string
success
Specifies the security group rule ID, which uniquely identifies the security group rule.



Authors

  • Huawei (@huaweicloud)