Skip to content

Incorrect YAML format when provisioning server #168

Open

Description

@glennjacobs

Current Behavior

I provision a server (using DigitalOcean). When the server is created the spin.yml file is updated with the IP address, but it breaks the YAML format, making it invalid and preventing the rest of the script to run.

Expected Behavior

I expect the YAML file format to be correct when the IP address is added.

Steps To Reproduce

  1. Create a new project using spin new laravel my-billion-dollar-idea
  2. Set DigitalOcean credentials in spin.yml
  3. Run spin provision

Environment

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

Operating System Version: 
ProductName:            macOS
ProductVersion:         15.6
BuildVersion:           24G84

Docker Info: 
WARNING: daemon is not using the default seccomp profile
Client:
 Version:    24.0.6
 Context:    desktop-linux
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.11.2-desktop.4
    Path:     /Users/glenn/.docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.21.0-desktop.1
    Path:     /Users/glenn/.docker/cli-plugins/docker-compose
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.0
    Path:     /Users/glenn/.docker/cli-plugins/docker-dev
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.20
    Path:     /Users/glenn/.docker/cli-plugins/docker-extension
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v0.1.0-beta.7
    Path:     /Users/glenn/.docker/cli-plugins/docker-init
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     /Users/glenn/.docker/cli-plugins/docker-sbom
  scan: Docker Scan (Docker Inc.)
    Version:  v0.26.0
    Path:     /Users/glenn/.docker/cli-plugins/docker-scan
  scout: Command line tool for Docker Scout (Docker Inc.)
    Version:  0.24.1
    Path:     /Users/glenn/.docker/cli-plugins/docker-scout

Server:
 Containers: 25
  Running: 0
  Paused: 0
  Stopped: 25
 Images: 111
 Server Version: 24.0.6
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 8165feabfdfe38c65b599c4993d227328c231fca
 runc version: v1.1.8-0-g82f18fe
 init version: de40ad0
 Security Options:
  seccomp
   Profile: unconfined
  cgroupns
 Kernel Version: 6.3.13-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: aarch64
 CPUs: 5
 Total Memory: 4.08GiB
 Name: docker-desktop
 ID: 57be98c4-b5f3-4e43-a318-9a0d81a48334
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  127.0.0.0/8
 Live Restore Enabled: false

Anything else?

No response

