community.aws.elb_target 模块 – 管理目标组中的目标

注意

此模块是 community.aws 集合 (版本 9.0.0) 的一部分。

如果您正在使用 ansible 包,您可能已经安装了此集合。 它不包含在 ansible-core 中。 要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install community.aws。 您需要其他要求才能使用此模块,请参阅 要求 了解详情。

要在 playbook 中使用它,请指定:community.aws.elb_target

community.aws 1.0.0 中的新增功能

概要

  • 用于在目标组中注册或注销目标。

要求

执行此模块的主机需要满足以下要求。

  • python >= 3.6

  • boto3 >= 1.28.0

  • botocore >= 1.31.0

参数

参数

注释

access_key

别名: aws_access_key_id, aws_access_key, ec2_access_key

字符串

AWS 访问密钥 ID。

有关访问令牌的更多信息,请参阅 AWS 文档 https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys

也可以按优先级降序使用 AWS_ACCESS_KEY_IDAWS_ACCESS_KEYEC2_ACCESS_KEY 环境变量。

aws_access_keyprofile 选项是互斥的。

为了与 AWS botocore SDK 保持一致,在 5.1.0 版本中添加了 aws_access_key_id 别名。

ec2_access_key 别名已被弃用,将在 2024-12-01 之后的版本中删除。

EC2_ACCESS_KEY 环境变量的支持已被弃用,将在 2024-12-01 之后的版本中删除。

aws_ca_bundle

路径

用于验证 SSL 证书的 CA 包的位置。

也可以使用 AWS_CA_BUNDLE 环境变量。

aws_config

字典

用于修改 botocore 配置的字典。

可以在 AWS 文档中找到参数 https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html#botocore.config.Config

debug_botocore_endpoint_logs

布尔值

使用 botocore.endpoint 记录器解析任务期间发出的唯一(而不是总共)"resource:action" API 调用,将集合输出到任务结果中的 resource_actions 键。 使用 aws_resource_action 回调输出 playbook 期间制作的总列表。

也可以使用 ANSIBLE_DEBUG_BOTOCORE_LOGS 环境变量。

选择

  • false ← (默认)

  • true

deregister_unused

布尔值

未使用的目标的默认行为是保留注册状态。

如果相反您想删除它们,请设置 deregister_unused=true

选择

  • false ← (默认)

  • true

endpoint_url

别名: ec2_url, aws_endpoint_url, s3_url

字符串

连接到 AWS 默认端点以外的 URL。虽然这可以用于连接到其他与 AWS 兼容的服务,但 amazon.aws 和 community.aws 集合仅针对 AWS 进行了测试。

也可以按优先级降序使用 AWS_URLEC2_URL 环境变量。

ec2_urls3_url 别名已被弃用,将在 2024-12-01 之后的版本中删除。

EC2_URL 环境变量的支持已被弃用,将在 2024-12-01 之后的版本中删除。

profile

别名: aws_profile

字符串

用于身份验证的命名 AWS 配置文件。

有关命名配置文件的更多信息,请参阅 AWS 文档 https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html

也可以使用 AWS_PROFILE 环境变量。

profile 选项与 aws_access_keyaws_secret_keysecurity_token 选项互斥。

region

别名: aws_region, ec2_region

字符串

要使用的 AWS 区域。

对于 IAM、Route53 和 CloudFront 等全局服务,将忽略 region

也可以使用 AWS_REGIONEC2_REGION 环境变量。

有关更多信息,请参阅 Amazon AWS 文档 http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region

ec2_region 别名已被弃用,将在 2024-12-01 之后的版本中删除

EC2_REGION 环境变量的支持已被弃用,将在 2024-12-01 之后的版本中删除。

secret_key

别名: aws_secret_access_key, aws_secret_key, ec2_secret_key

字符串

AWS 秘密访问密钥。

有关访问令牌的更多信息,请参阅 AWS 文档 https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys

也可以使用 AWS_SECRET_ACCESS_KEYAWS_SECRET_KEYEC2_SECRET_KEY 环境变量,优先级依次降低。

