• 博客
  • Ansible 社区论坛
  • 文档
Ansible Logo
Ansible 社区文档
Ansible

Ansible 入门

  • Ansible 入门指南
  • 执行环境入门指南

安装、升级和配置

  • 安装指南
  • Ansible 移植指南

使用 Ansible

  • 构建 Ansible 清单
  • 使用 Ansible 命令行工具
  • 使用 Ansible playbook
  • 使用 Ansible vault 保护敏感数据
  • 使用 Ansible 模块和插件
  • 使用 Ansible 集合
  • 在 Windows 和 BSD 上使用 Ansible
  • Ansible 提示和技巧

为 Ansible 作出贡献

  • Ansible 社区指南
  • Ansible 集合贡献者指南
  • ansible-core 贡献者指南
  • 高级贡献者指南
  • Ansible 文档风格指南

扩展 Ansible

  • 开发者指南

常见的 Ansible 场景

  • 旧版公有云指南

网络自动化

  • 网络入门
  • 网络高级主题
  • 网络开发者指南

Ansible Galaxy

  • Galaxy 用户指南
  • Galaxy 开发者指南

参考和附录

  • 集合索引
    • Amazon 命名空间中的集合
    • Ansible 命名空间中的集合
    • Arista 命名空间中的集合
    • AWX 命名空间中的集合
    • Azure 命名空间中的集合
    • Check Point 命名空间中的集合
    • Chocolatey 命名空间中的集合
    • Cisco 命名空间中的集合
    • Cloud 命名空间中的集合
    • Cloudscale_ch 命名空间中的集合
    • Community 命名空间中的集合
      • Community.Aws
      • Community.Ciscosmb
      • Community.Crypto
      • Community.Digitalocean
      • Community.Dns
      • Community.Docker
      • Community.General
        • 描述
        • 沟通
        • 变更日志
        • 指南
        • 云指南
        • 开发者指南
        • 插件索引
      • Community.Grafana
      • Community.Hashi_Vault
      • Community.Hrobot
      • Community.Library_Inventory_Filtering_V1
      • Community.Libvirt
      • Community.Mongodb
      • Community.Mysql
      • Community.Network
      • Community.Okd
      • Community.Postgresql
      • Community.Proxysql
      • Community.Rabbitmq
      • Community.Routeros
      • Community.Sap_Libs
      • Community.Sops
      • Community.Vmware
      • Community.Windows
      • Community.Zabbix
    • 容器命名空间中的集合
    • Cyberark 命名空间中的集合
    • Dellemc 命名空间中的集合
    • F5networks 命名空间中的集合
    • Fortinet 命名空间中的集合
    • Frr 命名空间中的集合
    • Gluster 命名空间中的集合
    • Google 命名空间中的集合
    • Grafana 命名空间中的集合
    • Hetzner 命名空间中的集合
    • Hpe 命名空间中的集合
    • IBM 命名空间中的集合
    • Ieisystem 命名空间中的集合
    • Infinidat 命名空间中的集合
    • Infoblox 命名空间中的集合
    • Inspur 命名空间中的集合
    • Junipernetworks 命名空间中的集合
    • Kaytus 命名空间中的集合
    • Kubernetes 命名空间中的集合
    • Kubevirt 命名空间中的集合
    • Lowlydba 命名空间中的集合
    • Mellanox 命名空间中的集合
    • Microsoft 命名空间中的集合
    • Netapp 命名空间中的集合
    • Netapp_eseries 命名空间中的集合
    • Netbox 命名空间中的集合
    • Ngine_io 命名空间中的集合
    • Openstack 命名空间中的集合
    • Openvswitch 命名空间中的集合
    • Ovirt 命名空间中的集合
    • Purestorage 命名空间中的集合
    • Sensu 命名空间中的集合
    • Servicenow 命名空间中的集合
    • Splunk 命名空间中的集合
    • T_systems_mms 命名空间中的集合
    • Telekom_mms 命名空间中的集合
    • Theforeman 命名空间中的集合
    • Vmware 命名空间中的集合
    • Vultr 命名空间中的集合
    • Vyos 命名空间中的集合
    • Wti 命名空间中的集合
  • 所有模块和插件的索引
  • Playbook 关键字
  • 返回值
  • Ansible 配置设置
  • 控制 Ansible 的行为:优先级规则
  • YAML 语法
  • Python 3 支持
  • 解释器发现
  • 发布和维护
  • 测试策略
  • 健全性测试
  • 常见问题
  • 术语表
  • Ansible 参考:模块实用程序
  • 特殊变量
  • Red Hat Ansible Automation Platform
  • Ansible Automation Hub
  • 记录 Ansible 输出

路线图

  • Ansible 路线图
  • ansible-core 路线图




Ansible
  • 集合索引
  • Community 命名空间中的集合
  • Community.General
  • community.general.clc_server 模块 – 在 CenturyLink 云中创建、删除、启动和停止服务器
  • 在 GitHub 上编辑

community.general.clc_server 模块 – 在 CenturyLink 云中创建、删除、启动和停止服务器

