siw36.ansible_hcloud_vm
ansible-hcloud-vm
此角色在赫兹纳云中部署一个或多个虚拟机,并附加额外的磁盘。
发生的事情:
- 系统将在您的账户中创建指定的SSH公钥
- 将创建服务器列表,并为指定的SSH密钥设置root访问权限(只要您使用赫兹纳镜像)
- 将为每台服务器创建卷列表,并将卷附加到对应的服务器
__当前模块/API问题__:
当您删除一台服务器后,立即删除附加的卷时,API会报告这些卷仍附加在服务器上,无法删除。
当您运行此角色并将服务器状态设为absent
的同时,也将附加到该服务器的卷状态设为absent
时,就会发生这种情况。
获取此角色
ansible-galaxy install --roles-path ./roles/ siw36.ansible_hcloud_vm
要求
- Python模块:
hcloud
(此角色将自动安装到用户的Python模块目录中)
角色变量
名称 | 描述 | 默认值 |
---|---|---|
getInfoOnly | 获取服务器类型、镜像和位置的可能值。当此变量设为true时,仅打印信息。 | false |
hcloudBearer | 您的赫兹纳云API密钥。可以在项目的SSH密钥标签中找到。 | <none - __必须设置__> |
sshKey | 包含root SSH密钥信息的字典 | <none - __必须设置__> |
deployments | 部署及其磁盘的列表 | <none - __必须设置__> |
请参见以下示例以获取如何指定变量的详细信息
示例剧本
playbook.yml:
- hosts: localhost
become: false
gather_facts: false
roles:
- siw36.ansible_hcloud_vm
roles/siw36.ansible_hcloud_vm/vars/main.yml
#getInfoOnly: false
hcloudBearer: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
sshKey:
name: root
value: ssh-rsa xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx root
state: present
deployments:
- name: test0.nodes.replicas.io
state: absent # (present|started|stopped|restarted|absent|rebuild)
size: cx11
location: hel1
image: centos-7
backup: false
sshKeys:
- siw
labels:
project: replicas.io
stage: prod
location: helsinki
volumes:
- name: test0.nodes.replicas.io-data0
state: absent # (present|absent)
size: 10
automount: true
format: xfs # (xfs|ext4)
许可证
GNU通用公共许可证v3.0
作者信息
创建者:Robin 'siw36' Klussmann(07/2019)
安装
ansible-galaxy install siw36.ansible_hcloud_vm
许可证
gpl-3.0
下载
166
拥有者
Platform & DevOps Engineer