29 lines
1.4 KiB
YAML
29 lines
1.4 KiB
YAML
---
|
|
- hosts: backup01.srv.local
|
|
vars:
|
|
user: backup
|
|
group: backup
|
|
home: /home/backup
|
|
pool: "{{ home }}/repos"
|
|
auth_users:
|
|
- host: johndoe.clnt.local
|
|
key: "{{ lookup('file', '/path/to/keys/johndoe.clnt.local.pub') }}"
|
|
- host: web01.clnt.local
|
|
key: "{{ lookup('file', '/path/to/keys/web01.clnt.local.pub') }}"
|
|
- host: app01.clnt.local
|
|
key: "{{ lookup('file', '/path/to/keys/app01.clnt.local.pub') }}"
|
|
tasks:
|
|
- package: name=borg state=present
|
|
- group: name="{{ group }}" state=present
|
|
- user: name="{{ user }}" shell=/bin/bash home="{{ home }}" createhome=yes group="{{ group }}" groups= state=present
|
|
- file: path="{{ home }}" owner="{{ user }}" group="{{ group }}" mode=0700 state=directory
|
|
- file: path="{{ home }}/.ssh" owner="{{ user }}" group="{{ group }}" mode=0700 state=directory
|
|
- file: path="{{ pool }}" owner="{{ user }}" group="{{ group }}" mode=0700 state=directory
|
|
- authorized_key: user="{{ user }}"
|
|
key="{{ item.key }}"
|
|
key_options='command="cd {{ pool }}/{{ item.host }};borg serve --restrict-to-path {{ pool }}/{{ item.host }}",restrict'
|
|
with_items: "{{ auth_users }}"
|
|
- file: path="{{ home }}/.ssh/authorized_keys" owner="{{ user }}" group="{{ group }}" mode=0600 state=file
|
|
- file: path="{{ pool }}/{{ item.host }}" owner="{{ user }}" group="{{ group }}" mode=0700 state=directory
|
|
with_items: "{{ auth_users }}"
|