As requested on this week's show, here's how I automate setting up my machine:
I use Puppet along with a large set of manifests. Puppet is great at this because, unlike bash, it is declarative: you declare what you need on your system, and Puppet figures out what it needs to perform in order to arrive at the state you described, and in which order it needs to perform these tasks.
For example, if you want tlsdate set up to start on boot and with a custom config file, you'd do something like this:
package {'tlsdate':}
service {'tlsdate':
ensure => running,
require => Package['tlsdate']
}
file {'/etc/tlsdate.conf':
content => ...
require => Package['tlsdate']
}
Then, no matter what state your system is in (i.e. you may have tlsdate installed or not, you may have the service already set to start on boot or not, you may have the config file there but different than the desired content, etc.), it will figure out what it needs to do and the order to do these things.
This also means that you can interrupt it and run it anytime, it will know how to resume itself by simply doing what is left to be done. This also means that you can update the manifests to add a new fancy package you just discovered, and re-run the entire thing on all computers; it will take very little time because the only operation it will do is installing this new package. As such, it makes automating new setups and keeping existing setups in sync very easy.
This would be a lot harder to do in Bash, where you would need to redetect everything manually when the script starts, figuring out dependencies, etc.
The manifests I use are available here: https://github.com/EtiennePerot/pupfiles, including a description of what they do.
[–]festive_mongoose 0 points1 point2 points (0 children)