Activity

  1. jaydrogers commented on Sep 2, 2025

    @jaydrogers
    Member

    Thanks so much for posting a detailed bug report!

    I almost have the same exact environment as you. I provisioned about 3 Digital Ocean servers last week and did another one for this issue. Unfortunately I was not able to replicate.

    The IP came back exactly how it was supposed to be:
    Image

    Can you try running a spin prune to clear any Spin cache and Docker cache and try running again?

    Maybe try the whole process over to see if it was a one-time fluke or something? 🤔

  2. glennjacobs commented on Sep 2, 2025

    @glennjacobs
    Author

    Thanks so much for posting a detailed bug report!

    I almost have the same exact environment as you. I provisioned about 3 Digital Ocean servers last week and did another one for this issue. Unfortunately I was not able to replicate.

    The IP came back exactly how it was supposed to be: Image

    Can you try running a spin prune to clear any Spin cache and Docker cache and try running again?

    Maybe try the whole process over to see if it was a one-time fluke or something? 🤔

    Yep will do.

  3. LambdaDigamma commented on Sep 4, 2025

    @LambdaDigamma

    The same happens for me, I don't really know why its happening...
    But the screenshot shows how the spin.yml is formatted after the IP address is added.

    Image
    TASK [serversideup.spin.create_server : Store newly created servers in fact] *******************************************************************************
    ok: [localhost]
    
    TASK [serversideup.spin.create_server : Refresh inventory] *************************************************************************************************
    [WARNING]:  * Failed to parse /etc/ansible/collections/ansible_collections/serversideup/spin/plugins/inventory/spin-dynamic-inventory.sh with script
    plugin: failed to parse executable inventory script results from /etc/ansible/collections/ansible_collections/serversideup/spin/plugins/inventory/spin-
    dynamic-inventory.sh: Expecting value: line 1 column 1 (char 0). Expecting value: line 1 column 1 (char 0) Error: bad file '/ansible/.spin.yml': yaml: line
    38: did not find expected '-' indicator Error: bad file '/ansible/.spin.yml': yaml: line 38: did not find expected '-' indicator Error: bad file
    '/ansible/.spin.yml': yaml: line 38: did not find expected '-' indicator Error: bad file '/ansible/.spin.yml': yaml: line 38: did not find expected '-'
    indicator Error: bad file '/ansible/.spin.yml': yaml: line 38: did not find expected '-' indicator Error: bad file '/ansible/.spin.yml': yaml: line 38: did
    not find expected '-' indicator Error: bad file '/ansible/.spin.yml': yaml: line 38: did not find expected '-' indicator Error: bad file
    '/ansible/.spin.yml': yaml: line 38: did not find expected '-' indicator Error: bad file '/ansible/.spin.yml': yaml: line 38: did not find expected '-'
    indicator Error: bad file '/ansible/.spin.yml': yaml: line 38: did not find expected '-' indicator
    [WARNING]:  * Failed to parse /etc/ansible/collections/ansible_collections/serversideup/spin/plugins/inventory/spin-dynamic-inventory.sh with ini plugin:
    /etc/ansible/collections/ansible_collections/serversideup/spin/plugins/inventory/spin-dynamic-inventory.sh:11: Expected key=value host variable assignment,
    got: {
    
  4. glennjacobs commented on Sep 4, 2025

    @glennjacobs
    Author

    Yep, that's exactly what happened for me.

  5. jaydrogers commented on Sep 5, 2025

    @jaydrogers
    Member

    Weird! I will definitely take a look into this since there are multiple reports. For some reason I cannot replicate it on my machine, so I will try it on another Mac and see if I can replicate it there.

    @LambdaDigamma it looks like you're using Hetzner, so it's not just limited to Digital Ocean?

  6. moldygit commented on Sep 5, 2025

    @moldygit

    I'm using Hetzner too, and got that 'address' issue where it misses a space. Same logs.

  7. DanjBethel commented on Sep 8, 2025

    @DanjBethel

    Any update on this? Having the same issue I think. This is happening when I use the command "spin configure gha production". Screenshot below:

    Image
  8. added
    🧐 Bug: Needs ConfirmationSomething isn't working, but needs to be confirmed by a team member.
    and removed on Sep 8, 2025
  9. jaydrogers commented on Sep 8, 2025

    @jaydrogers
    Member

    I think the reason why I couldn't replicate this is because I had containers cached on my machine 🙃

    This is a very important issue for me to resolve. I'll get a fix deployed this week for sure 💯

  10. DanjBethel commented on Sep 11, 2025

    @DanjBethel

    @jaydrogers hey don't mean to rush you but any news on this? i'm a new buyer of spinpro and haven't been able to get a deployment up because of this issue.

    cheers and thanks for all the hard work.

  11. jaydrogers commented on Sep 11, 2025

    @jaydrogers
    Member

    @DanjBethel: I believe it's possible you might be running into a separate issue. It very well could be a syntax issue on your end. Verify your .spin.yml is valid and try running spin provision again. If you still have issues, I would advise opening a new issue and posting more about your set up.

    👉 Workaround if time is of the essence

    1. Deploy a server manually through the UI
    2. Ensure you can connect via SSH
    3. Configure your .spin.yml following the Use Any Host method

    🐛 Replicating the original bug (where refreshing the inventory fails because of an automated syntax error)

    I am baffled on why I cannot replicate this. Here are my steps and environment that I attempted to reproduce:

    Clear local docker cache and spin cache

    spin prune

    Delete Spin

    To be safe, I even deleted Spin:

    rm -rf ~/.spin

    Re-install Spin

    bash -c "$(curl -fsSL https://raw.githubusercontent.com/serversideup/spin/main/tools/install.sh)"
    

    Create a new project

    spin new laravel my-billion-dollar-idea
    

    I just use basic settings (doesn't matter).

    Configure .spin.yml

    Things I made sure to check:

    • Ensure users is set (with my username and SSH key)
    • Ensure providers is set (with my Hetzner API key
    • Ensure servers is set (with my server pointing to a hardware profile)
    • Ensure hardware_profile exists
    • Verify YML spacing is correct and valid
    Image

    Provision server

    spin provision

    👉 Actual Results

    • Everything worked as expected 🙃
    Image

    🌎 Environments I tested in

    • Spin Version: 3.0.4
    • macOS: 15.6.1
    • Windows 11 + WSL2

    Just to reiterate, I have tested this on my macOS and Windows machine and I am not able to replicate it.

    🤔 Possible further investigations

    1. The .spin.yml could have improper spacing and/or a syntax error before spin provision is run
    2. Could it be a CRLF issue?

    The code where it writes the IP address to the file is here:

    https://github.com/serversideup/ansible-collection-spin/blob/806d78782ecdec918006d7a4de5ed2402d444c42/roles/create_server/tasks/create-servers.yml#L28-L33

    👇 Next steps

    • Can someone follow my steps above and confirm that you're still having the issue?
  12. LambdaDigamma commented on Sep 11, 2025

    @LambdaDigamma

    I think I’ve identified the issue.

    When uncommenting any of the blocks in the initial .spin.yml (e.g., in PHPStorm), the editor inserts three leading spaces before the - due to the previous formatting of the comments (two spaces in front and one between the # and -). This is still valid YAML, so there’s no syntax error or warning when parsing the file with a YAML deserializer.

    However, your script assumes four leading spaces before the address: xxx.xxx.xxx.xxx attribute. That mismatch leads to the error.

    Since the difference between two, three, or four spaces is subtle (especially without “Visible Whitespace” enabled – and with three spaces still being valid YAML), it’s very easy to miss.

    For example:

    servers:
      # - server_name: ubuntu-2gb-ash-1
      #   environment: production
      #   hardware_profile: hetzner_2c_2gb_ubuntu2404
    
      # - server_name: ubuntu-1gb-ord-2
      #   environment: staging
      #   hardware_profile: vultr_1c_1gb_ubuntu2404

    After hitting CMD + Shift + 7, it becomes:

    servers:
       - server_name: ubuntu-2gb-ash-1
         environment: production
         hardware_profile: hetzner_2c_2gb_ubuntu2404
    
      # - server_name: ubuntu-1gb-ord-2
      #   environment: staging
      #   hardware_profile: vultr_1c_1gb_ubuntu2404

    One possible fix would be to adjust the formatting before uncommenting so it doesn’t introduce three spaces in front of every line. Another would be to handle the address attribute with a proper YAML formatter instead of hardcoding the indentation.

    Hope that clarifies things and helps in finding a good solution!

  13. DanjBethel commented on Sep 11, 2025

    @DanjBethel

    @jaydrogers hey don't mean to rush you but any news on this? i'm a new buyer of spinpro and haven't been able to get a deployment up because of this issue.

    cheers and thanks for all the hard work.

    @jaydrogers yikes completely my fault with this one. didn't realize that i needed to run spin provision before the gh configure command. sorry about that!

  14. jaydrogers commented on Sep 12, 2025

    @jaydrogers
    Member

    You rock @LambdaDigamma!!

    Just wanted to put I note that I was able to replicate this if I use PHPStorm (wow, first time for that 🙃):

    Image

    Let me see if I can play around with solutions. I think @LambdaDigamma had some great proposals.

    I'll keep you guys posted 👍

  15. added and removed
    🧐 Bug: Needs ConfirmationSomething isn't working, but needs to be confirmed by a team member.
    on Sep 12, 2025
  16. jaydrogers commented on Sep 12, 2025

    @jaydrogers
    Member

    Update

    I pushed up this commit, which should fix this -- but it's not a 100% solution serversideup/ansible-collection-spin@34b3e5c

    The "True solution"

    The above fix only fixes the specific issue for un-commenting in PHPStorm. It does not solve that if someone uses different delimiters or number of spaces in their file.

    Solving different delimiters

    I've been working on this all day, but ran into a "ready for the weekend brain rot" scenario. Here's where I left off:

    • Look into using something like yedit to directly modify the data structure instead of a file
    • If I get that to work, I should include a section for yamllint that will validate the syntax of a .spin.yml file before Ansible even runs (this will execute yamllint from within the container, so nobody will even need to install anything)

    Next steps (for people on this thread)

    • Test it out and let me know if this works on new projects. At least what I committed so far should fix your issue for now
    • I will keep you posted once I think on this a bit more 👍
  17. jaydrogers commented on Sep 19, 2025

    @jaydrogers
    Member

    Just nudging this thread to see if my fix worked for everyone 😅

  18. jaydrogers commented on Sep 23, 2025

    @jaydrogers
    Member

    Just adding a note that the current implementation needs to be reworked regardless.

    🐛 Additional bug

    If someone attempts to provision a server with an encrypted .spin.yml file, our "lineinfile" just adds it to the bottom without actually decrypting it and inserting it

    Image
  19. albertricart commented on Sep 24, 2025

    @albertricart

    Just nudging this thread to see if my fix worked for everyone 😅

    Came across this issue yesterday and what finally worked for me was clearing the docker cache and reinstalling spin like suggested.🎉

    Clear local docker cache and spin cache

    spin prune

    Delete Spin

    To be safe, I even deleted Spin:

    rm -rf ~/.spin

    Re-install Spin

    bash -c "$(curl -fsSL https://raw.githubusercontent.com/serversideup/spin/main/tools/install.sh)"
    
  20. self-assigned this
    on Jan 28, 2026
  21. jaydrogers commented on Jan 28, 2026

    @jaydrogers
    Member

    I finally had more time to dive deeper into this. I believe my "band-aid fix" fixed most user's issue, but I worked on a more permanent solution here:

    What I changed (if you want to review)

    Instead of statically writing back to the file, I am using yq from within the container to write back to the file. This seems to standardize all the whitespace and make sure the data is structured right.

    You can see my change here: serversideup/ansible-collection-spin@4096bca

    I just tested it with 6 servers on Hetzner and it all worked great.

    Let me know your thoughts or if anyone is still having any issues!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions