Live data from Hacker News

What scripts have you built to stand up a new server?

news.ycombinator.com

41–50 of 55 posts

Re: What scripts have you built to stand up a new server?

#41
post #36

These days I use Ansible to take care of all of that. I can’t share the scripts due to company restrictions, but it has probably built ~10,000 servers in the last year. I first run a bunch of checks to try and make sure the build will be successful. Then create the instance where cloud-init does a few basics to allow the rest to work. Once the instance is up, the connection in Ansible flips from localhost to the serv…

> That’s probably something we could solve for, but it hasn’t been a big deal so far. I did see the "it doesn't bother me" part, but for others looking to speed up mass provisioning don't overlook ansible-pull https://docs.ansible.com/ansible/10/cli/ansible-pull.html > It's also handy for keeping systems in a desired state but I use it a lot more for "clone this when you boot" times hundreds of devices. Error recover…

I’ll have to look into this a little to see if it might be useful for some other things we have, if we’re even allowed to used it. We’re running everything through AAP which is useful for audits. We do have a home-grown tool for installing and maintaining state of a lot of the things we need to setup. We install that during setup with Ansible and wait for it to finish its initial setup to make sure there are no errors before we turn it over to the customer.

The other issue we have is our change management process. We need to provide a single update with the status of everything when it’s done. So our process can only go as fast as the slowest server. We could change this, but it would be a political nightmare I don’t want to deal with.

Re: What scripts have you built to stand up a new server?

#42
Like others have said, cloud-init is the way. For the few instances that may not have the right tooling baked into their base image or where it’s not fully supported by the orchestrator (like Proxmox containers), I use https://github.com/rcarmo/ground-init (which I first wrote to set up my laptop and local machines and lets me re-use cloud-init files).

Re: What scripts have you built to stand up a new server?

#44
post #22

nixos-anywhere and some flakes is all i need! sometimes for new setups I'll run nixos-anywhere and write the config directly on the machine, but that's usually just for sketching out ideas. I'll reprovision with a module after I've worked out the kinks.

I just transitioned my home and homelab PCs to nixos+anywhere+flakes and I can't imagine going back to ansible or puppet or even docker compose. you know that it won't drift. you can generate images from the same config you apply to a host. you can stamp out the same config across N hosts. you can completely reconfigure a host without reprovisioning it from scratch. you can run slim VMs by mounting the nix store as r…

I recently started using devbox over homebrew for package installs on my Mac and this has gotten me more interested in nix - however, neither of the VPS providers we use offer NixOS as an OS option, is there a way to achieve that declarative setup on Ubuntu?

Re: What scripts have you built to stand up a new server?

#46

Strongly do NOT recommend what we are doing - https://github.com/chrisgo/fabric-example - https://github.com/chrisgo/fabric2-example

I see what you mean https://github.com/chrisgo/fabric2-example/blob/159ca5ea1844...

Also, I am obligated to point it out every time I see it: `curl --fail` for life otherwise bash will cheerfully try and execute the 503 html that curl writes out https://github.com/chrisgo/fabric2-example/blob/159ca5ea1844...

Re: What scripts have you built to stand up a new server?

#47
post #44

Earlier quoted context omitted.

I just transitioned my home and homelab PCs to nixos+anywhere+flakes and I can't imagine going back to ansible or puppet or even docker compose. you know that it won't drift. you can generate images from the same config you apply to a host. you can stamp out the same config across N hosts. you can completely reconfigure a host without reprovisioning it from scratch. you can run slim VMs by mounting the nix store as r…

I recently started using devbox over homebrew for package installs on my Mac and this has gotten me more interested in nix - however, neither of the VPS providers we use offer NixOS as an OS option, is there a way to achieve that declarative setup on Ubuntu?

the magic of nixos-anywhere is that you can start with a common OS base image and overwrite it with nixos.

you can also run nix as a service on other operating systems. https://lix.systems/install/#on-any-other-linuxmacos-system

Re: What scripts have you built to stand up a new server?

#48
post #6

On mobile at the moment, can't share - but I have a great library of Ansible roles. Strongly recommended for those looking for inspiration. Give "ansible-doc --list" a spin! This shows modules, it can filter for existing roles as well.

Thanks! I haven't looked at Ansible before

Happy to share! I'll save the sales pitch, but the module/role library is truly a good source of inspiration despite the language.

The code itself isn't that important - declarative YAML, but best practices/patterns can be an art. I don't actually have much published that wouldn't tie my identities together :P

Avoid using Ansible to wrap 'shell' commands with modules of the same name... outside of information gathering, stick with the modules specific to the work. Also avoid using when - may often prefer 'handlers' :)

Re: What scripts have you built to stand up a new server?

#49
As for general principles, if one’s packer, containerfile, cloud-init, bash, ansible, or puppet is much more than “install packages, set keys and a small amount of per-environment config, and start services,” it is likely that local packages are not being used effectively.

Re: What scripts have you built to stand up a new server?

#50
post #46

Strongly do NOT recommend what we are doing - https://github.com/chrisgo/fabric-example - https://github.com/chrisgo/fabric2-example

I see what you mean https://github.com/chrisgo/fabric2-example/blob/159ca5ea1844... Also, I am obligated to point it out every time I see it: `curl --fail` for life otherwise bash will cheerfully try and execute the 503 html that curl writes out https://github.com/chrisgo/fabric2-example/blob/159ca5ea1844...

Thanks, will take a look at that curl thing. We are still using this and been working for us for ~15 years (python 2, ported to python 3) and this is just an example of how to take https://fabfile.org to the extreme but still is not the best way to do it. We only ~50 servers so it is not a massive fleet. The convenience of typing `fab ` to do things under control is still better than nothing :)
Post reply on HN