Repository navigation
Incorrect YAML format when provisioning server #168
Copy link
Copy link
Open
Labels
🐛 Bug: ConfirmedBugs that are able to be replicated.Bugs that are able to be replicated.
Description
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
- Create a new project using
spin new laravel my-billion-dollar-idea - Set DigitalOcean credentials in spin.yml
- 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: falseAnything else?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
🐛 Bug: ConfirmedBugs that are able to be replicated.Bugs that are able to be replicated.
Activity
jaydrogers commentedon Sep 2, 2025
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:

Can you try running a
spin pruneto 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? 🤔
glennjacobs commentedon Sep 2, 2025
Yep will do.
LambdaDigamma commentedon Sep 4, 2025
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.
glennjacobs commentedon Sep 4, 2025
Yep, that's exactly what happened for me.
jaydrogers commentedon Sep 5, 2025
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?
moldygit commentedon Sep 5, 2025
I'm using Hetzner too, and got that 'address' issue where it misses a space. Same logs.
DanjBethel commentedon Sep 8, 2025
Any update on this? Having the same issue I think. This is happening when I use the command "spin configure gha production". Screenshot below:
jaydrogers commentedon Sep 8, 2025
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 💯
DanjBethel commentedon Sep 11, 2025
@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 commentedon Sep 11, 2025
@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.ymlis valid and try runningspin provisionagain. 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
.spin.ymlfollowing 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
Delete Spin
To be safe, I even deleted Spin:
rm -rf ~/.spinRe-install Spin
Create a new project
I just use basic settings (doesn't matter).
Configure
.spin.ymlThings I made sure to check:
Provision server
👉 Actual Results
🌎 Environments I tested in
3.0.4Just to reiterate, I have tested this on my macOS and Windows machine and I am not able to replicate it.
🤔 Possible further investigations
.spin.ymlcould have improper spacing and/or a syntax error beforespin provisionis runCRLFissue?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
LambdaDigamma commentedon Sep 11, 2025
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.xxxattribute. 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:
After hitting
CMD + Shift + 7, it becomes: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!
DanjBethel commentedon Sep 11, 2025
@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!
jaydrogers commentedon Sep 12, 2025
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 🙃):
Let me see if I can play around with solutions. I think @LambdaDigamma had some great proposals.
I'll keep you guys posted 👍
jaydrogers commentedon Sep 12, 2025
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:
yeditto directly modify the data structure instead of a fileyamllintthat will validate the syntax of a .spin.yml file before Ansible even runs (this will executeyamllintfrom within the container, so nobody will even need to install anything)Next steps (for people on this thread)
jaydrogers commentedon Sep 19, 2025
Just nudging this thread to see if my fix worked for everyone 😅
jaydrogers commentedon Sep 23, 2025
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.ymlfile, our "lineinfile" just adds it to the bottom without actually decrypting it and inserting italbertricart commentedon Sep 24, 2025
Came across this issue yesterday and what finally worked for me was clearing the docker cache and reinstalling spin like suggested.🎉
jaydrogers commentedon Jan 28, 2026
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
yqfrom 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!