Commit Graph

31 Commits

Author SHA1 Message Date
Joey Hess 0ee04ecc43 GADT properties seem to work (untested)
* Property has been converted to a GADT, and will be Property NoInfo
  or Property HasInfo.
  This was done to make sure that ensureProperty is only used on
  properties that do not have Info.
  Transition guide:
  - Change all "Property" to "Property NoInfo" or "Property WithInfo"
    (The compiler can tell you if you got it wrong!)
  - To construct a RevertableProperty, it is useful to use the new
    (<!>) operator
  - Constructing a list of properties can be problimatic, since
    Property NoInto and Property WithInfo are different types and cannot
    appear in the same list. To deal with this, "props" has been added,
    and can built up a list of properties of different types,
    using the same (&) and (!) operators that are used to build
    up a host's properties.
2015-01-24 22:38:51 -04:00
Joey Hess 45c94ffdd7 moving to using the GADT
The problem this exposes has to do with requires. As implemented,
requires yields either a Property HasInfo or a Property NoInfo depending
on its inputs. That works. But look what happens when it's used:

*Propellor.Types> let foo = IProperty "foo" (return NoChange) mempty mempty
*Propellor.Types> let bar = IProperty "bar" (return NoChange) mempty mempty
*Propellor.Types> foo `requires` bar

<interactive>:17:5:
    No instance for (Requires (Property HasInfo) (Property HasInfo) r0)
      arising from a use of `requires'
    The type variable `r0' is ambiguous
    Possible fix: add a type signature that fixes these type variable(s)
    Note: there is a potential instance available:
      instance Requires
                 (Property HasInfo) (Property HasInfo) (Property HasInfo)
        -- Defined at Propellor/Types.hs:167:10
    Possible fix:
      add an instance declaration for
      (Requires (Property HasInfo) (Property HasInfo) r0)
    In the expression: foo `requires` bar
    In an equation for `it': it = foo `requires` bar

This can be avoided by specifying the result type:

*Propellor.Types> (foo `requires` bar) :: Property HasInfo
property "foo"

But then when multiple `requires` are given, the result type has to be
given each time:

*Propellor.Types> (foo `requires` bar `requires` bar) :: Property HasInfo
<interactive>:22:6:
    No instance for (Requires (Property HasInfo) (Property HasInfo) x0)
      arising from a use of `requires'
    The type variable `x0' is ambiguous
    Possible fix: add a type signature that fixes these type variable(s)
    Note: there is a potential instance available:
      instance Requires
                 (Property HasInfo) (Property HasInfo) (Property HasInfo)
        -- Defined at Propellor/Types.hs:167:10
    Possible fix:
      add an instance declaration for
      (Requires (Property HasInfo) (Property HasInfo) x0)
    In the first argument of `requires', namely `foo `requires` bar'
    In the expression:
        (foo `requires` bar `requires` bar) :: Property HasInfo
    In an equation for `it':
        it = (foo `requires` bar `requires` bar) :: Property HasInfo

<interactive>:22:21:
    No instance for (Requires x0 (Property HasInfo) (Property HasInfo))
      arising from a use of `requires'
    The type variable `x0' is ambiguous
    Possible fix: add a type signature that fixes these type variable(s)
    Note: there are several potential instances:
      instance Requires
                 (Property NoInfo) (Property HasInfo) (Property HasInfo)
        -- Defined at Propellor/Types.hs:175:10
      instance Requires
                 (Property HasInfo) (Property HasInfo) (Property HasInfo)
        -- Defined at Propellor/Types.hs:167:10
    Possible fix:
      add an instance declaration for
      (Requires x0 (Property HasInfo) (Property HasInfo))
    In the expression:
        (foo `requires` bar `requires` bar) :: Property HasInfo
    In an equation for `it':
        it = (foo `requires` bar `requires` bar) :: Property HasInfo

*Propellor.Types> (((foo `requires` bar) :: Property HasInfo) `requires` bar) :: Property HasInfo
property "foo"

Yuggh!
2015-01-24 16:54:49 -04:00
Joey Hess 414ee7eee6 added GADT to determine between a property with info and without
Not yet used
2015-01-24 16:53:59 -04:00
Joey Hess 0a2a553d31 add back a warning aboit info propigation to ensureProperty 2015-01-19 16:14:01 -04:00
Joey Hess 603e6d3406 split out types to improve haddock for Propellor.Types 2015-01-19 15:09:03 -04:00
Joey Hess afee550e70 Property tree
Properties now form a tree, instead of the flat list used before.

