Propellor's config file is written in Haskell, and Haskell is invaluable to extend Propellor with your own custom properties. But you don't need to know about monads to configure Propellor!
Let's take a quick tour of the
-- This is the main configuration file for Propellor, and is used to build -- the propellor program.
-- starts a comment in this file.
import Propellor import qualified Propellor.Property.File as File import qualified Propellor.Property.Apt as Apt import qualified Propellor.Property.User as User import qualified Propellor.Property.Cron as Cron
This loads up Propellor's modules. You'll almost certainly want these; many more can be found in the API documentation.
main :: IO () main = defaultMain hosts
This config file is the Propellor program, and so it needs a little
stub to go run itself. No need to ever change this part.
hosts is the list of hosts that you configure, and it comes next:
-- The hosts propellor knows about. hosts :: [Host] hosts = [ mylaptop , myserver ]
Finally, you need to define the configuration for each host in the list:
mylaptop :: Host mylaptop = host "mylaptop.example.com" $ props & osDebian Unstable X86_64 & Apt.stdSourcesList myserver :: Host myserver = host "server.example.com" $ props & osDebian (Stable "jessie") X86_64 & Apt.stdSourcesList & Apt.installed ["ssh"]
The configuration for the mylaptop host first tells propellor what
OS it's running. Then the
stdSourcesList line tells propellor to
/etc/apt/sources.list, using its OS.
(Of course you might want to change that
Each property of the host is prefixed with an "&" operator. This just makes a list of properties.
Some other properties you may find in your config.hs, or want to add:
& Apt.unattendedUpgrades & User.hasSomePassword (User "root") & "/etc/default/foodaemon" `File.containsLine` "ENABLED=yes" & Cron.runPropellor (Cron.Times "30 * * * *")
Some of these properties can be reverted -- this makes Propellor undo whatever effects they might have. For example, unattended upgrades can be scary, so maybe you turned that on, but want to disable it now. To do so, just change the "&" to a "!"
Some properties cannot be reverted. Yet. It takes coding to implement revertability. If you try to revert a property that does not support reversion, propellor will fail to compile! This is a good thing.. it avoids you getting confused or bad things happening.
The error message when this happens might look a little scary. But if you read through it, it's remarkably precise about what and where the problem is.
config.hs:30:19: Couldn't match expected type `RevertableProperty' with actual type `Property DebianLike' In the return type of a call of `Apt.installed' In the second argument of `(!)', namely `Apt.installed ["ssh"]' In the first argument of `(&)', namely `host "mylaptop.example.com" & Apt.stdSourcesList Unstable & Apt.unattendedUpgrades ! Apt.installed ["ssh"]'
Similarly, if you make a typo in the config file, you'll probably get a long but informative error message.
config.hs:27:19: Not in scope: `Apt.standardSourcesList' Perhaps you meant one of these: `Apt.stdSourcesList' (imported from Propellor.Property.Apt) ...
That's really all there is to configuring Propellor. Once you
config.hs ready to try out, you can run
propellor --spin $host
on one of the hosts configured in it.
(If you'd like to learn a little Haskell after all, check out Learn You a Haskell for Great Good.)