community.general.linode 模块 – 管理 Linode 公有云上的实例
注意
此模块是 community.general 集合 (版本 10.1.0) 的一部分。
如果您正在使用 ansible
包,则可能已安装此集合。它不包含在 ansible-core
中。要检查它是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.general
。您需要其他要求才能使用此模块,有关详细信息,请参见 要求。
要在剧本中使用它,请指定:community.general.linode
。
概要
管理 Linode 公有云实例,并可选择等待其状态变为“运行”。
要求
以下要求是在执行此模块的主机上所需的。
linode-python
参数
参数 |
注释 |
---|---|
用于创建添加到 Linode 配置设置的附加磁盘的字典列表。 字典包含大小、标签、类型。大小以 MB 为单位。 |
|
设置带宽警报的状态。 选项
|
|
设置带宽警报的阈值(以 MB 为单位)。 |
|
设置带宽输出警报的状态。 选项
|
|
设置带宽输出警报的阈值(以 MB 为单位)。 |
|
设置带宽配额警报的状态,以网络传输配额的百分比表示。 选项
|
|
设置带宽配额警报的阈值(以 MB 为单位)。 |
|
设置接收 CPU 使用率警报的状态。 选项
|
|
设置接收 CPU 使用率警报的百分比阈值。每个 CPU 内核都会将总计增加 100%。 |
|
设置接收磁盘 IO 警报的状态。 选项
|
|
设置 2 小时内平均 IO ops/sec 的阈值。 |
|
Linode API 密钥。
|
|
进行备份的星期几。 |
|
进行备份的时间窗口。 |
|
创建实例的数据中心(Linode 数据中心) |
|
将实例添加到 Linode Manager 中的显示组。 默认值: |
|
要用于实例的发行版(Linode 发行版) |
|
要用于实例的内核(Linode 内核) |
|
Linode 服务器的唯一 ID。此值在创建 Linode 时是只读的,因为它不会被使用。Linode API 生成这些 ID,我们可以在这里使用生成的这些值来更具体地引用 Linode。这对于幂等性非常有用。 |
|
要赋予实例的名称(字母数字、短划线、下划线)。 为了保持 Linode Web 控制台的一致性,名称前缀为 |
|
要应用于新服务器的 root 密码(如果缺少则自动生成) |
|
要用于实例的付款期限(以月为单位) 选项
|
|
要用于实例的计划(Linode 计划) |
|
创建 Linode 时添加私有 IPv4 地址。 默认为 选项
|
|
应用于 root 用户的 SSH 公钥 |
|
指示所需资源状态 选项
|
|
交换空间大小(以 MB 为单位) 默认值: |
|
等待实例处于 选项
|
|
等待超时时间(秒) 默认值: |
|
设置 Lassie 看门狗的状态。 选项
|
属性
属性 |
支持 |
描述 |
---|---|---|
支持:无 |
可在 |
|
支持:无 |
在diff模式下,将返回有关已更改内容(或在 |
备注
注意
请注意,linode-python 不支持 Python 3。
此模块使用现已弃用的 Linode API v3。
请查看https://www.linode.com/api/linode 以确定所需的参数。
示例
- name: Create a new Linode
community.general.linode:
name: linode-test1
plan: 1
datacenter: 7
distribution: 129
state: present
register: linode_creation
- name: Create a server with a private IP Address
community.general.linode:
module: linode
api_key: 'longStringFromLinodeApi'
name: linode-test1
plan: 1
datacenter: 2
distribution: 99
password: 'superSecureRootPassword'
private_ip: true
ssh_pub_key: 'ssh-rsa qwerty'
swap: 768
wait: true
wait_timeout: 600
state: present
delegate_to: localhost
register: linode_creation
- name: Fully configure new server
community.general.linode:
api_key: 'longStringFromLinodeApi'
name: linode-test1
plan: 4
datacenter: 2
distribution: 99
kernel_id: 138
password: 'superSecureRootPassword'
private_ip: true
ssh_pub_key: 'ssh-rsa qwerty'
swap: 768
wait: true
wait_timeout: 600
state: present
alert_bwquota_enabled: true
alert_bwquota_threshold: 80
alert_bwin_enabled: true
alert_bwin_threshold: 10
alert_cpu_enabled: true
alert_cpu_threshold: 210
alert_bwout_enabled: true
alert_bwout_threshold: 10
alert_diskio_enabled: true
alert_diskio_threshold: 10000
backupweeklyday: 1
backupwindow: 2
displaygroup: 'test'
additional_disks:
- {Label: 'disk1', Size: 2500, Type: 'raw'}
- {Label: 'newdisk', Size: 2000}
watchdog: true
delegate_to: localhost
register: linode_creation
- name: Ensure a running server (create if missing)
community.general.linode:
api_key: 'longStringFromLinodeApi'
name: linode-test1
plan: 1
datacenter: 2
distribution: 99
password: 'superSecureRootPassword'
ssh_pub_key: 'ssh-rsa qwerty'
swap: 768
wait: true
wait_timeout: 600
state: present
delegate_to: localhost
register: linode_creation
- name: Delete a server
community.general.linode:
api_key: 'longStringFromLinodeApi'
name: linode-test1
linode_id: "{{ linode_creation.instance.id }}"
state: absent
delegate_to: localhost
- name: Stop a server
community.general.linode:
api_key: 'longStringFromLinodeApi'
name: linode-test1
linode_id: "{{ linode_creation.instance.id }}"
state: stopped
delegate_to: localhost
- name: Reboot a server
community.general.linode:
api_key: 'longStringFromLinodeApi'
name: linode-test1
linode_id: "{{ linode_creation.instance.id }}"
state: restarted
delegate_to: localhost