This simplifies propigation of Info from the Properties used inside a
container to the outer host; the Property that docks the container on the
host can just have as child properties all the inner Properties, and their
Info can then be gathered recursively. (Although in practice it still needs
to be filtered, since not all Info should propigate out of a container.)

Note that there is no change to how Properties are actually satisfied.
Just because a Property lists some child properties, this does not mean
they always have their propertySatisfy actions run. It's still up to the
parent property to run those actions.

That's necessary so that a container's properties can be satisfied inside
it, not outside. It also allows property combinators to
add the combined Properties to their childProperties list, even if,
like onChange, they don't always run the child properties at all.

Testing: I tested that the exact same Info is calculated before and after
this change, for every Host in my config file.
2015-01-18 18:46:38 -04:00
Joey Hess 52664e6220 sshPubKey is renamed to Ssh.pubKey 2015-01-04 15:36:53 -04:00
Joey Hess dc36a98fc1 Revert ensureProperty warning message, too many false positives in places where Info is correctly propigated. Better approach needed. 2014-12-21 21:33:03 -04:00
Joey Hess d194765e10
propellor spin 2014-12-21 21:14:11 -04:00
Joey Hess 42a0c83248 Display a warning when ensureProperty is used on a property which has Info and is so prevented from propigating it.
Would much rather a type-based fixed, but this is all I have for now.
2014-12-07 17:09:55 -04:00
Joey Hess 5a932c382d docuemnt info propigtion problem 2014-12-07 16:37:02 -04:00
Joey Hess 29442f222e Reboot.atEnd 2014-12-06 13:21:19 -04:00
Joey Hess fcff7762e3 endAction can be used to register an action to run once propellor has successfully run on a host. 2014-12-06 06:34:32 -04:00
Joey Hess 9500e9bb81
added more debugging 2014-11-27 17:55:56 -04:00
Joey Hess 7ddb862176
propellor spin 2014-11-27 17:51:41 -04:00
Joey Hess ca09087caf
propellor spin 2014-11-22 22:24:09 -04:00
Joey Hess 6eb64d56e3 avoid setting title when not at console 2014-11-21 23:33:39 -04:00
Joey Hess 0a415a7b41
show last line if it cannot be parsed as a serialized Result 2014-11-21 23:30:40 -04:00
Joey Hess 3669bd61d0
propellor spin 2014-11-20 16:07:57 -04:00
Joey Hess a4f04fcb02
propellor spin 2014-11-20 15:15:28 -04:00
Joey Hess 4dddbb725d prevent multiple concurrent provisioning inside docker container
Lock a lock file while provisioning inside, otherwise propellor could be
running to init the container when the system has just booted, or the
container was just started from being stopped, and at the same time,
propellor run outside the container chains into it to provision.

Previously, simplesh prevented this in a different way.
2014-11-19 01:28:38 -04:00
Joey Hess ac46ab4d0c
propellor spin 2014-07-23 12:33:44 -04:00
Joey Hess 41a23743e7
propellor spin 2014-07-23 12:27:38 -04:00
Joey Hess dd32a63a07
propellor spin 2014-07-23 12:25:38 -04:00
Joey Hess fc49d75e4f Attr is renamed to Info. 2014-06-09 01:47:11 -04:00
Joey Hess 58c8d74b4c simplified record accessors 2014-05-31 20:48:23 -04:00
Joey Hess 4f70fceb3a got rid of the Attr -> Attr SetAttr hack, and use monoids for Attr
The SetAttr hack used to be needed because the hostname was part of the
Attr, and was required to be present. Now that it's moved to Host, let's
get rid of that, since it tended to waste CPU.
2014-05-31 20:43:23 -04:00
Joey Hess 4c96b0681c
propellor spin 2014-05-31 18:52:42 -04:00
Joey Hess 4722b62e45
propellor spin 2014-05-31 18:40:34 -04:00
Joey Hess 5fc4b00651 remove now redundant _hostname field of Attr
Now that Host includes _hostName, it's redundant to also keep it in Attr.

This requires changing the reader monad to operate on the whole Host.
2014-05-31 18:04:41 -04:00
Joey Hess 7115d1ec16 moved source code to src
This is to work around OSX's brain-damange regarding filename case
insensitivity.

Avoided moving config.hs, because it's a config file. Put in a symlink to
make build work.
2014-05-14 19:41:05 -04:00