diff --git a/pillars/roles/backup/init.sls b/pillars/roles/backup/init.sls new file mode 100644 index 0000000..d00a1ed --- /dev/null +++ b/pillars/roles/backup/init.sls @@ -0,0 +1,21 @@ +{% set states = salt['cp.list_states'](saltenv) %} +include: + - roles.backup.none +{%- if grains['roles'] is defined -%} + {%- if grains['roles'] is not none -%} + {%- if 'portal' in grains['roles'] -%} + {%- for state in states %} + {%- if state.startswith("pillars.roles.backup.") -%} + {%- set role = state.split('.')[3] %} + - roles.backup.{{ role }} + {%- endif -%} + {%- endfor -%} + {%- else -%} + {%- for role in grains['roles'] %} + {%- if 'pillars.roles.backup.'+role in states %} + - roles.backup.{{ role }} + {%- endif -%} + {%- endfor -%} + {%- endif -%} + {%- endif -%} +{%- endif -%} diff --git a/pillars/roles/backup/none.sls b/pillars/roles/backup/none.sls new file mode 100755 index 0000000..e69de29 diff --git a/pillars/roles/backup/radarr.sls b/pillars/roles/backup/radarr.sls new file mode 100644 index 0000000..9f9c6fb --- /dev/null +++ b/pillars/roles/backup/radarr.sls @@ -0,0 +1,9 @@ +backup: + radarr: + location: /var/lib/radarr + user: radarr + group: radarr + fmode: 644 + dmode: 755 + services: + - radarr diff --git a/pillars/roles/init.sls b/pillars/roles/init.sls index aabab46..ebe1dd8 100644 --- a/pillars/roles/init.sls +++ b/pillars/roles/init.sls @@ -5,3 +5,4 @@ include: - roles.aurpkgs - roles.mount - roles.git + - roles.backup diff --git a/pillars/roles/mount/saltmaster.sls b/pillars/roles/mount/saltmaster.sls index 72c26c9..bb83aa5 100644 --- a/pillars/roles/mount/saltmaster.sls +++ b/pillars/roles/mount/saltmaster.sls @@ -1,6 +1,10 @@ mount: sshfs: - /mnt: + /srv/salt: host: host.actcur.com directory: /mnt/butter/salt - user: mount + user: salt + /mnt/backups: + host: host.actcur.com + directory: /mnt/butter/backups/configurations + user: backups diff --git a/states/backups b/states/backups new file mode 120000 index 0000000..8652e72 --- /dev/null +++ b/states/backups @@ -0,0 +1 @@ +/mnt/backups \ No newline at end of file diff --git a/states/mirrors.jinja b/states/mirrors.jinja deleted file mode 100644 index 36d40c7..0000000 --- a/states/mirrors.jinja +++ /dev/null @@ -1 +0,0 @@ -/root/scripts/mirrors.jinja \ No newline at end of file diff --git a/states/mirrors.jinja b/states/mirrors.jinja new file mode 120000 index 0000000..36d40c7 --- /dev/null +++ b/states/mirrors.jinja @@ -0,0 +1 @@ +/root/scripts/mirrors.jinja \ No newline at end of file diff --git a/states/mirrors.list b/states/mirrors.list deleted file mode 100644 index acd640b..0000000 --- a/states/mirrors.list +++ /dev/null @@ -1 +0,0 @@ -/root/scripts/mirrors.list \ No newline at end of file diff --git a/states/mirrors.list b/states/mirrors.list new file mode 120000 index 0000000..acd640b --- /dev/null +++ b/states/mirrors.list @@ -0,0 +1 @@ +/root/scripts/mirrors.list \ No newline at end of file diff --git a/states/pillars b/states/pillars deleted file mode 100644 index 27c0754..0000000 --- a/states/pillars +++ /dev/null @@ -1 +0,0 @@ -../pillars/ \ No newline at end of file diff --git a/states/pillars b/states/pillars new file mode 120000 index 0000000..27c0754 --- /dev/null +++ b/states/pillars @@ -0,0 +1 @@ +../pillars/ \ No newline at end of file diff --git a/states/restore/init.sls b/states/restore/init.sls new file mode 100644 index 0000000..81bc4c5 --- /dev/null +++ b/states/restore/init.sls @@ -0,0 +1,38 @@ +{##ensure that backup pillar exists##} +{%- if pillar['backup'] is defined -%} + + {##restore directories from backup##} + {%- for name in pillar['backup'] %} + {%- if pillar['backup'][name]['location'] is defined %} + #handle restoring radarr backup folder +{{ pillar['backup'][name]['location'] }}: + file.recurse: + - source: salt://backups/{{ name }}/latest + {%- if pillar['backup'][name]['user'] is defined %} + - user: {{ pillar['backup'][name]['user'] }} + {%- endif -%} + {%- if pillar['backup'][name]['group'] is defined %} + - group: {{ pillar['backup'][name]['group'] }} + {%- endif -%} + {%- if pillar['backup'][name]['fmode'] is defined %} + - file_mode: {{ pillar['backup'][name]['fmode'] }} + {%- endif -%} + {%- if pillar['backup'][name]['dmode'] is defined %} + - dir_mode: {{ pillar['backup'][name]['dmode'] }} + {%- endif %} + - clean: true + - include_empty: true + - keep_symlinks: true + - force_symlinks: true + + {%- if pillar['backup'][name]['services'] is defined %} + {%- for service in pillar['backup'][name]['services'] %} +{{ service }}: + service.running: + - watch: + - file: {{ pillar['backup'][name]['location'] }} + {%- endfor %} + {%- endif -%} + {%- endif -%} + {%- endfor %} +{%- endif %} diff --git a/states/roles/maintain/glances/certs b/states/roles/maintain/glances/certs deleted file mode 100644 index 1f4d9d6..0000000 --- a/states/roles/maintain/glances/certs +++ /dev/null @@ -1 +0,0 @@ -/etc/letsencrypt/live/ \ No newline at end of file diff --git a/states/roles/maintain/glances/certs b/states/roles/maintain/glances/certs new file mode 120000 index 0000000..1f4d9d6 --- /dev/null +++ b/states/roles/maintain/glances/certs @@ -0,0 +1 @@ +/etc/letsencrypt/live/ \ No newline at end of file diff --git a/states/roles/maintain/ldap/certs b/states/roles/maintain/ldap/certs deleted file mode 100644 index 1f4d9d6..0000000 --- a/states/roles/maintain/ldap/certs +++ /dev/null @@ -1 +0,0 @@ -/etc/letsencrypt/live/ \ No newline at end of file diff --git a/states/roles/maintain/ldap/certs b/states/roles/maintain/ldap/certs new file mode 120000 index 0000000..1f4d9d6 --- /dev/null +++ b/states/roles/maintain/ldap/certs @@ -0,0 +1 @@ +/etc/letsencrypt/live/ \ No newline at end of file diff --git a/states/roles/maintain/nginx-proxy/certs b/states/roles/maintain/nginx-proxy/certs deleted file mode 100644 index 1f4d9d6..0000000 --- a/states/roles/maintain/nginx-proxy/certs +++ /dev/null @@ -1 +0,0 @@ -/etc/letsencrypt/live/ \ No newline at end of file diff --git a/states/roles/maintain/nginx-proxy/certs b/states/roles/maintain/nginx-proxy/certs new file mode 120000 index 0000000..1f4d9d6 --- /dev/null +++ b/states/roles/maintain/nginx-proxy/certs @@ -0,0 +1 @@ +/etc/letsencrypt/live/ \ No newline at end of file diff --git a/states/roles/maintain/radarr/init.sls b/states/roles/maintain/radarr/init.sls new file mode 100755 index 0000000..cbfc8c1 --- /dev/null +++ b/states/roles/maintain/radarr/init.sls @@ -0,0 +1,8 @@ +#package is in aur repo +radarr: + pkg.installed + +radarr_service: + service.running: + - name: radarr + - enable: true diff --git a/states/roles/maintain/saltminion/minion b/states/roles/maintain/saltminion/minion index 6fedb22..f9d4271 100644 --- a/states/roles/maintain/saltminion/minion +++ b/states/roles/maintain/saltminion/minion @@ -1,5 +1,5 @@ ##### Primary configuration settings ##### -########################################## +########################################## # This configuration file is used to manage the behavior of the Salt Minion. # With the exception of the location of the Salt Master Server, values that are # commented out but have an empty line after the comment are defaults that need @@ -348,10 +348,11 @@ master: salt.actcur.com # by statically setting it. Remember that the recommended way to manage # environments is to isolate via the top file. {%- set env="dev" -%} -{%- if pillar['env'] is defined -%} +{%- if pillar['env'] is defined -%} {%- set env=pillar['env'] -%} {%- endif %} environment: {{ env }} +pillarenv: {{ env }} # # If using the local file directory, then the state top file name needs to be # defined, by default this is top.sls. diff --git a/states/secure b/states/secure deleted file mode 100644 index fdd2f90..0000000 --- a/states/secure +++ /dev/null @@ -1 +0,0 @@ -/secure \ No newline at end of file diff --git a/states/secure b/states/secure new file mode 120000 index 0000000..fdd2f90 --- /dev/null +++ b/states/secure @@ -0,0 +1 @@ +/secure \ No newline at end of file diff --git a/states/systems/core/git/init.sls b/states/systems/core/git/init.sls index 932d1ae..8b5f1c2 100644 --- a/states/systems/core/git/init.sls +++ b/states/systems/core/git/init.sls @@ -53,5 +53,14 @@ git_pkg: - value: {{ pillar['git'][repo]['email'] }} - repo: {{ pillar['git'][repo]['path'] }} {%- endif -%} + + {##ensure that key is defined pillar exists##} + {%- if pillar['git'][repo]['key'] is defined %} +{{ repo }}_conf_key: + git.config_set: + - name: core.sshCommand + - value: "ssh -i /root/.ssh/{{ pillar['git'][repo]['key'] }}" + - repo: {{ pillar['git'][repo]['path'] }} + {%- endif -%} {%- endfor %} {%- endif %} diff --git a/states/systems/core/git/keys b/states/systems/core/git/keys deleted file mode 100644 index 2feebc4..0000000 --- a/states/systems/core/git/keys +++ /dev/null @@ -1 +0,0 @@ -/keys/git/ \ No newline at end of file diff --git a/states/systems/core/git/keys b/states/systems/core/git/keys new file mode 120000 index 0000000..2feebc4 --- /dev/null +++ b/states/systems/core/git/keys @@ -0,0 +1 @@ +/keys/git/ \ No newline at end of file diff --git a/states/systems/core/mount/keys b/states/systems/core/mount/keys deleted file mode 100644 index e0ecba1..0000000 --- a/states/systems/core/mount/keys +++ /dev/null @@ -1 +0,0 @@ -/keys/mount/ \ No newline at end of file diff --git a/states/systems/core/mount/keys b/states/systems/core/mount/keys new file mode 120000 index 0000000..e0ecba1 --- /dev/null +++ b/states/systems/core/mount/keys @@ -0,0 +1 @@ +/keys/mount/ \ No newline at end of file