snowdrop/k8s-infra

hcloud: SSH key name is already used (uniqueness_error)

Closed this issue · 0 comments

Issue

The following error occurs

TASK [hetzner/create_server : Create cloud server key] *****************************************************************************************************************************************************************
Thursday 09 September 2021  17:50:20 +0200 (0:00:00.027)       0:00:04.601 **** 
fatal: [localhost]: FAILED! => {"changed": false, "cmd": "hcloud ssh-key create --name snowdrop 
--public-key \"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC1kBAJB/S9j18OqOFpsu7Qgoe/xLa+n3+mHK9MYZKdtDHWtfZYPA6ESlnelBfASnUHg3Pvmtk5wdqG3dKf0yg+rQnvWCOk5We2J5MYLifCHpVeH4q7uORQw2NH4P41zZw7dMfGuEd0SUnx7sKC7K3uOK3+aPzspJsedNAtobM3yPt7M61csR16KU4c77viKtX52IIU/HPTof2EBeg2MG2OE1/+lQAVd6YPvoWBfyJIDuK7lbRa0jUmX0+LX4RIJb2pHsUEjQKf+FvyQhFdkc4roRQZWB8ljtUtpPHxE1vdH2JSNxH7sf/kxkVyUqcjHB6GSMC2Bbw45gyw9Gn8cXPT\"", 
"delta": "0:00:00.292425", "end": "2021-09-09 17:50:21.087361", 
"failed_when_result": true, "msg": "non-zero return code", 
"rc": 1, "start": "2021-09-09 17:50:20.794936", 
"stderr": "hcloud: SSH key name is already used (uniqueness_error)", 
"stderr_lines": ["hcloud: SSH key name is already used (uniqueness_error)"], 
"stdout": "", "stdout_lines": []}

using the current playbook and the following commands

VM_NAME=h01-121
ansible-playbook ansible/playbook/passstore_controller_inventory_remove.yml -e vm_name=${VM_NAME} -e pass_provider=hetzner
ansible-playbook ansible/playbook/passstore_controller_inventory.yml -e vm_name=${VM_NAME} -e pass_provider=hetzner -e k8s_type=masters -e k8s_version=121 --tags create
ansible-playbook hetzner/ansible/hetzner-create-server.yml \
  -e vm_name=${VM_NAME} \
  -e salt_text=$(head -c 500 /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 20 | head -n 1) \
  -e hetzner_context_name=snowdrop \
  -e server_type=cx41

Temporary workaround

Disable the command creating the SSH key which already exists since 6months on hetzner (snowdrop)

#- name: "Create cloud server key"
#  shell: "hcloud ssh-key create --name {{ context_name }} --public-key \"{{ hetzner_public_key }}\""
#  register: hcloud_ssh_key_res
#  changed_when: "hcloud_ssh_key_res.rc == 0"
#  failed_when: "hcloud_ssh_key_res.rc != 0 and ('SSH key with the same fingerprint already exists' not in hcloud_ssh_key_res.stderr)"