manage restic rsa

This commit is contained in:
Keiran Snowden
2023-11-27 01:42:37 -05:00
parent c1a5c8d95b
commit 5be2a914ac
8 changed files with 63 additions and 28 deletions

View File

@@ -1,3 +1,4 @@
# Managed by Saltstack
{% for comment, key in salt.pillar.get('authorized_keys')[user].items() -%}
{{ key }} {{ comment }}
{% endfor -%}

View File

@@ -1,5 +1,7 @@
# If not running interactively, don't do anything
{# code: lang=jinja-shell -#}
# vim: et:ai:ts=4:sw=4:ft=sh
case $- in
*i*) ;;
*) return;;
@@ -25,19 +27,13 @@ shopt -s checkwinsize
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias vi='vim'
export EDITOR='vim'
export VISUAL='vim'
@@ -64,8 +60,7 @@ PATH="${PATH}:${HOME}/.local/bin"
alias random='< /dev/urandom tr -dc A-Za-z0-9 | head -c${1:-32};echo'
{%- if bashrc_user is defined %}
{%- if bashrc_user == 'root' and salt.pillar.get('restic:client', None) is not none %}
export RESTIC_REPOSITORY={{ salt.pillar.get('restic:client:repo') }}
export RESTIC_PASSWORD={{ salt.pillar.get('restic:client:pass') }}
source /opt/restic/env.sh
{%- endif %}
{%- for alias, cmd_str in salt.pillar.get("bash_aliases:{}".format(bashrc_user), {}).items() %}
alias {{ alias }}="{{ cmd_str }}"

View File

@@ -1,6 +1,15 @@
{% for host, config in salt.pillar.get('ssh_hosts')[user].items() -%}
# Managed by Saltstack
{%- for host, config in salt.pillar.get('ssh_hosts', {}).get(user, {}).items() %}
Host {{ host }}
{%- for key, val in config %}
{%- for key, val in config.items() %}
{{ key }} {{ val }}
{%- endfor %}
{%- endfor %}
{%- if salt.pillar.get('restic:client:environ:RESTIC_REPOSITORY', '').startswith('sftp:') %}
{% set user=salt.pillar.get('restic:client:environ:RESTIC_REPOSITORY').split(':')[1] %}
Host {{ user }}
HostName kpi.keiran.us
User {{ user }}
Port 9022
IdentityFile /root/.ssh/id_rsa
{%- endif %}