注意

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

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

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

要在 playbook 中使用它,请指定:community.general.clc_server。

  • 概要

  • 要求

  • 参数

  • 属性

  • 备注

  • 示例

  • 返回值

概要

  • 一个 Ansible 模块,用于在 CenturyLink 云中创建、删除、启动和停止服务器。

要求

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

  • python = 2.7

  • requests >= 2.5.0

  • clc-sdk

参数

参数

注释

add_public_ip

布尔值

是否为服务器添加公网 IP

选项

  • false ← (默认)

  • true

additional_disks

列表 / 元素=字典

服务器的附加磁盘列表

默认值: []

alert_policy_id

字符串

要分配给服务器的告警策略。这与“alert_policy_name”互斥。

alert_policy_name

字符串

要分配给服务器的告警策略。这与“alert_policy_id”互斥。

alias

字符串

用于在其中配置服务器的帐户别名。

anti_affinity_policy_id

字符串

要分配给服务器的反亲和性策略。这与“anti_affinity_policy_name”互斥。

anti_affinity_policy_name

字符串

要分配给服务器的反亲和性策略。这与“anti_affinity_policy_id”互斥。

configuration_id

字符串

仅对于裸机服务器需要。指定要部署的裸机服务器的特定配置类型的标识符。

count

整数

要构建的服务器数量(与 exact_count 互斥)

默认值: 1

count_group

字符串

指定 exact_count 时需要。用于确定要部署多少服务器的服务器组。

cpu

整数

要在服务器上配置的 CPU 数量

默认值: 1

cpu_autoscale_policy_id

字符串

要分配给服务器的自动缩放策略。

custom_fields

列表 / 元素=字典

要在服务器上设置的自定义字段列表。

默认值: []

description

字符串

要为服务器设置的描述。

exact_count

整数

以幂等模式运行。将确保在提供的组中运行此确切数量的服务器,创建和删除它们以达到该数量。需要设置 count_group。

group

字符串

要在其下创建服务器的服务器组。

默认值: "Default Group"

ip_address

字符串

服务器的 IP 地址。如果没有提供,则会分配一个。

location

字符串

要在其中创建服务器的数据中心。

managed_os

布尔值

是否将服务器创建为“托管”服务器。

选项

  • false ← (默认)

  • true

memory

整数

内存(以 GB 为单位)。

默认值: 1

name

字符串

用于服务器的 1 到 6 个字符的标识符。当 state 为“present”时,这是必需的。

network_id

字符串

要在其上创建服务器的网络 UUID。

os_type

字符串

仅对于裸机服务器需要。指定要与裸机服务器一起配置的操作系统。

选项

  • "redHat6_64Bit"

  • "centOS6_64Bit"

  • "windows2012R2Standard_64Bit"

  • "ubuntu14_64Bit"

packages

列表 / 元素=字典

在服务器创建后在其上运行的蓝图包列表。

默认值: []

password

字符串

管理员/root 用户的密码

primary_dns

字符串

服务器使用的主 DNS。

public_ip_ports

列表 / 元素=字典

如果 add_public_ip 设置为 True,则允许通过防火墙访问服务器公网 IP 的端口列表。

默认值: []

public_ip_protocol

字符串

如果 add_public_ip 设置为 True,则用于公网 IP 的协议。

选项

  • "TCP" ← (默认)

  • "UDP"

  • "ICMP"

secondary_dns

字符串

服务器使用的辅助 DNS。

server_ids

列表 / 元素=字符串

对于 started、stopped 和 absent 状态都需要。服务器 ID 列表,确保已启动、已停止或不存在。

默认值: []

source_server_password

字符串

如果指定了克隆,则源服务器的密码。

state

字符串

确保提供的资源处于的状态。

选项

  • "present" ← (默认)

  • "absent"

  • "started"

  • "stopped"

storage_type

字符串

要附加到服务器的存储类型。

选项

  • "standard" ← (默认)

  • "hyperscale"

template

字符串

用于服务器创建的模板。如果提供部分字符串,则将搜索模板。当 state 为 'present' 时,这是必需的。

ttl

字符串

服务器的生存时间(秒)。当此时间到期时,服务器将被删除。

type

字符串

要创建的服务器类型。

选项

  • "standard" ← (默认)

  • "hyperscale"

  • "bareMetal"

wait

布尔值

是否在返回之前等待配置任务完成。

选项

  • false

  • true ← (默认)

属性

属性

支持

描述

check_mode

支持:完全支持

可以在 check_mode 下运行,并在不修改目标的情况下返回更改状态预测。

diff_mode

支持:不支持

在差异模式下,将返回有关已更改内容(或可能需要在 check_mode 中更改的内容)的详细信息。

备注

