summaryrefslogtreecommitdiff
path: root/doc/forum/how_to_install_a_cluster_with_propellor/comment_1_e6860056989da82fd7cd8f374e209548._comment
blob: 21a2b80c0362a16286a15eb5f42c8ebf9b8e664b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
[[!comment format=mdwn
 username="joey"
 subject="""comment 1"""
 date="2015-08-31T20:55:38Z"
 content="""
Don't know that I have an answer to this question. I've never done that. :)

I think it breaks down into several independant questions,
although due to lack of experience I could be missing some.

## Initial installation

I'm working on getting propellor to be able to
generate bootable disk images. <http://joeyh.name/blog/entry/then_and_now/>
Once that works, it might provide a way to generate images to install
machines in a cluster. But, any method for installing the base system
and propellor could work too, and there are probably many cluster-specific
OS installation tools.

## Expressing the cluster in a propellor config file

Propellor's config is a list of hosts, and `defaultMain` looks at the hostname
to determine which host it is provisioning. A cluster might have many hosts
that are very similar or identical, and you probably want it to be easy to
add more.

So, you'll probably want a way to generate a Host from a HostName with the
desired Properties you want nodes in the cluster to have:

[[!format haskell """
clusterNode :: HostName -> Host
clusterNode hn = host hn
	& foo
	& bar
"""]]

Then you could feed a list of hostnames to defaultMain to finish the
config file:

[[!format haskell """
main :: IO ()
main = defaultMain (map clusterNode hostnames)
  where
	hostnames = 
		[ "node1"
		, "node2"
		-- etc
		]
	-- alternatively...
	-- hostnames = map (\n -> "node" ++ show n) [1..100]
"""]]

Or, you could even look up the current hostname, and feed defaultMain 
a Host containing that hostname; so this single propellor configuration
could be used on any number of hosts:

[[!format haskell """
main = IO ()
main = do
	hn <- takeWhile (/= '\n') <$> readProcess "hostname" ["-f"]
	defaultMain [ clusterNode hn ]
"""]]

## Triggering propellor on nodes

When you change your propellor config.hs, you need a way to trigger the
nodes to update. Propellor has a couple of different ways to do this;
you could just use Propellor.Property.Cron.runPropellor to run it periodically
from cron on all the nodes.

Or you could run propellor --spin against all the hosts in the
cluster to push out a change. (It would be a nice enhancement to make
propellor be able to --spin multiple hosts concurrently; there's nothing
really preventing it but the output would be a mess.)

There's certianly room for improvement here. Also you'll probably want some
monitoring, which propellor doesn't provide in itself, etc.