community.aws.eks_fargate_profile 模块 – 管理 EKS Fargate Profile

注意

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

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

要安装它,请使用:ansible-galaxy collection install community.aws。您需要其他要求才能使用此模块,有关详细信息,请参阅 要求

要在剧本中使用它,请指定:community.aws.eks_fargate_profile

community.aws 4.0.0 中的新增功能

概要

  • 管理 EKS Fargate Profile。

要求

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

  • 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 保持一致,aws_access_key_id 别名是在 5.1.0 版本中添加的。

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

cluster_name

字符串 / 必需

EKS 集群的名称。

debug_botocore_endpoint_logs

布尔值

使用 botocore.endpoint 记录器来解析在任务期间执行的唯一(而不是总计)"resource:action" API 调用,并将集合输出到任务结果中的 resource_actions 密钥。使用 aws_resource_action 回调将输出到剧本期间执行的总列表。

还可以使用 ANSIBLE_DEBUG_BOTOCORE_LOGS 环境变量。

选项

  • false ← (默认)

  • true

endpoint_url

别名:ec2_url、aws_endpoint_url、s3_url

字符串

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

还可以按优先级递减的顺序使用 AWS_URLEC2_URL 环境变量。

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

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

name

字符串 / 必需

EKS Fargate 配置文件名称。

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 选项互斥。

purge_tags

布尔值

如果 purge_tags=true 且设置了 tags,则将从资源中清除现有标签,以完全匹配 tags 参数定义的内容。

如果未设置 tags 参数,则即使 purge_tags=True,也不会修改标签。

aws: 开头的标签键由 Amazon 保留,无法修改。因此,在 purge_tags 参数中将忽略它们。有关更多信息,请参阅 Amazon 文档 https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html#tag-conventions

选项

  • false

  • true ← (默认)

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 之后的发行版中移除。

role_arn

字符串

EKS 集群使用的 IAM 角色的 ARN。

state=present 时必需。

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 之后的发行版中移除。

selectors

列表 / 元素=字典

在 Fargate 配置文件中使用的选择器列表。

state=present 时必需。

labels

字典

Fargate 配置文件中使用的标签字典。

默认值: {}

namespace

字符串

Fargate 配置文件中使用的命名空间。

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 选项互斥。

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

security_tokenaws_security_tokenaccess_token 别名已弃用,将在 2024-12-01 之后的发行版中移除。

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

state

字符串

创建或删除 Fargate 配置文件。

选项

  • "absent"

  • "present" ← (默认)

subnets

列表 / 元素=字符串

Kubernetes 集群的子网 ID 列表。

state=present 时必需。

tags

别名:resource_tags

字典

表示要应用于资源的标签的字典。

如果未设置 tags 参数,则不会修改标签。

validate_certs

布尔值

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

强烈建议不要设置 validate_certs=false,可以考虑改为设置 aws_ca_bundle

选项

  • false

  • true ← (默认)

wait

布尔值

指定模块在继续之前是否等待配置文件创建或删除完成。

选项

  • false ← (默认)

  • true

wait_timeout

整数

等待集群变为活动状态的持续时间(以秒为单位)。默认为 1200 秒(20 分钟)。

默认值: 1200

备注

注意

  • 注意:对于模块,环境变量和配置文件是从 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: Create an EKS Fargate Profile
  community.aws.eks_fargate_profile:
    name: test_fargate
    cluster_name: test_cluster
    role_arn: my_eks_role
    subnets:
      - subnet-aaaa1111
    selectors:
      - namespace: nm-test
        labels:
          - label1: test
    state: present
    wait: true

- name: Remove an EKS Fargate Profile
  community.aws.eks_fargate_profile:
    name: test_fargate
    cluster_name: test_cluster
    wait: true
    state: absent

返回值

常用的返回值已在此处记录 此处,以下是此模块独有的字段。

Key

描述

cluster_name

字符串

EKS 集群的名称。

返回:当 state 为 present 时

示例: "test-cluster"

created_at

字符串

Fargate 配置文件的创建日期和时间。

返回:当 state 为 present 时

示例: "2022-01-18T20:00:00.111000+00:00"

fargate_profile_arn

字符串

Fargate 配置文件的 ARN。

返回:当 state 为 present 时

示例: "arn:aws:eks:us-east-1:1231231123:safd"

fargate_profile_name

字符串

Fargate 配置文件名称。

返回:当 state 为 present 时

示例: "test_profile"

pod_execution_role_arn

字符串

Fargate 配置文件使用的 IAM 角色的 ARN。

返回:当 state 为 present 时

示例: "arn:aws:eks:us-east-1:1231231123:role/asdf"

selectors

complex

选择器配置。

返回:当 state 为 present 时

labels

列表 / 元素=字符串

配置文件中使用的 Kubernetes 标签列表。

返回:当 state 为 present 时

示例: [{"label1": "test1"}, {"label2": "test2"}]

namespace

字符串

配置文件中使用的 Kubernetes 命名空间名称。

返回:当 state 为 present 时

示例: "nm-test"

status

字符串

EKS Fargate 配置文件的状态。

返回:当 state 为 present 时

示例: "['CREATING', 'ACTIVE']"

subnets

列表 / 元素=字符串

Fargate 配置文件中使用的子网列表。

返回:当 state 为 present 时

示例: ["subnet-qwerty123", "subnet-asdfg456"]

tags

字典

资源标签字典。

返回:当 state 为 present 时

示例: {"env": "test", "foo": "bar"}

作者

  • Tiago Jarra (@tjarra)