1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_restic_archiver.git synced 2024-08-16 10:09:49 +02:00

Cleanup linting and prepare update

This commit is contained in:
L3D 2023-10-22 20:33:44 +02:00
parent 0c96ce2b90
commit 95d21b7d28
No known key found for this signature in database
GPG key ID: AD65B920933B4B20
16 changed files with 163 additions and 177 deletions

View file

@ -2,21 +2,21 @@
name: Ansible Lint check name: Ansible Lint check
# yamllint disable-line rule:truthy # yamllint disable-line rule:truthy
on: on: [push, pull_request]
push:
branches: '*'
pull_request:
branches: '*'
jobs: jobs:
build: build:
name: Ansible Lint
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - name: 'checkout git repo'
uses: actions/checkout@v4
- name: Lint Ansible Playbook
uses: ansible/ansible-lint-action@v6
with: with:
targets: "." submodules: true
fetch-depth: 0
- name: Run ansible-lint
uses: ansible-actions/ansible-lint-action@v1.0.1
with:
target: "./"

View file

@ -1,20 +1,24 @@
--- ---
name: Galaxy release name: Galaxy-NG Roles Import
# yamllint disable-line rule:truthy # yamllint disable-line rule:truthy
on: on:
push:
branches: ['main']
release: release:
types: ['created'] types: ['created']
jobs: jobs:
build: build:
name: Galaxy Role Importer
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: checkout - name: 'Checkout git repo'
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: galaxy with:
uses: robertdebock/galaxy-action@1.2.1 submodules: true
fetch-depth: 0
- name: 'Release on galaxy'
uses: ansible-actions/ansible-galaxy-action@v1.0.1
with: with:
galaxy_api_key: ${{ secrets.galaxy_api_key }} galaxy_api_key: ${{ secrets.galaxy_api_key }}

View file

@ -1,22 +0,0 @@
---
name: 'Yamllint GitHub Actions'
# yamllint disable-line rule:truthy
on:
push:
branches: '*'
pull_request:
branches: '*'
jobs:
yamllint:
name: 'Yamllint'
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v3
- name: 'Yamllint'
uses: karancode/yamllint-github-action@master
with:
yamllint_file_or_dir: '.'
yamllint_config_filepath: './.yamllint'

View file

@ -1,17 +1,17 @@
--- ---
- name: systemctl daemon-reload - name: Run systemctl daemon-reload
become: true become: true
ansible.builtin.systemd: ansible.builtin.systemd:
daemon_reload: true daemon_reload: true
- name: systemctl start restic-archiver.timer - name: Run systemctl start restic-archiver.timer
become: true become: true
ansible.builtin.systemd: ansible.builtin.systemd:
name: restic-archiver.timer name: restic-archiver.timer
enabled: true enabled: true
state: started state: started
- name: systemctl enable restic-archiver.service - name: Run systemctl enable restic-archiver.service
become: true become: true
ansible.builtin.systemd: ansible.builtin.systemd:
name: restic-archiver.service name: restic-archiver.service

View file

@ -1,18 +1,19 @@
--- ---
galaxy_info: galaxy_info:
role_name: restic_archiver role_name: restic_archiver
author: L3D author: do1jlr
namespace: do1jlr namespace: l3d
description: Role to deploy restic and setup backups. description: Role to deploy restic and setup backups.
license: MIT license: MIT
min_ansible_version: 2.11 min_ansible_version: "2.13"
platforms: platforms:
- name: Debian - name: Debian
versions: all versions: ['all']
galaxy_tags: galaxy_tags:
- backup - backup
- archive - archive
- delete - delete
- restic - restic
- linux
dependencies: [] dependencies: []

View file

@ -1,17 +1,17 @@
--- ---
- name: install cron - name: Install cron
become: true become: true
ansible.builtin.package: ansible.builtin.package:
name: "{{ restic_archiver__package }}" name: "{{ restic_archiver__package }}"
state: present state: present
- name: migrate cronjob to cron.d directory - name: Migrate cronjob to cron.d directory
become: true become: true
ansible.builtin.cron: ansible.builtin.cron:
name: "archive restic backup with ansible_role_restic_archiver" name: "archive restic backup with ansible_role_restic_archiver"
state: absent state: absent
- name: setup cronjob for restic with logging - name: Setup cronjob for restic with logging
become: true become: true
ansible.builtin.cron: ansible.builtin.cron:
name: "archive restic backup with ansible_role_restic_archiver" name: "archive restic backup with ansible_role_restic_archiver"
@ -22,7 +22,7 @@
user: "{{ restic_archiver__owner }}" user: "{{ restic_archiver__owner }}"
when: restic_archiver__log_output when: restic_archiver__log_output
- name: setup cronjob for restic without logging - name: Setup cronjob for restic without logging
become: true become: true
ansible.builtin.cron: ansible.builtin.cron:
name: "archive restic backup with ansible_role_restic_archiver" name: "archive restic backup with ansible_role_restic_archiver"

