Commit 5dd0de9aec2519516e453b46919af8a1c764f3ef
have a play
Michael Williams committed on 12/24/2017, 10:38:28 PMParent: b3b5e786806c8e137c4383c6a3c761b8d6221c36
Files changed
salt/state/cloud.sls | changed |
salt/state/top.sls | changed |
salt/state/hub.sls | added |
salt/state/pub.sls | added |
salt/state/cloud.sls | ||
---|---|---|
@@ -1,21 +1,12 @@ | ||
1 | -{% set roles_by_service = { | |
2 | - 'hub': [ | |
3 | - 'master' | |
4 | - ], | |
5 | - 'pub': [ | |
6 | - 'minion' | |
7 | - ] | |
8 | -%} | |
9 | -{% set agents = salt['pillar.get']('agents', []) %} | |
10 | -{% for agent in agents %} | |
1 … | +{% set hubs = salt['pillar.get']('hub.list', []) %} | |
2 … | +{% for hub in hubs %} | |
11 | 3 … | |
12 | -{% if agent.type == 'bot' %} | |
4 … | +{$ set provider = hub.provider %} | |
5 … | +{% set size = hub.size || 'small' %} | |
6 … | +{% set profile = salt['pillar.get']('cloud.' + provider + '_' + size, []) %} | |
13 | 7 … | |
14 | -{% set size = agent.size || 'small' %} | |
15 | -{% set profile = salt['pillar.get']('cloud.profiles_' + size, []) %} | |
16 | - | |
17 | -{{agent.name}}: | |
8 … | +{{hub.name}}: | |
18 | 9 … | cloud.present: |
19 | 10 … | - script: bootstrap-salt |
20 | 11 … | - script_args: -P git v2017.7.2 |
21 | 12 … | {% for key, value in profile.items() %} |
@@ -24,12 +15,11 @@ | ||
24 | 15 … | - minion: |
25 | 16 … | grains: |
26 | 17 … | env: production |
27 | 18 … | roles: |
28 | - - salt | |
29 | - {% for role in roles_by_service[agent.service] %} | |
30 | - - {{ role }} | |
31 | - {% endfor %} | |
19 … | + - minion | |
20 … | + - hub | |
21 … | + - pub | |
32 | 22 … | |
33 | 23 … | {% endif %} |
34 | 24 … | |
35 | 25 … | {% endfor %} |
salt/state/top.sls | ||
---|---|---|
@@ -1,7 +1,18 @@ | ||
1 | 1 … | base: |
2 … | + '*': | |
3 … | + - docker | |
2 | 4 … | 'roles:master': |
3 | 5 … | - match: grain |
4 | 6 … | - salt.master |
7 … | + - cloud | |
5 | 8 … | 'roles:minion': |
6 | 9 … | - match: grain |
7 | 10 … | - salt.minion |
11 … | +{# | |
12 … | + 'roles:hub' | |
13 … | + - match: grain | |
14 … | + - hub | |
15 … | + 'roles:pub' | |
16 … | + - match: grain | |
17 … | + - pub | |
18 … | +#} |
salt/state/hub.sls |
---|
salt/state/pub.sls | ||
---|---|---|
@@ -1,0 +1,73 @@ | ||
1 … | +{# TODO | |
2 … | + | |
3 … | +apt update | |
4 … | +apt upgrade -y | |
5 … | +apt install -y apt-transport-https ca-certificates curl software-properties-common | |
6 … | +wget https://download.docker.com/linux/debian/gpg -O docker-gpg | |
7 … | +sudo apt-key add docker-gpg | |
8 … | +echo "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee -a /etc/apt/sources.list.d/docker.list | |
9 … | +apt update | |
10 … | +apt install -y docker-ce | |
11 … | +systemctl start docker | |
12 … | +systemctl enable docker | |
13 … | + | |
14 … | +docker pull ahdinosaur/ssb-pub | |
15 … | + | |
16 … | +mkdir /root/ssb-pub-data | |
17 … | +chown -R 1000:1000 /root/ssb-pub-data | |
18 … | + | |
19 … | +docker run -d --name sbot \ | |
20 … | + -v ~/ssb-pub-data/:/home/node/.ssb/ \ | |
21 … | + -e ssb_host="<hostname.yourdomain.tld>" \ | |
22 … | + -p 8008:8008 --restart unless-stopped \ | |
23 … | + ahdinosaur/ssb-pub | |
24 … | + | |
25 … | +#} | |
26 … | + | |
27 … | +ahdinosaur/ssb-pub: | |
28 … | + docker_image.present | |
29 … | + | |
30 … | +ahdinosaur/healer: | |
31 … | + docker_image.present | |
32 … | + | |
33 … | +healer: | |
34 … | + docker_container.running: | |
35 … | + - image: ahdinosaur/healer | |
36 … | + - require: | |
37 … | + - docker_image: ahdinosaur/healer | |
38 … | + | |
39 … | +{% set pubs = salt['grains.get']('pub.list', []) %} | |
40 … | +{% for pub in pubs %} | |
41 … | + | |
42 … | +{% set name = pub.name %} | |
43 … | + | |
44 … | +/root/bots/{{name}} | |
45 … | + file.directory | |
46 … | + | |
47 … | +/root/bots/{{name}}/secret | |
48 … | + file.managed: | |
49 … | + - mode: | |
50 … | + - require: | |
51 … | + - file: /root/bots/{{name}} | |
52 … | + | |
53 … | +/root/bots/{{name}}/gossip.json | |
54 … | + file.managed: | |
55 … | + - require: | |
56 … | + - file: /root/bots/{{name}} | |
57 … | + | |
58 … | +{{name}}: | |
59 … | + docker_container.running: | |
60 … | + - image: ahdinosaur/ssb-pub | |
61 … | + - env: | |
62 … | + - ssb_host: {{name}} | |
63 … | + - binds: | |
64 … | + - /root/bots/{{name}}:/home/node/.ssb/ | |
65 … | + - ports: | |
66 … | + - 8008 | |
67 … | + - restart_policy: unless-stopped | |
68 … | + - require: | |
69 … | + - docker_image: ahdinosaur/ssb-pub | |
70 … | + - file: /root/bots/{{name}}/secret | |
71 … | + - file: /root/bots/{{name}}/gossip.json | |
72 … | + | |
73 … | +{% endfor %} |
Built with git-ssb-web