Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spin provision can't work with existing ssh keys in hetzner cloud (and maybe others) #154

Open
anhofmann opened this issue Jan 17, 2025 · 1 comment

Comments

@anhofmann
Copy link

Current Behavior

I'm using hetzner cloud. I have my SSH Keys stored there.

I'm running spin provision and spin crashed with this:

TASK [serversideup.spin.create_server : Create SSH keys for sudo users if they don't exist in Hetzner Cloud] *************************************************************************************************************************
changed: [localhost] => (item=[{'username': 'myuser', 'name': 'My Name', 'state': 'present', 'groups': ['sudo'], 'shell': '/bin/bash', 'authorized_keys': [{'public_key': '<my public key>'}]}, {'public_key': '<my public key again>'}])
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible_collections.hetzner.hcloud.plugins.module_utils.vendor.hcloud._exceptions.APIException: SSH key with the same fingerprint already exists (uniqueness_error, c7494d6b58fdf8c7)

When I delete my existing keys, spin creates them with its own naming scheme.

Expected Behavior

It would be great if spin would recognize existing keys and doesn't insist on its own naming scheme.

Steps To Reproduce

  1. use hetzner cloud
  2. add your own ssh keys
  3. setup spin so that it uses those keys
  4. spin provision

Environment

Spin Version: 
v3.0.2 [stable] (User Installed)

Operating System Version: 
NAME="Manjaro Linux"
PRETTY_NAME="Manjaro Linux"
ID=manjaro
ID_LIKE=arch
BUILD_ID=rolling
ANSI_COLOR="32;1;24;144;200"
HOME_URL="https://manjaro.org/"
DOCUMENTATION_URL="https://wiki.manjaro.org/"
SUPPORT_URL="https://forum.manjaro.org/"
BUG_REPORT_URL="https://docs.manjaro.org/reporting-bugs/"
PRIVACY_POLICY_URL="https://manjaro.org/privacy-policy/"
LOGO=manjarolinux

Docker Info: 
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
Client:
 Version:    27.3.1
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  0.19.2
    Path:     /usr/lib/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  2.31.0
    Path:     /usr/lib/docker/cli-plugins/docker-compose
  scan: Docker Scan (Docker Inc.)
    Version:  v0.1.0-280-gc7fa31d4c4
    Path:     /usr/lib/docker/cli-plugins/docker-scan

Server:
 Containers: 5
  Running: 1
  Paused: 0
  Stopped: 4
 Images: 28
 Server Version: 27.3.1
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: true
  Native Overlay Diff: false
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 207ad711eabd375a01713109a8a197d197ff6542.m
 runc version: 
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.6.65-1-MANJARO
 Operating System: Manjaro Linux
 OSType: linux
 Architecture: x86_64
 CPUs: 20
 Total Memory: 31.09GiB
 Name: manjaro-infinity
 ID: 3266:OYZK:QQBW:KU3B:QZXA:KIXN:NATT:YCPE:KWBR:25TY:I5M6:S2S4
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Anything else?

No response

@jaydrogers
Copy link
Member

Sorry for the troubles! I've seen this come up once or twice. The issue resides in this file:

https://github.com/serversideup/ansible-collection-spin/blob/main/roles/create_server/tasks/providers/hetzner.yml

Workaround

  1. Go into Hetzner
  2. Delete the SSH key
  3. Re-run spin provision (it will upload it for you)

Next Steps

I will swing back to this and try to figure out why this is happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants