git ssb

1+

dinoworm 🐛 / butt-as-a-service



Commit 5dd0de9aec2519516e453b46919af8a1c764f3ef

have a play

Michael Williams committed on 12/24/2017, 10:38:28 PM
Parent: b3b5e786806c8e137c4383c6a3c761b8d6221c36

Files changed

salt/state/cloud.slschanged
salt/state/top.slschanged
salt/state/hub.slsadded
salt/state/pub.slsadded
salt/state/cloud.slsView
@@ -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 %}
113
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, []) %}
137
14-{% set size = agent.size || 'small' %}
15-{% set profile = salt['pillar.get']('cloud.profiles_' + size, []) %}
16-
17-{{agent.name}}:
8 +{{hub.name}}:
189 cloud.present:
1910 - script: bootstrap-salt
2011 - script_args: -P git v2017.7.2
2112 {% for key, value in profile.items() %}
@@ -24,12 +15,11 @@
2415 - minion:
2516 grains:
2617 env: production
2718 roles:
28- - salt
29- {% for role in roles_by_service[agent.service] %}
30- - {{ role }}
31- {% endfor %}
19 + - minion
20 + - hub
21 + - pub
3222
3323 {% endif %}
3424
3525 {% endfor %}
salt/state/top.slsView
@@ -1,7 +1,18 @@
11 base:
2 + '*':
3 + - docker
24 'roles:master':
35 - match: grain
46 - salt.master
7 + - cloud
58 'roles:minion':
69 - match: grain
710 - salt.minion
11 +{#
12 + 'roles:hub'
13 + - match: grain
14 + - hub
15 + 'roles:pub'
16 + - match: grain
17 + - pub
18 +#}
salt/state/hub.slsView
salt/state/pub.slsView
@@ -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