community.digitalocean.digital_ocean_kubernetes_info 模块 – 返回有关现有 DigitalOcean Kubernetes 集群的信息

注意

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

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

要安装它,请使用: ansible-galaxy collection install community.digitalocean

要在 playbook 中使用它,请指定: community.digitalocean.digital_ocean_kubernetes_info

community.digitalocean 1.3.0 中的新增功能

概要

  • 返回有关现有 DigitalOcean Kubernetes 集群的信息。

参数

参数

注释

name

字符串 / 必需

Kubernetes 集群的可读名称。

oauth_token

别名:API_TOKEN

字符串 / 必需

DigitalOcean OAuth 令牌;可以在 DO_API_KEYDO_API_TOKENDO_OAUTH_TOKEN 环境变量中指定

return_kubeconfig

布尔值

控制是否返回 kubeconfig

选项

  • false ← (默认)

  • true

示例

- name: Get information about an existing DigitalOcean Kubernetes cluster
  community.digitalocean.digital_ocean_kubernetes_info:
    oauth_token: "{{ lookup('ansible.builtin.env', 'DO_API_TOKEN') }}"
    name: hacktoberfest
    return_kubeconfig: true
  register: my_cluster

- ansible.builtin.debug:
    msg: "Cluster name is {{ my_cluster.data.name }}, ID is {{ my_cluster.data.id }}"

- ansible.builtin.debug:
    msg: "Cluster kubeconfig is {{ my_cluster.data.kubeconfig }}"

返回值

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

描述

data

字典

DigitalOcean Kubernetes 集群(以及可选的 kubeconfig

返回:changed

示例: {"auto_upgrade": false, "cluster_subnet": "10.244.0.0/16", "created_at": "2020-09-26T21:36:18Z", "endpoint": "https://REDACTED.k8s.ondigitalocean.com", "id": "REDACTED", "ipv4": "REDACTED", "kubeconfig": "apiVersion: v1\nclusters:\n- cluster:\n    certificate-authority-data: REDACTED\n    server: https://REDACTED.k8s.ondigitalocean.com\n  name: do-nyc1-hacktoberfest\ncontexts:\n- context:\n    cluster: do-nyc1-hacktoberfest\n    user: do-nyc1-hacktoberfest-admin\n  name: do-nyc1-hacktoberfest\ncurrent-context: do-nyc1-hacktoberfest\nkind: Config\npreferences: {}\nusers:\n- name: do-nyc1-hacktoberfest-admin\n  user:\n    token: REDACTED", "maintenance_policy": {"day": "any", "duration": "4h0m0s", "start_time": "13:00"}, "name": "hacktoberfest", "node_pools": [{"auto_scale": false, "count": 1, "id": "REDACTED", "labels": null, "max_nodes": 0, "min_nodes": 0, "name": "hacktoberfest-workers", "nodes": [{"created_at": "2020-09-26T21:36:18Z", "droplet_id": "REDACTED", "id": "REDACTED", "name": "hacktoberfest-workers-3tv46", "status": {"state": "running"}, "updated_at": "2020-09-26T21:40:28Z"}], "size": "s-1vcpu-2gb", "tags": ["k8s", "k8s:REDACTED", "k8s:worker"], "taints": []}], "region": "nyc1", "service_subnet": "10.245.0.0/16", "status": {"state": "running"}, "surge_upgrade": false, "tags": ["k8s", "k8s:REDACTED"], "updated_at": "2020-09-26T21:42:29Z", "version": "1.18.8-do.0", "vpc_uuid": "REDACTED"}

作者

  • Mark Mercado (@mamercad)