Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add arguments_specs to roles #56

Merged
merged 6 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/role_arg_specs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- "Add argument_specs.yaml to validate the role variables."
128 changes: 128 additions & 0 deletions roles/azure_load_balancer_with_public_ip/meta/argument_specs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
---
argument_specs:
main:
version_added: 2.0.0
short_description: A role to Create/Delete/Configure an Azure Load Balancer.
description:
- A role to Create/Delete/Configure an Azure Load Balancer.
- This role requires an azure user account with valid permission.
options:
azure_load_balancer_with_public_ip_operation:
description:
- Operation to perform
default: "create"
choices: ["create", "delete"]
azure_load_balancer_with_public_ip_resource_group:
description:
- Resource group on/from which the load balancer will reside.
- When O(azure_load_balancer_with_public_ip_operation) is set to create, this resource group will be created if it does not exist.
required: true
azure_load_balancer_with_public_ip_region:
description:
- An Azure location for the resources.
azure_load_balancer_with_public_ip_tags:
description:
- metadata to the resource group.
type: dict
azure_load_balancer_with_public_ip_load_balancer:
description:
- Object used to provide details for a load balancer.
type: dict
options:
name:
description: Name of the load balancer.
required: true
public_ip_name:
description: Name of load balancer's public ip.
default: "name-ip"
frontend_ip_configurations:
description: List of dict of frontend IPs and names to be used.
type: list
elements: dict
options:
name:
description: Name of the frontend ip configuration.
default: "default"
public_ip_address:
description:
- Name of existing public IP address object in the current resource group to be associated with.
default: <load balancers public ip>
backend_address_pools:
description: List of backend address pools where network interfaces can be attached.
type: list
elements: dict
options:
name:
description: Name of the backend address pool.
default: "default"
probes:
description: List of probe definitions used to check endpoint health.
type: list
elements: dict
options:
name:
description: Name of the probe.
port:
description: Probe port for communicating the probe. Possible values range from 1 to 65535, inclusive.
fail_count:
description:
- The number of probes which, if there is no response, will result in stopping further traffic from being delivered to the endpoint.
- This value allows endpoints to be taken out of rotation faster or slower than the typical times used in Azure.
default: '3'
interval:
description: Interval (in seconds) for how frequently to probe the endpoint for health status. Minimum value is '5'.
default: '15'
protocol:
description:
- Protocol of the endpoint to be probed. If 'Tcp' is specified, a received ACK is required for the probe to be successful.
- If 'Http' or 'Https' is specified, a 200 OK response from the specified URL is required for the probe to be successful.
request_path:
description:
- The URI used for requesting health status from the VM.
- Path is required if protocol=Http or protocol=Https. Otherwise, it is not allowed.
rules:
description: List of load balancing rules.
type: list
elements: dict
options:
name:
description: Name of the load balancing rule.
probe:
description: Name of the load balancer probe this rule should use.
backend_address_pool:
description: Name of backend address pool, where inbound traffic is randomly load balanced across the IPs in the pool.
frontend_ip_configuration:
description: Name of frontend ip configuration to apply rule to.
backend_port:
description:
- The port used for internal connections on the endpoint.
- Acceptable values are between 0 and 65535. Note that value 0 enables "Any Port".
enable_floating_ip:
description:
- Configures a virtual machine's endpoint mapping to the Frontend IP address of the Load Balancer instead of backend instance's IP.
frontend_port:
description:
- The port for the external endpoint.
- Frontend port numbers must be unique across all rules within the load balancer.
- Acceptable values are between 0 and 65534. Note that value 0 enables "Any Port".
idle_timeout:
description:
- The timeout for the TCP idle connection.
- The value can be set between 4 and 30 minutes.
- This element is only used when the protocol is set to TCP.
default: '4'
load_distribution:
description: Session persistence policy for this rule.
default: 'no persistence'
choices: ['SourceIP', 'SourceIPProtocol', 'no persistence']
protocol:
description: IP protocol for the rule.
choices: ['Tcp', 'Udp', 'All']
sku:
description:
- Load balancer SKU.
- Will also be applied to the public ip generated for the load balancer.
choices: ['Basic', 'Standard']
tags:
description: Metadata to the load balancer.
type: dict
15 changes: 0 additions & 15 deletions roles/azure_load_balancer_with_public_ip/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
---
- name: Check azure_load_balancer_with_public_ip_operation validation
ansible.builtin.fail:
msg: Please provide azure_load_balancer_with_public_ip_operation as 'create' or 'delete'
when: azure_load_balancer_with_public_ip_operation not in ['create', 'delete']

- name: Ensure resource group is defined
ansible.builtin.fail:
msg: Azure resource group must be defined as azure_load_balancer_with_public_ip_resource_group
when: azure_load_balancer_with_public_ip_resource_group is not defined

- name: Ensure load balancer name is defined
ansible.builtin.fail:
msg: Azure load balancer name must be defined as azure_load_balancer_with_public_ip_load_balancer.name
when: azure_load_balancer_with_public_ip_load_balancer.name is not defined

