I've got a server defined in config.hs as follows:
myserver :: Host
myserver = host "myserver.mydomain" $ props
& standardSystem (Stable "jessie") X86_64 [ "Welcome to myserver!" ]
I'm writing a module (to deploy Matrix, FWIW) which has a section like this:
sources :: Property Debian
sources = File.hasContent "/etc/apt/sources.list.d/matrix.list"
[ "# Deployed by Propellor"
, ""
, "deb http://matrix.org/packages/debian/ jessie main"
] `onChange` Apt.update
What I would like to be able to do, for example, is pull "jessie" from the standardSystem line into the sources function.
The host name is another I'd like to be able to pull in, so that I can abstract as much as possible and wind up with a line that looks not unlike this:
& Matrix.server
Instead of
& Matrix.server hostname jessie
Am I barking up the wrong tree and should I just embrace the latter?
This is where propellor's
Info
system comes in.Propellor.Info.getOS
can be run to get the OS info.It's also possible to add new properties that add new values with custom types to
Info
.The hostname is not currently stored in
Info
, but it probably should be; that would be a good simplification. Currently there's a separate way to get the hostname:asks hostName
(run in the Propellor monad)A worked example:
Ugh, sorry to ask again but I'm specifically stuck trying to extract the Debian suite only from this. Is this stored as a specific value I can draw on? I've been wading through the source and added in a swag of trial and error with no luck.
I can see the suite listed in the output
but I was wondering if there was a method to pull out just the suite code name (ie: "jessie") that did not involve a regex looking for it amongst that output.
The goal is to query Info so that a suite name can be added to a sources list.
If I have to regex, that's OK, I just didn't want to go down that path if there was a smarted way.
Thanks Joey
What you're looking for is not a regexp, but Haskell's pattern matching.
For example: