git ssb

1+

dinoworm 🐛 / butt-as-a-service



Commit c665bf96bb285a6f2c440671a555577192e263dc

make a mess

Michael Williams committed on 12/23/2017, 11:43:02 AM
Parent: 1f985742f731df43e79685fdfd3fd08824f86588

Files changed

INSTALL.mdchanged
example/salt/pillar/agents.slschanged
example/salt/pillar/cloud.slschanged
example/salt/pillar/base.slsadded
salt/state/cloud.slsadded
salt/state/masteradded
salt/state/master.slsadded
salt/state/minionadded
salt/state/minion.slsadded
salt/state/salt.slsadded
salt/state/top.slsadded
INSTALL.mdView
@@ -17,36 +17,42 @@
1717 ```
1818
1919 ---
2020
21 +generate ssh key
22 +
23 +```shell
24 +ssh-keygen -t rsa -b 8192
25 +```
26 +
27 +upload to GitHub (or git provider): https://github.com/settings/keys
28 +
29 +---
30 +
2131 update master config
2232
2333 ```shell
24-ssh-keygen -t rsa -b 8192
2534 nano /etc/salt/master
2635 ```
2736
28-```
37 +```yaml
2938 fileserver_backend:
3039 - git
31-gitfs_remotes:
32- - git@github.com:ahdinosaur/butt-as-a-service
40 +
3341 gitfs_privkey: /root/.ssh/id_rsa
3442 gitfs_pubkey: /root/.ssh/id_rsa.pub
35-gitfs_root: salt/state
43 +gitfs_remotes:
44 + - git@github.com:ahdinosaur/butt-as-a-service:
45 + - root: salt/state
3646
47 +ext_pillar_privkey: /root/.ssh/id_rsa
48 +ext_pillar_pubkey: /root/.ssh/id_rsa.pub
3749 ext_pillar:
3850 - git:
3951 - master git@github.com:${user}/${repo}:
4052 - root: salt/pillar
41- - privkey: /root/.ssh/id_rsa
42- - pubkey: /root/.ssh/id_rsa.pub
4353 ```
4454
45-```yml
46-master: 127.0.0.1
47-```
48-
4955 ---
5056
5157 update minion config
5258
example/salt/pillar/agents.slsView
@@ -1,7 +1,4 @@
11 agents:
2- - type: person
3- name: Mikey
42 - type: bot
5- name: ${name}
6- url: ${url}
7- cloud_profile: ssb-pub
3 + name: salt.butt.nz
4 + service: pub
example/salt/pillar/cloud.slsView
@@ -1,9 +1,20 @@
11 cloud:
2 + ssh_key_name: salt
3 + ssh_key_file: /root/.ssh/id_rsa
4 +
25 minion:
36 master: salt.butt.nz
47
58 providers:
6- scaleway_butt:
7- access_key: ${access_key}
8- token: ${token}
9 + scaleway:
910 driver: scaleway
11 + access_key: 26e74568-4f7e-4e40-bd97-7717b9909319
12 + token: ba41a1d2-a0c2-4590-af5c-4fa80ce078b0
13 + key_filename: /root/.ssh/id_rsa
14 +
15 + profiles:
16 + scaleway_small:
17 + image: Debian Stretch (9.0)
18 + location: par1
19 + commercial_type: VC1S
20 + enable_ipv6: True
example/salt/pillar/base.slsView
@@ -1,0 +1,5 @@
1 +master: salt.butt.nz
2 +git_pubkey: /root/.ssh/id_rsa
3 +git_privkey: /root/.ssh/id_rsa.pub
4 +pillar_git: git@github.com:ahdinosaur/salt.butt.nz
5 +state_git: git@github.com:ahdinosaur/butt-as-a-service
salt/state/cloud.slsView
@@ -1,0 +1,35 @@
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 %}
11 +
12 +{% if agent.type == 'bot' %}
13 +
14 +{% set size = agent.size || 'small' %}
15 +{% set profile = salt['pillar.get']('cloud.profiles_' + size, []) %}
16 +
17 +{{agent.name}}:
18 + cloud.present:
19 + - script: bootstrap-salt
20 + - script_args: -P git v2017.7.2
21 + {% for key, value in profile.items() %}
22 + - {{ key }}: {{ value }}
23 + {% endfor %}
24 + - minion:
25 + grains:
26 + env: production
27 + roles:
28 + - salt
29 + {% for role in roles_by_service[agent.service] %}
30 + - {{ role }}
31 + {% endfor %}
32 +
33 +{% endif %}
34 +
35 +{% endfor %}
salt/state/masterView
@@ -1,0 +1,15 @@
1 +fileserver_backend:
2 + - git
3 +
4 +gitfs_privkey: {{ pillar['git_privkey'] }}
5 +gitfs_pubkey: {{ pillar['git_pubkey'] }}
6 +gitfs_remotes:
7 + - {{ pillar['state_git'] }}:
8 + - root: salt/state
9 +
10 +gitfs_privkey: {{ pillar['git_privkey'] }}
11 +gitfs_pubkey: {{ pillar['git_pubkey'] }}
12 +ext_pillar:
13 + - git:
14 + - master {{pillar_git}:
15 + - root: salt/pillar
salt/state/master.slsView
salt/state/minionView
salt/state/minion.slsView
salt/state/salt.slsView
@@ -1,0 +1,22 @@
1 +{% set roles = salt['grains.get']('roles', []) %}
2 +{% if 'salt' in roles %}
3 +
4 +{% for salt in ['master', 'minion'] %}
5 +{% if salt in roles %}
6 +
7 +/etc/salt/{{salt}}:
8 + file.managed:
9 + - source: salt://{{salt}}
10 + - user: root
11 + - group: root
12 + - mode: 644
13 + - template: jinja
14 + - defaults:
15 + git_pubkey: /root/.ssh/id_rsa
16 + git_privkey: /root/.ssh/id_rsa.pub
17 + state_git: git@github.com:ahdinosaur/butt-as-a-service
18 +
19 +{% endif %}
20 +{% endfor %}
21 +
22 +{% endif %}
salt/state/top.slsView
@@ -1,0 +1,8 @@
1 +{% for role in salt['grains.get']('roles', []) %}
2 +{% if role %}
3 + 'role:{{ role }}':
4 + - match: grain
5 + - {{ role }}
6 +
7 +{% endif %}
8 +{% endfor %}

Built with git-ssb-web