generated from sebclem/ansible-role-template
Add base
This commit is contained in:
parent
9daf8bcafb
commit
7e7a8e28a6
@ -1,2 +1,12 @@
|
||||
---
|
||||
# defaults file for ${REPO_NAME_TITLE}
|
||||
|
||||
borg_version: false
|
||||
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') }}"
|
||||
|
62
tasks/configure.yml
Normal file
62
tasks/configure.yml
Normal file
@ -0,0 +1,62 @@
|
||||
---
|
||||
- name: Create Group
|
||||
ansible.builtin.group:
|
||||
name: "{{ group }}"
|
||||
state: present
|
||||
|
||||
- name: Create user
|
||||
ansible.builtin.user:
|
||||
name: "{{ user }}"
|
||||
shell: /bin/bash
|
||||
home: "{{ home }}"
|
||||
createhome: true
|
||||
group: "{{ group }}"
|
||||
state: present
|
||||
|
||||
- name: Ensure home dir is present
|
||||
ansible.builtin.file:
|
||||
path: "{{ home }}"
|
||||
owner: "{{ user }}"
|
||||
group: "{{ group }}"
|
||||
mode: 0700
|
||||
state: directory
|
||||
|
||||
- name: Ensure ssh dir is present
|
||||
ansible.builtin.file:
|
||||
path: "{{ home }}/.ssh"
|
||||
owner: "{{ user }}"
|
||||
group: "{{ group }}"
|
||||
mode: 0700
|
||||
state: directory
|
||||
|
||||
- name: Ensure pool dir is present
|
||||
ansible.builtin.file:
|
||||
path: "{{ pool }}"
|
||||
owner: "{{ user }}"
|
||||
group: "{{ group }}"
|
||||
mode: 0700
|
||||
state: directory
|
||||
|
||||
- name: Create autorized key entry
|
||||
ansible.posix.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 }}"
|
||||
|
||||
- name: Ensure permission on authorized_keys file
|
||||
ansible.builtin.file:
|
||||
path: "{{ home }}/.ssh/authorized_keys"
|
||||
owner: "{{ user }}"
|
||||
group: "{{ group }}"
|
||||
mode: 0600
|
||||
state: file
|
||||
|
||||
- name: Ensure host pool dir is present
|
||||
ansible.builtin.file:
|
||||
path: "{{ pool }}/{{ item.host }}"
|
||||
owner: "{{ user }}"
|
||||
group: "{{ group }}"
|
||||
mode: 0700
|
||||
state: directory
|
||||
with_items: "{{ auth_users }}"
|
@ -1,2 +1,5 @@
|
||||
---
|
||||
# tasks file for Ansible-Borg-Server-Role
|
||||
- name: Install Borg
|
||||
ansible.builtin.include_tasks:
|
||||
file: preflight.yml
|
||||
|
13
tasks/preflight.yml
Normal file
13
tasks/preflight.yml
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
- name: Install dependent Python Packages
|
||||
ansible.builtin.pip:
|
||||
name: "{{ borg_dependent_python_packages }}"
|
||||
virtualenv: /opt/borgmatic
|
||||
when: borg_dependent_python_packages is defined
|
||||
|
||||
- name: Install main Python Packages
|
||||
ansible.builtin.pip:
|
||||
name: "{{ item.name }}"
|
||||
version: "{{ item.version | default(omit, true) }}"
|
||||
when: borg_python_packages is defined
|
||||
loop: "{{ borg_python_packages }}"
|
@ -1,2 +1,10 @@
|
||||
---
|
||||
# vars file for Ansible-Borg-Server-Role
|
||||
|
||||
borg_dependent_python_packages:
|
||||
- cython
|
||||
- pkgconfig
|
||||
|
||||
borg_python_packages:
|
||||
- name: borgbackup
|
||||
version: "{{ borg_version }}"
|
||||
|
Loading…
Reference in New Issue
Block a user