Read the README.adoc and README-cloud.adoc documents.
Although there are several playbooks available, for creating and deleting hetzner VMs 2 of them should be used. Other playbooks are used as dependencies for these main playbooks
The playbook for creating a passwordstore based VM is hetzner_vm_create_passwordstore.yml
which is located at ansible/playbook/hetzner/
.
To create a new VM execute the following command
ansible-playbook ansible/playbook/hetzner/hetzner_vm_create_passwordstore.yml -e vm_name=snowdrop-vm -e k8s_type=masters -e k8s_version=123 -e salt_text=$(gpg --gen-random --armor 1 20) -e vm_image=fedora-37 -e server_type=cx21
The parameters are the following.
Parameter | Description | ||
---|---|---|---|
string |
Type of k8s node Choices:
|
||
string |
Kubernetes version Choices:
|
||
string required |
Salt to be used on the generation of the host user password. Usually the following script is used: |
||
string |
The flavor of the servier in terms of CPU and RAM. More information at: https://docs.hetzner.com/cloud/servers/overview/#shared-vcpu |
||
string |
The base image to generate the VM from (OS). More information at: |
||
string required |
Name to be given to the VM. |
Note
|
More information on the Click to see the sample
|
Note
|
More information on the Click to see the sample
|
The playbook for deleting a passwordstore based VM is hetzner_vm_delete_passwordstore.yml
which is located at ansible/playbook/hetzner/
.
To delete a new VM execute the following command.
ansible-playbook ansible/playbook/hetzner/hetzner_vm_delete_passwordstore.yml -e vm_name=snowdrop-vm
Initializes the Hetzner context.
$ ansible-playbook hetzner/ansible/hetzner-init-context.yml
This playbook has the following variables.
Variable | Required | Prompt | Meaning |
---|---|---|---|
|
x |
x |
context name |
|
x |
x |
The token to register with Hetzner. |
Each of the Ansible prompts can be replaced by defining it’s value as an extra variable of the playbook.
$ ansible-playbook hetzner/ansible/hetzner-init-context.yml -e hetzner_context_name=mycontext -e hetzner_token=mytoken
Several playbooks have been created to interact with Hetzner which are described in this section.
The playbooks with _passwordstore
suffix have been developed with storing information on a pass database.
Prior to creating a new VM, the SSH key generated by the Ansible Inventory must be added to the Hetzner SSH Key repository. This SSH will then be used in the server creation.
This is accomplished using the [hetzner-create-ssh-key](ansible/hetzner-create-ssh-key.yml) playbook which will create an SSH Key with the name of the
hetzner_ssh_key_create
playbook options
string required |
Name of the VM to be created at hetzner. |
hetzner_ssh_key_create
playbook sample$ ansible-playbook hetzner/ansible/hetzner-create-ssh-key.yml -e vm_name=${VM_NAME}