Commit Graph

54 Commits

Author SHA1 Message Date
Joey Hess 681e4dbbcb
propellor spin 2015-04-29 14:26:13 -04:00
Joey Hess e9d5d9aff1 remove toSimpleProp
It didn't do what I thought it did with a RevertableProperty; it always
returned Nothing because even if the input properties to <!> are NoInfo, it
casts them to HasInfo.

Even if it had worked, it lost type safety. Better to export the
Property NoInfo that is used in a RevertableProperty, so it can be used
directly.
2015-01-25 14:47:57 -04:00
Joey Hess 334abae312 fix combines instance
The old one caused the actions to run in the right order, but with the
wrong description.

This problem was found by comparing the [Host] between this branch and
current joeyconfig, and printing out their properties, info, and also their
list of child properties.

The only other difference found is that onChange orders the child property
list differently. That does not have any real effect and would be difficult
to change, so I've left it as-is.
2015-01-25 13:28:04 -04:00
Joey Hess f4fc24aa5c avoid needing to define Show twice 2015-01-25 13:04:39 -04:00
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 141a7c028b use type level functions to fix type inference for `require` 2015-01-24 19:40:43 -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 e583c40c65 more reorg 2015-01-19 15:11:10 -04:00
Joey Hess 603e6d3406 split out types to improve haddock for Propellor.Types 2015-01-19 15:09:03 -04:00
Joey Hess a2a97cbeb2 avoid haddock warnings 2015-01-19 14:26:18 -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 c7609c824b Add descriptions of how to set missing fields to --list-fields output. (Minor API changes) 2015-01-15 20:15:01 -04:00
Joey Hess f1a1d0001a sshPubKey is renamed to Ssh.pubKey, and has an added SshKeyType parameter. 2015-01-04 15:57:27 -04:00
Joey Hess 7cbd367e1c Update intermediary propellor in --spin --via 2015-01-01 17:13:03 -04:00
Joey Hess 4e9b01a8a7 propellor spin
(cherry picked from commit 1d02d589c7)
2014-12-08 01:07:25 -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 9ca332e481 Fixed privdata introspection for User.hasPassword and User.hasSomePassword
This is not a complete fix for the problem that Info doen't propigate
from the called property when code does something like:

	do
		hostname <- asks hostName
		ensureProperty $ foo hostname

Instead, I just eliminated the need to implement hasPassword that way,
by making the PrivData Info use a HostContext which automatically
gets the right hostname passed to it.

All other uses of withPrivData don't have the problem. It's still possible
for the user to run into the problem if they write something like the
above, where foo is a property that uses privdata. However, all properties
that take a Context now also accept a HostContext, so it's at least less
likely the user needs to write that.
2014-12-07 15:03:06 -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 9d975e9ee4 add --merge 2014-11-23 18:48:52 -04:00
Joey Hess 0ea0f7f4de --spin can be passed multiple hosts, and it will provision each host in turn.
Note that if it fails to spin a host, it will stop. I think this is better
than continuing to the next, because there might be a reason to spin hosts
in some specific order (ie, update dns first and then use it).
2014-11-23 15:17:57 -04:00
Joey Hess 40339a7fd8
propellor spin 2014-11-22 15:54:31 -04:00
Joey Hess fd3335e40e --via implemented 2014-11-22 12:57:07 -04:00
Joey Hess 6c92f1034f split out info types 2014-11-21 18:55:33 -04:00
Joey Hess 6e8b28cd3c
propellor spin 2014-11-21 17:11:26 -04:00
Joey Hess a904476333 avoid console output when chaining into chroot and not at console 2014-11-21 01:05:51 -04:00
Joey Hess a4f04fcb02
propellor spin 2014-11-20 15:15:28 -04:00
Joey Hess def4431132 remove unused Eq instance for Info
Its implementation was .. shady at best, as Host has no Eq
2014-11-20 14:16:26 -04:00
Joey Hess b8b746a7f1 starting work on a Chroot module
factored out info up-propigation code rom Docker
2014-11-20 14:15:26 -04:00
Joey Hess 5e4c57652c fix docker container provisioning
Since the containers are no longer on the host list, they were not found
while provisioning, oops.

To fix, had to add to a host's info a map of the containers docked to it.

Unfortunately, that required Propellor.Types.Info be glommed into
Propellor.Types, since it needed to refer to Host.
2014-11-20 00:21:40 -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 325fe4037b
propellor spin 2014-11-19 00:30:06 -04:00
Joey Hess c9fed0fdaa add --update, which will one day replace --boot
But no time soon, since that would break --spin to old versions of
propellor

Maybe after 1 year?
2014-11-18 19:36:30 -04:00
Joey Hess b7bbde3d72 avoid extra git pull when --spin calles first --boot and then --run 2014-11-18 18:26:15 -04:00
Joey Hess 4a0cac113c fix color display when running propellor inside docker 2014-11-18 17:53:42 -04:00
Joey Hess bad6a8c3e6
propellor spin 2014-11-18 15:05:15 -04:00
Joey Hess 8ea43c6302 avoid renaming --boot to --sync
That broke updating existing systems, since --boot is what makes the remote
propellor update itself.

The hostname is no longer needed by --boot for new propellor's, but is
still passed for old ones.

Note that there will be a double run of propellor when upgrading via
--spin, because it now runs --boot followed by --spin on the remote host,
and the old --boot also satisfied all properties.
2014-11-18 01:04:41 -04:00
Joey Hess 40f6d06f1a Run remote propellor --spin with a controlling terminal.
Avoids need for hack to make ansi colors work, but also things like apt-get
and wget process bars will be displayed.
2014-11-18 01:01:50 -04:00
Joey Hess 1e22e178b4 a few other whitespace fixups 2014-10-08 13:19:53 -04:00
Joey Hess 6a674c79d7 fix some accidental uses of spaces, rather than tabs, for indentation 2014-10-08 13:14:21 -04:00
Joey Hess 58f79c12aa
propellor spin 2014-07-06 15:56:56 -04:00
Joey Hess f674c56119 Add --list-fields to list a host's currently set privdata fields. 2014-06-19 14:56:50 -04:00
Joey Hess 42594d6b4c Add --edit to edit a privdata value in $EDITOR 2014-06-19 14:48:15 -04:00
Joey Hess fc49d75e4f Attr is renamed to Info. 2014-06-09 01:47:11 -04:00
Joey Hess 16ae2b503f display improvements 2014-06-05 17:10:58 -04:00
Joey Hess a2db41b4e8 add show instance for Host
doable now that Attr setting is cleaned up, and makes debugging easier
2014-06-05 16:48:17 -04:00
Joey Hess 740740d215 Added --dump to dump out a field of a host's privdata. Useful for editing it. 2014-06-01 16:58:05 -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