注意

  • 要使用此模块,需要设置以下环境变量,以启用对 CenturyLink Cloud 的访问 - CLC_V2_API_USERNAME(CenturyLink Cloud 的帐户登录 ID)- CLC_V2_API_PASSWORD(CenturyLink Cloud 的帐户密码)

  • 或者,该模块接受 API 令牌和帐户别名。API 令牌可以使用 CLC 帐户登录名和密码通过 HTTP API 调用生成,网址为 https://api.ctl.io/v2/authentication/login - CLC_V2_API_TOKEN(从 https://api.ctl.io/v2/authentication/login 生成的 API 令牌)- CLC_ACCT_ALIAS(与 CenturyLink Cloud 关联的帐户别名)

  • 用户可以设置 CLC_V2_API_URL 来指定指向不同 CLC 环境的端点。

示例

# Note - You must set the CLC_V2_API_USERNAME And CLC_V2_API_PASSWD Environment variables before running these examples

- name: Provision a single Ubuntu Server
  community.general.clc_server:
    name: test
    template: ubuntu-14-64
    count: 1
    group: Default Group
    state: present

- name: Ensure 'Default Group' has exactly 5 servers
  community.general.clc_server:
    name: test
    template: ubuntu-14-64
    exact_count: 5
    count_group: Default Group
    group: Default Group

- name: Stop a Server
  community.general.clc_server:
    server_ids:
      - UC1ACCT-TEST01
    state: stopped

- name: Start a Server
  community.general.clc_server:
    server_ids:
      - UC1ACCT-TEST01
    state: started

- name: Delete a Server
  community.general.clc_server:
    server_ids:
      - UC1ACCT-TEST01
    state: absent

返回值

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

键

描述

partially_created_server_ids

列表 / 元素=字符串

部分创建的服务器 ID 列表

返回:成功

示例:["UC1TEST-SVR01", "UC1TEST-SVR02"]

server_ids

列表 / 元素=字符串

已创建的服务器 ID 列表

返回:成功

示例:["UC1TEST-SVR01", "UC1TEST-SVR02"]

servers

列表 / 元素=字符串

从 CLC 返回的服务器对象列表

返回:成功

示例:[{"changeInfo": {"createdBy": "service.wfad", "createdDate": 1438196820, "modifiedBy": "service.wfad", "modifiedDate": 1438196820}, "description": "test-server", "details": {"alertPolicies": [], "cpu": 1, "customFields": [], "diskCount": 3, "disks": [{"id": "0:0", "partitionPaths": [], "sizeGB": 1}, {"id": "0:1", "partitionPaths": [], "sizeGB": 2}, {"id": "0:2", "partitionPaths": [], "sizeGB": 14}], "hostName": "", "inMaintenanceMode": false, "ipAddresses": [{"internal": "10.1.1.1"}], "memoryGB": 1, "memoryMB": 1024, "partitions": [], "powerState": "started", "snapshots": [], "storageGB": 17}, "groupId": "086ac1dfe0b6411989e8d1b77c4065f0", "id": "test-server", "ipaddress": "10.120.45.23", "isTemplate": false, "links": [{"href": "/v2/servers/wfad/test-server", "id": "test-server", "rel": "self", "verbs": ["GET", "PATCH", "DELETE"]}, {"href": "/v2/groups/wfad/086ac1dfe0b6411989e8d1b77c4065f0", "id": "086ac1dfe0b6411989e8d1b77c4065f0", "rel": "group"}, {"href": "/v2/accounts/wfad", "id": "wfad", "rel": "account"}, {"href": "/v2/billing/wfad/serverPricing/test-server", "rel": "billing"}, {"href": "/v2/servers/wfad/test-server/publicIPAddresses", "rel": "publicIPAddresses", "verbs": ["POST"]}, {"href": "/v2/servers/wfad/test-server/credentials", "rel": "credentials"}, {"href": "/v2/servers/wfad/test-server/statistics", "rel": "statistics"}, {"href": "/v2/servers/wfad/510ec21ae82d4dc89d28479753bf736a/upcomingScheduledActivities", "rel": "upcomingScheduledActivities"}, {"href": "/v2/servers/wfad/510ec21ae82d4dc89d28479753bf736a/scheduledActivities", "rel": "scheduledActivities", "verbs": ["GET", "POST"]}, {"href": "/v2/servers/wfad/test-server/capabilities", "rel": "capabilities"}, {"href": "/v2/servers/wfad/test-server/alertPolicies", "rel": "alertPolicyMappings", "verbs": ["POST"]}, {"href": "/v2/servers/wfad/test-server/antiAffinityPolicy", "rel": "antiAffinityPolicyMapping", "verbs": ["PUT", "DELETE"]}, {"href": "/v2/servers/wfad/test-server/cpuAutoscalePolicy", "rel": "cpuAutoscalePolicyMapping", "verbs": ["PUT", "DELETE"]}], "locationId": "UC1", "name": "test-server", "os": "ubuntu14_64Bit", "osType": "Ubuntu 14 64-bit", "status": "active", "storageType": "standard", "type": "standard"}]

作者

  • CLC Runner (@clc-runner)

收藏链接

  • 问题跟踪器
  • 代码库(源码)
  • 寻求帮助
  • 提交错误报告
  • 请求功能
  • 沟通
上一页 下一页

© 版权所有 Ansible 项目贡献者。 上次更新于 2024 年 12 月 19 日。