Merge branch 'joeyconfig'
This commit is contained in:
commit
45d943023d
|
@ -6,6 +6,8 @@ propellor (1.0.1) UNRELEASED; urgency=medium
|
||||||
* --spin target --via relay causes propellor to bounce through an
|
* --spin target --via relay causes propellor to bounce through an
|
||||||
intermediate relay host, which handles any necessary uploads
|
intermediate relay host, which handles any necessary uploads
|
||||||
when provisioning the target host.
|
when provisioning the target host.
|
||||||
|
* --spin can be passed multiple hosts, and it will provision each host
|
||||||
|
in turn.
|
||||||
* Hostname parameters not containing dots are looked up in the DNS to
|
* Hostname parameters not containing dots are looked up in the DNS to
|
||||||
find the full hostname.
|
find the full hostname.
|
||||||
* Added group-related properties. Thanks, Félix Sipma.
|
* Added group-related properties. Thanks, Félix Sipma.
|
||||||
|
|
|
@ -20,12 +20,18 @@ action as needed to satisfy the configured properties of the local host.
|
||||||
|
|
||||||
# OPTIONS
|
# OPTIONS
|
||||||
|
|
||||||
* --spin targethost [--via relayhost]
|
* --spin targethost [targethost ...] [--via relayhost]
|
||||||
|
|
||||||
Causes propellor to automatically install itself on the specified target
|
Causes propellor to automatically install itself on the specified target
|
||||||
host, or if it's already installed there, push any updates. Propellor is
|
host, or if it's already installed there, push any updates. Propellor is
|
||||||
then run on the target host, to satisfy its configured properties.
|
then run on the target host, to satisfy its configured properties.
|
||||||
|
|
||||||
|
A signed git commit is made by --spin, so that any changes you have made
|
||||||
|
get propigated to the target host.
|
||||||
|
|
||||||
|
Multiple target hosts can be specified; propellor will run on each of
|
||||||
|
them in sequence.
|
||||||
|
|
||||||
When run with --via, propellor sshes to the relay host and runs
|
When run with --via, propellor sshes to the relay host and runs
|
||||||
`propellor --spin hostname` from there. This can be useful when
|
`propellor --spin hostname` from there. This can be useful when
|
||||||
propellor is installing itself, since most of the data transfer
|
propellor is installing itself, since most of the data transfer
|
||||||
|
|
|
@ -39,8 +39,11 @@ usageError ps = do
|
||||||
processCmdLine :: IO CmdLine
|
processCmdLine :: IO CmdLine
|
||||||
processCmdLine = go =<< getArgs
|
processCmdLine = go =<< getArgs
|
||||||
where
|
where
|
||||||
go ("--spin":h:[]) = Spin <$> hostname h <*> pure Nothing
|
go ("--spin":ps) = case reverse ps of
|
||||||
go ("--spin":h:"--via":r:[]) = Spin <$> hostname h <*> pure (Just r)
|
(r:"--via":hs) -> Spin
|
||||||
|
<$> mapM hostname (reverse hs)
|
||||||
|
<*> pure (Just r)
|
||||||
|
_ -> Spin <$> mapM hostname ps <*> pure Nothing
|
||||||
go ("--add-key":k:[]) = return $ AddKey k
|
go ("--add-key":k:[]) = return $ AddKey k
|
||||||
go ("--set":f:c:[]) = withprivfield f c Set
|
go ("--set":f:c:[]) = withprivfield f c Set
|
||||||
go ("--dump":f:c:[]) = withprivfield f c Dump
|
go ("--dump":f:c:[]) = withprivfield f c Dump
|
||||||
|
@ -97,12 +100,14 @@ defaultMain hostlist = do
|
||||||
go _ (Update (Just h)) = forceConsole >> fetchFirst (update (Just h))
|
go _ (Update (Just h)) = forceConsole >> fetchFirst (update (Just h))
|
||||||
go True cmdline@(Spin _ _) = buildFirst cmdline $ go False cmdline
|
go True cmdline@(Spin _ _) = buildFirst cmdline $ go False cmdline
|
||||||
go True cmdline = updateFirst cmdline $ go False cmdline
|
go True cmdline = updateFirst cmdline $ go False cmdline
|
||||||
go False (Spin hn r) = withhost hn $ spin hn r
|
go False (Spin hs r) = do
|
||||||
|
commitSpin
|
||||||
|
forM_ hs $ \hn -> withhost hn $ spin hn r
|
||||||
go False cmdline@(SimpleRun hn) = buildFirst cmdline $
|
go False cmdline@(SimpleRun hn) = buildFirst cmdline $
|
||||||
go False (Run hn)
|
go False (Run hn)
|
||||||
go False (Run hn) = ifM ((==) 0 <$> getRealUserID)
|
go False (Run hn) = ifM ((==) 0 <$> getRealUserID)
|
||||||
( onlyprocess $ withhost hn mainProperties
|
( onlyprocess $ withhost hn mainProperties
|
||||||
, go True (Spin hn Nothing)
|
, go True (Spin [hn] Nothing)
|
||||||
)
|
)
|
||||||
|
|
||||||
withhost :: HostName -> (Host -> IO ()) -> IO ()
|
withhost :: HostName -> (Host -> IO ()) -> IO ()
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
module Propellor.Spin (
|
module Propellor.Spin (
|
||||||
|
commitSpin,
|
||||||
spin,
|
spin,
|
||||||
update,
|
update,
|
||||||
gitPushHelper
|
gitPushHelper
|
||||||
|
@ -23,18 +24,19 @@ import qualified Propellor.Shim as Shim
|
||||||
import Utility.FileMode
|
import Utility.FileMode
|
||||||
import Utility.SafeCommand
|
import Utility.SafeCommand
|
||||||
|
|
||||||
|
commitSpin :: IO ()
|
||||||
|
commitSpin = do
|
||||||
|
void $ actionMessage "Git commit" $
|
||||||
|
gitCommit [Param "--allow-empty", Param "-a", Param "-m", Param "propellor spin"]
|
||||||
|
-- Push to central origin repo first, if possible.
|
||||||
|
-- The remote propellor will pull from there, which avoids
|
||||||
|
-- us needing to send stuff directly to the remote host.
|
||||||
|
whenM hasOrigin $
|
||||||
|
void $ actionMessage "Push to central git repository" $
|
||||||
|
boolSystem "git" [Param "push"]
|
||||||
|
|
||||||
spin :: HostName -> Maybe HostName -> Host -> IO ()
|
spin :: HostName -> Maybe HostName -> Host -> IO ()
|
||||||
spin target relay hst = do
|
spin target relay hst = do
|
||||||
unless relaying $ do
|
|
||||||
void $ actionMessage "Git commit" $
|
|
||||||
gitCommit [Param "--allow-empty", Param "-a", Param "-m", Param "propellor spin"]
|
|
||||||
-- Push to central origin repo first, if possible.
|
|
||||||
-- The remote propellor will pull from there, which avoids
|
|
||||||
-- us needing to send stuff directly to the remote host.
|
|
||||||
whenM hasOrigin $
|
|
||||||
void $ actionMessage "Push to central git repository" $
|
|
||||||
boolSystem "git" [Param "push"]
|
|
||||||
|
|
||||||
cacheparams <- if viarelay
|
cacheparams <- if viarelay
|
||||||
then pure ["-A"]
|
then pure ["-A"]
|
||||||
else toCommand <$> sshCachingParams hn
|
else toCommand <$> sshCachingParams hn
|
||||||
|
@ -78,7 +80,7 @@ spin target relay hst = do
|
||||||
|
|
||||||
runcmd = "cd " ++ localdir ++ " && ./propellor " ++ cmd
|
runcmd = "cd " ++ localdir ++ " && ./propellor " ++ cmd
|
||||||
cmd = if viarelay
|
cmd = if viarelay
|
||||||
then "--serialized " ++ shellEscape (show (Spin target (Just target)))
|
then "--serialized " ++ shellEscape (show (Spin [target] (Just target)))
|
||||||
else "--continue " ++ shellEscape (show (SimpleRun target))
|
else "--continue " ++ shellEscape (show (SimpleRun target))
|
||||||
|
|
||||||
-- Update the privdata, repo url, and git repo over the ssh
|
-- Update the privdata, repo url, and git repo over the ssh
|
||||||
|
|
|
@ -142,7 +142,7 @@ instance ActionResult Result where
|
||||||
|
|
||||||
data CmdLine
|
data CmdLine
|
||||||
= Run HostName
|
= Run HostName
|
||||||
| Spin HostName (Maybe HostName)
|
| Spin [HostName] (Maybe HostName)
|
||||||
| SimpleRun HostName
|
| SimpleRun HostName
|
||||||
| Set PrivDataField Context
|
| Set PrivDataField Context
|
||||||
| Dump PrivDataField Context
|
| Dump PrivDataField Context
|
||||||
|
|
Loading…
Reference in New Issue