salt/state/pub.slsView |
---|
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 | 1 … | ahdinosaur/ssb-pub: |
28 | 2 … | docker_image.present |
29 | 3 … | |
30 | 4 … | ahdinosaur/healer: |
35 | 9 … | - image: ahdinosaur/healer |
36 | 10 … | - require: |
37 | 11 … | - docker_image: ahdinosaur/healer |
38 | 12 … | |
| 13 … | +{% set seeds = salt['grains.get']('pub.seeds', []) %} |
39 | 14 … | {% set pubs = salt['grains.get']('pub.list', []) %} |
40 | 15 … | {% for pub in pubs %} |
41 | 16 … | |
42 | 17 … | {% set name = pub.name %} |
| 18 … | +{% set port = pub.port or 8008 %} |
43 | 19 … | |
44 | | -/root/bots/{{name}} |
45 | | - file.directory |
| 20 … | +{% set secret = pub.secret %} |
| 21 … | +{% set curve = secret.curve %} |
| 22 … | +{% set public = secret.public %} |
| 23 … | +{% set private = secret.private %} |
46 | 24 … | |
47 | | -/root/bots/{{name}}/secret |
| 25 … | +{{ name }}/: |
| 26 … | + file.directory: |
| 27 … | + - name: /root/bots/{{ name }}/ |
| 28 … | + - mode: 755 |
| 29 … | + - user: debian |
| 30 … | + - group: debian |
| 31 … | + - recurse: |
| 32 … | + - user |
| 33 … | + - group |
|
| 34 … | + |
| 35 … | +{{ name }}/secret: |
48 | 36 … | file.managed: |
49 | | - - mode: |
| 37 … | + - name: /root/bots/{{ name }}/secret |
| 38 … | + - dataset: |
| 39 … | + curve: {{ curve }} |
| 40 … | + public: {{ public }}.{{ curve }} |
| 41 … | + private: {{ private }}.{{ curve }} |
| 42 … | + id: @{{ public }}.{{ curve }} |
| 43 … | + - mode: 0400 |
| 44 … | + - user: debian |
| 45 … | + - group: debian |
| 46 … | + - formatter: json |
| 47 … | + - merge_if_exists: True |
50 | 48 … | - require: |
51 | | - - file: /root/bots/{{name}} |
| 49 … | + - file: {{ name }}/ |
52 | 50 … | |
53 | | -/root/bots/{{name}}/gossip.json |
54 | | - file.managed: |
| 51 … | +{{ name }}/config: |
| 52 … | + file.serialize: |
| 53 … | + - name: /root/bots/{{ name }}/config |
| 54 … | + - dataset: |
| 55 … | + seeds: |
| 56 … | + - net:{{ name }}:{{ port }}~shs:{{ public }} |
| 57 … | + {% for seed in seeds %} |
| 58 … | + - {{ seed }} |
| 59 … | + {% endfor %} |
| 60 … | + - formatter: json |
| 61 … | + - mode: 644 |
| 62 … | + - user: debian |
| 63 … | + - group: debian |
| 64 … | + - merge_if_exists: True |
55 | 65 … | - require: |
56 | | - - file: /root/bots/{{name}} |
| 66 … | + - file: {{ name }}/ |
57 | 67 … | |
58 | | -{{name}}: |
| 68 … | +{{ name }}: |
59 | 69 … | docker_container.running: |
60 | 70 … | - image: ahdinosaur/ssb-pub |
61 | 71 … | - env: |
62 | | - - ssb_host: {{name}} |
| 72 … | + - ssb_host: {{ name }} |
63 | 73 … | - binds: |
64 | | - - /root/bots/{{name}}:/home/node/.ssb/ |
| 74 … | + - /root/bots/{{ name }}:/home/node/.ssb/ |
65 | 75 … | - ports: |
66 | 76 … | - 8008 |
67 | 77 … | - restart_policy: unless-stopped |
68 | 78 … | - require: |
69 | 79 … | - docker_image: ahdinosaur/ssb-pub |
70 | | - - file: /root/bots/{{name}}/secret |
71 | | - - file: /root/bots/{{name}}/gossip.json |
| 80 … | + - file: {{ name }}/secret |
| 81 … | + - file: {{ name }}/config |
72 | 82 … | |
73 | 83 … | {% endfor %} |