1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_restic.git synced 2024-12-11 23:41:32 +01:00

update linting

This commit is contained in:
L3D 2022-10-06 14:52:27 +02:00
parent 62b7b7812d
commit e3732c72c3
Signed by: l3d
GPG key ID: CD08445BFF4313D1
9 changed files with 66 additions and 37 deletions

View file

@ -0,0 +1,23 @@
---
name: Ansible Lint check
# yamllint disable-line rule:truthy
on:
push:
branches: '*'
pull_request:
branches: '*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Lint Ansible Playbook
uses: ansible/ansible-lint-action@v6
with:
targets: "."
args: ""

View file

@ -12,9 +12,11 @@ jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: checkout - name: 'checkout git repo'
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: galaxy
uses: robertdebock/galaxy-action@1.2.1 - name: 'release on galaxy'
uses: robertdebock/galaxy-action@1.2.0
with: with:
galaxy_api_key: ${{ secrets.galaxy_api_key }} galaxy_api_key: ${{ secrets.galaxy_api_key }}
git_branch: 'main'

View file

@ -6,14 +6,18 @@ galaxy_info:
license: MIT license: MIT
min_ansible_version: 2.10.6 min_ansible_version: 2.10.6
platforms: platforms:
- name: ArchLinux
versions:
- all
- name: Debian - name: Debian
versions: all versions:
- name: EL - all
versions: all
- name: Fedora
versions: all
- name: Ubuntu - name: Ubuntu
versions: all versions:
- all
- name: Fedora
versions:
- all
galaxy_tags: galaxy_tags:
- backup - backup
- restic - restic

View file

@ -8,6 +8,7 @@
delegate_to: localhost delegate_to: localhost
- name: (SCHEDULE) (OLD) try to remove entries from /etc/crontab - name: (SCHEDULE) (OLD) try to remove entries from /etc/crontab
become: true
ansible.builtin.cron: ansible.builtin.cron:
name: "do1jlr.restic backup {{ item.name }}" name: "do1jlr.restic backup {{ item.name }}"
job: "CRON=true {{ restic_script_dir }}/backup-{{ item.name | replace(' ', '') }}.sh" job: "CRON=true {{ restic_script_dir }}/backup-{{ item.name | replace(' ', '') }}.sh"
@ -18,7 +19,6 @@
state: absent state: absent
cron_file: '/etc/crontab' cron_file: '/etc/crontab'
user: 'root' user: 'root'
become: true
no_log: "{{ restic_no_log }}" no_log: "{{ restic_no_log }}"
with_items: '{{ restic_backups }}' with_items: '{{ restic_backups }}'
when: when:
@ -26,11 +26,10 @@
- item.name is defined - item.name is defined
- item.scheduled | default(false) - item.scheduled | default(false)
- ansible_service_mgr != 'systemd' or restic_force_cron | default(false) or restic_schedule_type == "cronjob" - ansible_service_mgr != 'systemd' or restic_force_cron | default(false) or restic_schedule_type == "cronjob"
ignore_error: true
tags: skip_ansible_lint
register: cron_delete register: cron_delete
failed_when: false
- name: "(SCHEDULE) (OLD) make sure 'do1jlr.restic backup {{ item.name }}' is not in /etc/crontab" - name: "(SCHEDULE) (OLD) make sure do1jlr.restic backup script is not in /etc/crontab"
become: true become: true
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: '/etc/crontab' path: '/etc/crontab'
@ -39,7 +38,7 @@
when: cron_delete.failed when: cron_delete.failed
with_items: '{{ restic_backups }}' with_items: '{{ restic_backups }}'
- name: "(SCHEDULE) (OLD) make sure '{{ restic_script_dir }}/backup-{{ item.name | replace(' ', '') }}.sh' is not in /etc/crontab" - name: "(SCHEDULE) (OLD) make sure restic script is not in /etc/crontab"
become: true become: true
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: '/etc/crontab' path: '/etc/crontab'

View file

@ -1,22 +1,22 @@
--- ---
- name: add OS specific variables - name: Add OS specific variables
ansible.builtin.include_vars: "{{ lookup('first_found', restic_os_variables) }}" ansible.builtin.include_vars: "{{ lookup('first_found', restic_os_variables) }}"
- name: perform optional versionscheck - name: Perform optional versionscheck
ansible.builtin.include_tasks: 'versioncheck.yml' ansible.builtin.include_tasks: 'versioncheck.yml'
when: submodules_versioncheck | bool when: submodules_versioncheck | bool
- name: make sure restic is available - name: Make sure restic is available
ansible.builtin.include_tasks: 'preperation.yml' ansible.builtin.include_tasks: 'preperation.yml'
- name: make sure restic is installed - name: Make sure restic is installed
ansible.builtin.include_tasks: 'install.yml' ansible.builtin.include_tasks: 'install.yml'
when: not restic_executable.stat.exists or not restic_installed.stat.exists when: not restic_executable.stat.exists or not restic_installed.stat.exists
- name: initialize restic repo(s) - name: Initialize restic repo(s)
ansible.builtin.include_tasks: 'configure.yml' ansible.builtin.include_tasks: 'configure.yml'
- name: create backup script - name: Create backup script
ansible.builtin.include_tasks: 'backup.yml' ansible.builtin.include_tasks: 'backup.yml'
loop_control: loop_control:
loop_var: loop_distribution loop_var: loop_distribution
@ -25,7 +25,7 @@
distribution_version: '{{ ansible_distribution_version }}' distribution_version: '{{ ansible_distribution_version }}'
distribution_major_version: '{{ ansible_distribution_major_version }}' distribution_major_version: '{{ ansible_distribution_major_version }}'
- name: schedule restic backup - name: Schedule restic backup
ansible.builtin.include_tasks: 'schedule.yml' ansible.builtin.include_tasks: 'schedule.yml'
loop_control: loop_control:
loop_var: loop_distribution loop_var: loop_distribution

View file

@ -1,5 +1,9 @@
--- ---
- name: (SCHEDULE) (SYSTEMD) create systemd timer - name: (SCHEDULE) (SYSTEMD) create systemd timer
when:
- ansible_service_mgr == 'systemd'
- restic_schedule_type == "systemd"
- restic_create_schedule | bool
block: block:
- name: (SCHEDULE) (SYSTEMD) copy systemd timer - name: (SCHEDULE) (SYSTEMD) copy systemd timer
become: true become: true
@ -56,11 +60,7 @@
when: when:
- item.name is defined - item.name is defined
- item.scheduled | default(false) - item.scheduled | default(false)
when:
- ansible_service_mgr == 'systemd'
- restic_schedule_type == "systemd"
- restic_create_schedule | bool
rescue: rescue:
- name: set cronjob intead of systemd - name: Set cronjob intead of systemd
ansible.builtin.set_fact: ansible.builtin.set_fact:
restic_force_cron: true restic_force_cron: true

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_rule_template-instead-of-copy