- name: Get load balancer info
azure.azcollection.azure_rm_loadbalancer_info:
resource_group: "{{ azure_load_balancer_with_public_ip_resource_group }}"
Expand Down
95 changes: 95 additions & 0 deletions roles/azure_manage_network_interface/meta/argument_specs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
argument_specs:
main:
version_added: 2.0.0
short_description: A role to Create/Delete/Configure an Azure Network Interface.
description:
- A role to Create/Delete/Configure an Azure Network Interface.
- This role requires an azure user account with valid permission.
options:
azure_manage_network_interface_operation:
description:
- Operation to perform
default: "create"
choices: ["create", "delete"]
azure_manage_network_interface_resource_group:
description:
- Resource group.
required: true
azure_manage_network_interface_interface:
description:
- Object used to provide details for a network interface.
type: dict
options:
name:
description: Name of the network interface.
required: true
vnet_name:
description:
- Name of the existing azure virtual network where the network interface will reside.
- Required when O(azure_manage_network_interface_operation=create).
subnet_name:
description:
- Name of the existing azure subnet where the network interface will reside.
- Required when O(azure_manage_network_interface_operation=create).
security_group_name:
description:
- Name of the existing security group with which to associate the network interface.
- If not provided, a default security group will be created when O(create_with_security_group=true).
create_with_security_group:
description: Whether or not a default security group should be created with the network interface.
type: bool
default: true
os_type:
description:
- Determines any rules to be added to a network interface's default security group.
- If O(os_type=Windows), a rule allowing RDP access will be added.
- If O(os_type=Linux), a rule allowing SSH access will be added.
enable_accelerated_networking:
description: Set to V(yes) to enable accelerated networking.
type: bool
ip_forwarding:
description: Set to V(yes) to enable ip forwarding.
type: bool
dns_servers:
description: List of IP addresses representing which DNS servers the network interface should look up.
type: list
ip_configurations:
description: List of IP configurations.
type: list
elements: dict
options:
name:
description: Name of the IP configuration.
required: true
primary:
description:
- Set to V(yes) to make IP configuration the primary one.
- The first IP configuration is by default set to O(primary=yes).
application_security_groups:
description: List of application security groups in which the IP configuration is included.
type: list
elements: str
load_balancer_backend_address_pools:
description: List of existing load balancer backend address pools in which the network interface will be load balanced.
type: list
elements: str
private_ip_address:
description: Private IP address for the IP configuration.
private_ip_address_version:
description: Ip version.
default: 'IPv4'
choices: ['IPv4', 'IPv6']
private_ip_allocation_method:
description: Ip allocation method.
default: 'Dynamic'
choices: ['Dynamic', 'Static']
public_ip_address_name:
description: Name of the existing public IP address to be assigned to the network interface.
public_ip_allocation_method:
description: Ip allocation method.
default: 'Dynamic'
choices: ['Dynamic', 'Static']
tags:
description: Metadata for the network interface.
type: dict
15 changes: 0 additions & 15 deletions roles/azure_manage_network_interface/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
---
- name: Check operation validation
ansible.builtin.fail:
msg: Please provide azure_manage_network_interface_operation as 'create' or 'delete'
when: azure_manage_network_interface_operation not in ['create', 'delete']

- name: Ensure resource group is defined
ansible.builtin.fail:
msg: Azure resource group name must be defined as azure_manage_network_interface_resource_group
when: azure_manage_network_interface_resource_group is not defined

- name: Ensure network interface name is defined
ansible.builtin.fail:
msg: "Missing parameter: key 'name' not found in azure_manage_network_interface_interface"
when: azure_manage_network_interface_interface.name is not defined

- name: Get resource group info
azure.azcollection.azure_rm_resourcegroup_info:
name: "{{ azure_manage_network_interface_resource_group }}"
Expand Down
48 changes: 48 additions & 0 deletions roles/azure_manage_networking_stack/meta/argument_specs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
argument_specs:
main:
version_added: 2.0.0
short_description: A role to Create/Delete/Configure an Azure Network Interface.
description:
- This role create/delete azure networking stack which include virtual network and add/delete a subnet.
- It will also create the resource group on which the networking stack should be attached, if not existing.
- This role requires an azure user account with valid permission.
options:
azure_manage_networking_stack_operation:
description:
- Operation to perform
choices: ["create", "delete"]
required: true
azure_manage_networking_stack_delete_option:
description:
- When deleting created resources, this is used to specified wether to remove only the subnet, the virtual network or all (including resource group).
default: 'all'
choices: ['subnet', 'virtual_network', 'all']
azure_manage_networking_stack_resource_group:
description:
- Resource group on which the networking stack should be attached.
required: true
azure_manage_networking_stack_virtual_network:
description:
- Name of the virtual network to create/delete.
azure_manage_networking_stack_subnet:
description:
- Name of the subnet to create/delete.
azure_manage_networking_stack_security_group:
description:
- Existing security group with which to associate the subnet.
azure_manage_networking_stack_region:
description: An Azure location for the virtual network to create.
azure_manage_networking_stack_vnet_address_prefixes_cidr:
description:
- List of IPv4 address ranges for virtual network where each is formatted using CIDR notation.
- Required when creating a new virtual network.
type: list
elements: str
azure_manage_networking_stack_subnet_address_prefixes_cidr:
description:
- CIDR defining the IPv4 and IPv6 address space of the subnet.
- Must be valid within the context of the virtual network.
azure_manage_networking_stack_tags:
description: Dictionary of string:string pairs to assign as metadata to the object.
type: dict
Loading
Loading