Chef-solo state of the art

I'm trying to use chef to just preserve the infrastructure of my single server as code so I can recreate and modify it later.

Seems like chef-solo is the product for this. Unfortunately, if I search for chef-solo tutorials, they are all 8-9 years old. Several of them have notes on them pointing out they are very old and suggesting to use tools like knife-solo and librarian. But then, knife-solo itself is also deprecated!

What is the up-to-date method of using chef-solo and what tools can be used to set up a basic scaffold for creating and running recipes on a remote machine?

If you have an O’Reilly Safari subscription, I did a whole series on how to do Chef without a server using what became the replacement for chef-solo - it’s called “chef local mode":
“Learning Chef for Linux and macOS”:
https://learning.oreilly.com/videos/learning-chef-for/9781491959442

The crux of it is that you can run an in-memory chef server by running chef-client —local-mode. Then it works as if you had a real chef-server to run your cookbooks, with no drawbacks or functionality limitations. It even works with databags and other chef server features. It’s a little clunky to setup and use because it’s fitted into chef-client, but it works and you only have to install chef client to use it, even to run this in-memory server. (Behind the scenes it actually runs the real Chef Erlang server - it’s bundled in chef-client).

You can also take a look at the example source here: https://github.com/learningchef/learningchef-code

And here’s a script that a client of mine still actively uses to run chef-client —local-mode which also does berkshelf to download full cookbook dependencies:
Linux and macOS: https://github.com/TetrationAnalytics/polymath/blob/master/polly
Windows: https://github.com/TetrationAnalytics/polymath/blob/master/polly.ps1

There’s also chef-apply which can run a single recipe, but I don’t find that really useful for real automation code. What you’re looking for is “local mode”. That ended up replacing chef-solo.

Also, there’s also this new thing in Chef 15 called “Target Mode”, where you can use chef-client -t.

Unfortunately the drawback to it the last time I used it is that most resources don’t have target mode implemented, nor did ohai work properly - it just used the train library to detect state, which isn’t enough for complex cookbooks. So I still use local mode, personally, as it does the job. The next future of chef-solo will likely be target mode as it evolves.

Here’s a video on that: https://www.youtube.com/watch?v=Rp5YXenHRmg

Thanks so much for the help. In my own investigation, I also found chef-run. Is it correct that the difference between chef-run and chef-apply is that chef-apply is run on the target node itself, whereas chef-run is run on another machine against the target node?

And the disadvantage of using chef-run vs. local mode is that chef-run will not be as feature rich as having an actual chef server running? Any good examples of why this would be a drawback?

There's also this old thing called "chef-zero", which basically replaced chef-solo.Though I don't support chef professionally anymore, I had good success with infrastructure as code using chef-zero. Changes recorded in the local chef setup were published back to the primary git repo, with branches used as needed. In some ways it, worked better than a chef server with locked down cookbooks. The cookbooks could be edited locally without touching those used by other systems.