secret_keyprofile 选项互斥。

为了与 AWS botocore SDK 保持一致,在 5.1.0 版本中添加了 aws_secret_access_key 别名。

ec2_secret_key 别名已被弃用,将在 2024-12-01 之后的版本中删除。

EC2_SECRET_KEY 环境变量的支持已被弃用,将在 2024-12-01 之后的版本中删除。

session_token

别名: aws_session_token, security_token, aws_security_token, access_token

字符串

用于临时凭证的 AWS STS 会话令牌。

有关访问令牌的更多信息,请参阅 AWS 文档 https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys

也可以使用 AWS_SESSION_TOKENAWS_SECURITY_TOKENEC2_SECURITY_TOKEN 环境变量,优先级依次降低。

security_tokenprofile 选项互斥。

别名 aws_session_tokensession_token 在 3.2.0 版本中添加,参数在 6.0.0 版本中从 security_token 重命名为 session_token

security_tokenaws_security_tokenaccess_token 别名已被弃用,将在 2024-12-01 之后的版本中删除。

EC2_SECRET_KEYAWS_SECURITY_TOKEN 环境变量的支持已被弃用,将在 2024-12-01 之后的版本中删除。

state

string / 必选

注册或注销目标。

选择

  • "present"

  • "absent"

target_az

字符串

一个可用区或 all。这将确定目标是否从指定可用区中的负载均衡器节点或从负载均衡器的所有已启用可用区接收流量。如果目标组的目标类型为实例,则不支持此参数。

target_group_arn

字符串

目标组的 Amazon 资源名称 (ARN)。

target_group_name 互斥。

target_group_name

字符串

目标组的名称。

target_group_arn 互斥。

target_id

string / 必选

目标的 ID。

target_port

integer

目标正在侦听的端口。您可以指定端口覆盖。如果目标已注册,您可以再次使用不同的端口注册它。

目标的默认端口是目标组的端口。

target_status

字符串

阻塞并等待目标状态等于给定值。有关目标状态的更多详细信息,请参阅 https://docs.aws.amazon.com/elasticloadbalancing/latest/application/target-group-health-checks.html#target-health-states

选择

  • "initial"

  • "healthy"

  • "unhealthy"

  • "unused"

  • "draining"

  • "unavailable"

target_status_timeout

integer

等待 target_status 更改的最大秒数。

默认值: 60

validate_certs

布尔值

设置为 false 时,将不会验证与 AWS API 通信的 SSL 证书。

强烈建议不要设置 validate_certs=false,作为替代方案,请考虑设置 aws_ca_bundle

选择

  • false

  • true ← (默认)

说明

注意

  • 如果在注册目标时指定了端口覆盖,则在注销目标时必须同时指定目标 ID 和端口。

  • 注意: 对于模块,环境变量和配置文件是从 Ansible “主机” 上下文中读取的,而不是从 “控制器” 上下文中读取的。因此,可能需要将文件显式复制到“主机”。对于查找和连接插件,环境变量和配置文件是从 Ansible “控制器” 上下文中读取的,而不是从 “主机” 上下文中读取的。

  • Ansible 使用的 AWS SDK (boto3) 也可能从其在 Ansible “主机” 上下文中的配置文件(通常为 ~/.aws/credentials)读取凭证和其他设置(例如区域)的默认值。有关更多信息,请参阅 https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html

示例

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

- name: Register an IP address target to a target group
  community.aws.elb_target:
    target_group_name: myiptargetgroup
    target_id: i-1234567
    state: present

- name: Register an instance target to a target group
  community.aws.elb_target:
    target_group_name: mytargetgroup
    target_id: i-1234567
    state: present

- name: Deregister a target from a target group
  community.aws.elb_target:
    target_group_name: mytargetgroup
    target_id: i-1234567
    state: absent

# Modify a target to use a different port
- name: Register a target to a target group
  community.aws.elb_target:
    target_group_name: mytargetgroup
    target_id: i-1234567
    target_port: 8080
    state: present

作者

  • Rob White (@wimnat)