Hostname parameters not containing dots are looked up in the DNS to find the full hostname.
This commit is contained in:
parent
95f78a0586
commit
9a8fcf80bb
|
@ -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.
|
||||||
|
* Hostname parameters not containing dots are looked up in the DNS to
|
||||||
|
find the full hostname.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Sat, 22 Nov 2014 00:12:35 -0400
|
-- Joey Hess <joeyh@debian.org> Sat, 22 Nov 2014 00:12:35 -0400
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import System.Environment (getArgs)
|
||||||
import Data.List
|
import Data.List
|
||||||
import System.Exit
|
import System.Exit
|
||||||
import System.PosixCompat
|
import System.PosixCompat
|
||||||
|
import qualified Network.BSD
|
||||||
|
|
||||||
import Propellor
|
import Propellor
|
||||||
import Propellor.Protocol
|
import Propellor.Protocol
|
||||||
|
@ -40,9 +41,8 @@ usageError ps = do
|
||||||
processCmdLine :: IO CmdLine
|
processCmdLine :: IO CmdLine
|
||||||
processCmdLine = go =<< getArgs
|
processCmdLine = go =<< getArgs
|
||||||
where
|
where
|
||||||
go ("--run":h:[]) = return $ Run h
|
go ("--spin":h:[]) = Spin <$> hostname h <*> pure Nothing
|
||||||
go ("--spin":h:[]) = return $ Spin h Nothing
|
go ("--spin":h:"--via":r:[]) = Spin <$> hostname h <*> pure (Just r)
|
||||||
go ("--spin":h:"--via":r:[]) = return $ Spin h (Just r)
|
|
||||||
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
|
||||||
|
@ -56,9 +56,10 @@ processCmdLine = go =<< getArgs
|
||||||
go ("--serialized":s:[]) = serialized Serialized s
|
go ("--serialized":s:[]) = serialized Serialized s
|
||||||
go ("--continue":s:[]) = serialized Continue s
|
go ("--continue":s:[]) = serialized Continue s
|
||||||
go ("--gitpush":fin:fout:_) = return $ GitPush (Prelude.read fin) (Prelude.read fout)
|
go ("--gitpush":fin:fout:_) = return $ GitPush (Prelude.read fin) (Prelude.read fout)
|
||||||
|
go ("--run":h:[]) = go [h]
|
||||||
go (h:[])
|
go (h:[])
|
||||||
| "--" `isPrefixOf` h = usageError [h]
|
| "--" `isPrefixOf` h = usageError [h]
|
||||||
| otherwise = return $ Run h
|
| otherwise = Run <$> hostname h
|
||||||
go [] = do
|
go [] = do
|
||||||
s <- takeWhile (/= '\n') <$> readProcess "hostname" ["-f"]
|
s <- takeWhile (/= '\n') <$> readProcess "hostname" ["-f"]
|
||||||
if null s
|
if null s
|
||||||
|
@ -210,3 +211,10 @@ spin target relay hst = do
|
||||||
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))
|
||||||
|
|
||||||
|
hostname :: String -> IO HostName
|
||||||
|
hostname s
|
||||||
|
| "." `isInfixOf` s = pure s
|
||||||
|
| otherwise = do
|
||||||
|
h <- Network.BSD.getHostByName s
|
||||||
|
return (Network.BSD.hostName h)
|
||||||
|
|
|
@ -1,6 +1,17 @@
|
||||||
module Propellor.Types.OS where
|
module Propellor.Types.OS (
|
||||||
|
HostName,
|
||||||
|
UserName,
|
||||||
|
GroupName,
|
||||||
|
System(..),
|
||||||
|
Distribution(..),
|
||||||
|
DebianSuite(..),
|
||||||
|
isStable,
|
||||||
|
Release,
|
||||||
|
Architecture,
|
||||||
|
) where
|
||||||
|
|
||||||
|
import Network.BSD (HostName)
|
||||||
|
|
||||||
type HostName = String
|
|
||||||
type UserName = String
|
type UserName = String
|
||||||
type GroupName = String
|
type GroupName = String
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue