Added radarr and restore states

This commit is contained in:
Beth Parker 2017-08-21 20:30:49 +00:00
parent 51a7806ef3
commit aa106b5d52
19 changed files with 96 additions and 4 deletions

View file

@ -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 -%}

0
pillars/roles/backup/none.sls Executable file
View file

View file

@ -0,0 +1,9 @@
backup:
radarr:
location: /var/lib/radarr
user: radarr
group: radarr
fmode: 644
dmode: 755
services:
- radarr

View file

@ -5,3 +5,4 @@ include:
- roles.aurpkgs
- roles.mount
- roles.git
- roles.backup

View file

@ -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

1
states/backups Symbolic link
View file

@ -0,0 +1 @@
/mnt/backups

View file

@ -1 +0,0 @@
/root/scripts/mirrors.jinja

1
states/mirrors.jinja Symbolic link
View file

@ -0,0 +1 @@
/root/scripts/mirrors.jinja

View file

@ -1 +0,0 @@
/root/scripts/mirrors.list

1
states/mirrors.list Symbolic link
View file

@ -0,0 +1 @@
/root/scripts/mirrors.list

View file

@ -1 +0,0 @@
../pillars/

1
states/pillars Symbolic link
View file

@ -0,0 +1 @@
../pillars/

38
states/restore/init.sls Normal file
View file

@ -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 %}

View file

@ -1 +0,0 @@
/etc/letsencrypt/live/

View file

@ -0,0 +1 @@
/etc/letsencrypt/live/

View file

@ -1 +0,0 @@
/etc/letsencrypt/live/

View file

@ -0,0 +1 @@
/etc/letsencrypt/live/

View file

@ -1 +0,0 @@
/etc/letsencrypt/live/

View file

@ -0,0 +1 @@
/etc/letsencrypt/live/

View file

@ -0,0 +1,8 @@
#package is in aur repo
radarr:
pkg.installed
radarr_service:
service.running:
- name: radarr
- enable: true

View file

@ -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.

View file

@ -1 +0,0 @@
/secure

1
states/secure Symbolic link
View file

@ -0,0 +1 @@
/secure

View file

@ -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 %}

View file

@ -1 +0,0 @@
/keys/git/

View file

@ -0,0 +1 @@
/keys/git/

View file

@ -1 +0,0 @@
/keys/mount/

View file

@ -0,0 +1 @@
/keys/mount/