View file

@ -1,7 +1,5 @@
--- ---
# tasks file for skeleton - name: Reformat dict if necessary
- name: reformat dict if necessary
ansible.builtin.set_fact: ansible.builtin.set_fact:
restic_archiver__backups: "{{ restic_archiver__backups | dict2items | json_query('[*].value') }}" restic_archiver__backups: "{{ restic_archiver__backups | dict2items | json_query('[*].value') }}"
when: when:

View file

@ -1,5 +1,5 @@
--- ---
- name: create /var/log/restic/ - name: Create /var/log/restic/
become: true become: true
ansible.builtin.file: ansible.builtin.file:
path: /var/log/restic path: /var/log/restic
@ -9,14 +9,14 @@
owner: "{{ restic_archiver__group }}" owner: "{{ restic_archiver__group }}"
mode: 0750 mode: 0750
- name: install logrotate - name: Install logrotate
become: true become: true
ansible.builtin.package: ansible.builtin.package:
name: logrotate name: logrotate
state: present state: present
when: restic_archiver__logrotate | bool when: restic_archiver__logrotate | bool
- name: create logrotate config - name: Create logrotate config
become: true become: true
ansible.builtin.copy: ansible.builtin.copy:
src: files/logrotate.conf src: files/logrotate.conf

View file

@ -1,5 +1,5 @@
--- ---
- name: install requirements - name: Install requirements
become: true become: true
ansible.builtin.package: ansible.builtin.package:
name: name:

View file

@ -1,9 +1,9 @@
--- ---
- name: run optional versionscheck - name: Run optional versionscheck
ansible.builtin.include_tasks: versioncheck.yml ansible.builtin.include_tasks: versioncheck.yml
when: submodules_versioncheck | bool when: submodules_versioncheck | bool
- name: deploy restic template - name: Deploy restic template
ansible.builtin.template: ansible.builtin.template:
src: templates/restic_forget_snapshots.j2 src: templates/restic_forget_snapshots.j2
dest: /opt/restic-backup.sh dest: /opt/restic-backup.sh
@ -12,18 +12,18 @@
mode: 0700 mode: 0700
become: true become: true
- name: setup logrotate - name: Setup logrotate
ansible.builtin.include_tasks: logs.yml ansible.builtin.include_tasks: logs.yml
when: restic_archiver__log_output | bool when: restic_archiver__log_output | bool
- name: create cronjob - name: Create cronjob
ansible.builtin.include_tasks: cron.yml ansible.builtin.include_tasks: cron.yml
when: not restic_archiver__use_systemd_timer | bool when: not restic_archiver__use_systemd_timer | bool
- name: create systemd timer - name: Create systemd timer
ansible.builtin.include_tasks: systemd.yml ansible.builtin.include_tasks: systemd.yml
when: restic_archiver__use_systemd_timer | bool when: restic_archiver__use_systemd_timer | bool
- name: install requirements for mailing - name: Install requirements for mailing
ansible.builtin.include_tasks: mail.yml ansible.builtin.include_tasks: mail.yml
when: restic_archiver__mailsummary | bool when: restic_archiver__mailsummary | bool

View file

@ -1,5 +1,5 @@
--- ---
- name: create restic-archiver.service - name: Create restic-archiver.service
become: true become: true
ansible.builtin.template: ansible.builtin.template:
src: templates/restic-archiver.service.j2 src: templates/restic-archiver.service.j2
@ -8,10 +8,10 @@
owner: root owner: root
group: root group: root
notify: notify:
- systemctl daemon-reload - Run systemctl daemon-reload
- systemctl enable restic-archiver.service - Run systemctl enable restic-archiver.service
- name: create restic-archiver.timer - name: Create restic-archiver.timer
become: true become: true
ansible.builtin.template: ansible.builtin.template:
src: templates/restic-archiver.timer.j2 src: templates/restic-archiver.timer.j2
@ -20,5 +20,5 @@
owner: root owner: root
group: root group: root
notify: notify:
- systemctl daemon-reload - Run systemctl daemon-reload
- systemctl start restic-archiver.timer - Run systemctl start restic-archiver.timer

View file

@ -10,7 +10,7 @@
mode: 0755 mode: 0755
when: submodules_versioncheck | bool when: submodules_versioncheck | bool
- name: check playbook version - name: Check playbook version
become: true become: true
ansible.builtin.slurp: ansible.builtin.slurp:
src: "/etc/.ansible-version/{{ playbook_version_path }}" src: "/etc/.ansible-version/{{ playbook_version_path }}"
@ -35,10 +35,11 @@
when: when:
- playbook_version.content|default("Mgo=")|b64decode|int - 1 >= playbook_version_number|int and submodules_versioncheck | bool - playbook_version.content|default("Mgo=")|b64decode|int - 1 >= playbook_version_number|int and submodules_versioncheck | bool
- name: write new version to remote disk - name: Write new version to remote disk
become: true become: true
ansible.builtin.copy: ansible.builtin.copy:
content: "{{ playbook_version_number }}" content: "{{ playbook_version_number }}"
dest: "/etc/.ansible-version/{{ playbook_version_path }}" dest: "/etc/.ansible-version/{{ playbook_version_path }}"
mode: '0644' mode: '0644'
when: submodules_versioncheck | bool when: submodules_versioncheck | bool
tags: skip_ansible_lint_template-instead-of-copy

View file

@ -4,79 +4,83 @@
Variables are defined via defaults! Variables are defined via defaults!
#} #}
{% macro retention_pattern(repo) -%} {% macro retention_pattern(repo) %}
{% if repo.keep_last is defined and repo.keep_last != None -%} {% if repo.keep_last is defined and repo.keep_last != None %}
--keep-last {{ repo.keep_last }} --keep-last {{ repo.keep_last }} \
{%- else -%} {% else %}
--keep-last {{ restic_archiver__keep }} --keep-last {{ restic_archiver__keep }} \
{%- endif %} \ {% endif %}
{% if repo.keep_hourly is defined and repo.keep_hourly != None -%} {% if repo.keep_hourly is defined and repo.keep_hourly != None %}
--keep-hourly {{ repo.keep_hourly }} --keep-hourly {{ repo.keep_hourly }} \
{%- else -%} {% else %}
--keep-hourly {{ restic_archiver__keep_hourly }} --keep-hourly {{ restic_archiver__keep_hourly }} \
{%- endif %} \ {% endif %}
{% if repo.keep_daily is defined and repo.keep_daily != None -%} {% if repo.keep_daily is defined and repo.keep_daily != None %}
--keep-daily {{ repo.keep_daily }} --keep-daily {{ repo.keep_daily }} \
{%- else -%} {% else %}
--keep-daily {{ restic_archiver__keep_daily }} --keep-daily {{ restic_archiver__keep_daily }} \
{%- endif %} \ {% endif %}
{% if repo.keep_weekly is defined and repo.keep_weekly != None -%} {% if repo.keep_weekly is defined and repo.keep_weekly != None %}
--keep-weekly {{ repo.keep_weekly }} --keep-weekly {{ repo.keep_weekly }} \
{%- else -%} {% else %}
--keep-weekly {{ restic_archiver__keep_weekly }} --keep-weekly {{ restic_archiver__keep_weekly }} \
{%- endif %} \ {% endif %}
{% if repo.keep_monthly is defined and repo.keep_monthly != None -%} {% if repo.keep_monthly is defined and repo.keep_monthly != None %}
--keep-monthly {{ repo.keep_monthly }} --keep-monthly {{ repo.keep_monthly }} \
{%- else -%} {% else %}
--keep-monthly {{ restic_archiver__keep_monthly }} --keep-monthly {{ restic_archiver__keep_monthly }} \
{%- endif %} \ {% endif %}
{% if repo.keep_yearly is defined and repo.keep_yearly != None -%} {% if repo.keep_yearly is defined and repo.keep_yearly != None %}
--keep-yearly {{ repo.keep_yearly }} --keep-yearly {{ repo.keep_yearly }} \
{%- else -%} {% else %}
--keep-yearly {{ restic_archiver__keep_yearly }} --keep-yearly {{ restic_archiver__keep_yearly }} \
{%- endif -%} {% endif %}
{% if repo.keep_within is defined and repo.keep_within != None %} \ {% if repo.keep_within is defined and repo.keep_within != None %}
--keep-within {{ repo.keep_within }} {% endif -%} --keep-within {{ repo.keep_within }} \
{%- if repo.prune|default(restic_archiver__prune) %} \ {% endif %}
--prune {% endif %} {% if repo.prune | default(restic_archiver__prune) %}
{%- endmacro %} --prune
{% endif %}
{% endmacro %}
{% macro retention_archive_pattern(repo) -%} {% macro retention_archive_pattern(repo) %}
{% if repo.keep_last is defined and repo.archive_keep_last != None -%} {% if repo.keep_last is defined and repo.archive_keep_last != None %}
--keep-last {{ repo.archive_keep_last }} --keep-last {{ repo.archive_keep_last }} \
{%- else -%} {% else %}
--keep-last {{ restic_archiver__archive_keep }} --keep-last {{ restic_archiver__archive_keep }} \
{%- endif %} \ {% endif %}
{% if repo.keep_hourly is defined and repo.archive_keep_hourly != None -%} {% if repo.keep_hourly is defined and repo.archive_keep_hourly != None %}
--keep-hourly {{ repo.archive_keep_hourly }} --keep-hourly {{ repo.archive_keep_hourly }} \
{%- else -%} {% else %}
--keep-hourly {{ restic_archiver__archive_keep_hourly }} --keep-hourly {{ restic_archiver__archive_keep_hourly }} \
{%- endif %} \ {% endif %}
{% if repo.keep_daily is defined and repo.archive_keep_daily != None -%} {% if repo.keep_daily is defined and repo.archive_keep_daily != None %}
--keep-daily {{ repo.archive_keep_daily }} --keep-daily {{ repo.archive_keep_daily }} \
{%- else -%} {% else %}
--keep-daily {{ restic_archiver__archive_keep_daily }} --keep-daily {{ restic_archiver__archive_keep_daily }} \
{%- endif %} \ {% endif %}
{% if repo.keep_weekly is defined and repo.archive_keep_weekly != None -%} {% if repo.keep_weekly is defined and repo.archive_keep_weekly != None %}
--keep-weekly {{ repo.archive_keep_weekly }} --keep-weekly {{ repo.archive_keep_weekly }} \
{%- else -%} {% else %}
--keep-weekly {{ restic_archiver__archive_keep_weekly }} --keep-weekly {{ restic_archiver__archive_keep_weekly }} \
{%- endif %} \ {% endif %}
{% if repo.keep_monthly is defined and repo.archive_keep_monthly != None -%} {% if repo.keep_monthly is defined and repo.archive_keep_monthly != None %}
--keep-monthly {{ repo.archive_keep_monthly }} --keep-monthly {{ repo.archive_keep_monthly }} \
{%- else -%} {% else %}
--keep-monthly {{ restic_archiver__archive_keep_monthly }} --keep-monthly {{ restic_archiver__archive_keep_monthly }}
{%- endif %} \ {% endif %}
{% if repo.keep_yearly is defined and repo.archive_keep_yearly != None -%} {% if repo.keep_yearly is defined and repo.archive_keep_yearly != None %}
--keep-yearly {{ repo.archive_keep_yearly }} --keep-yearly {{ repo.archive_keep_yearly }}
{%- else -%} {% else %}
--keep-yearly {{ restic_archiver__archive_keep_yearly }} --keep-yearly {{ restic_archiver__archive_keep_yearly }}
{%- endif -%} {% endif %}
{% if repo.keep_within is defined and repo.archive_keep_within != None %} \ {% if repo.keep_within is defined and repo.archive_keep_within != None %} \
--keep-within {{ repo.archive_keep_within }} {% endif -%} --keep-within {{ repo.archive_keep_within }}
{%- if repo.prune|default(restic_archiver__prune) %} \ {% endif %}
--prune {% endif %} {% if repo.prune | default(restic_archiver__prune) %}
{%- endmacro %} --prune
{% endif %}
{% endmacro %}
{# {#

View file

@ -6,6 +6,6 @@ Documentation=https://github.com/roles-ansible/ansible_role_restic_archiver.git
Type=oneshot Type=oneshot
ExecStart=/opt/restic-backup.sh ExecStart=/opt/restic-backup.sh
TimeoutStartSec=0 TimeoutStartSec=0
{% if restic_archiver__log_output -%} {% if restic_archiver__log_output %}
StandardOutput=append:/var/log/restic/restic_archiver.log StandardOutput=append:/var/log/restic/restic_archiver.log
{%- endif -%} {% endif %}

View file

@ -1,3 +1,3 @@
--- ---
playbook_version_number: 54 # should be int playbook_version_number: 55 # should be int
playbook_version_path: 'role-restic_archiver_roles-ansible_github.com.version' playbook_version_path: 'role-restic_archiver_roles-ansible_github.com.version'