mirror of
https://github.com/roles-ansible/ansible_role_restic/
synced 2026-09-05 19:27:05 +02:00
reference ansible facts through ansible_facts instead of ansible_ prefix
The feature is deprecated, Ansible 2.24 will remove access to facts through ansible_ prefix entirely.
example of such warning
```
[DEPRECATION WARNING]: INJECT_FACTS_AS_VARS default to `True` is deprecated, top-level facts will not be auto injected after the change. This feature will be removed from ansible-core version 2.24.
Origin: $HOME/.ansible/roles/roles-ansible.restic/handlers/main.yml:16:7
14 - item.name is defined
15 - item.scheduled | default(false)
16 - ansible_service_mgr == 'systemd'
^ column 7
```
This commit is contained in:
parent
9807f99ddd
commit
d8bfba2104
10 changed files with 27 additions and 27 deletions
|
|
@ -13,4 +13,4 @@
|
|||
- restic_create_schedule
|
||||
- item.name is defined
|
||||
- item.scheduled | default(false)
|
||||
- ansible_service_mgr == 'systemd'
|
||||
- ansible_facts['service_mgr'] == 'systemd'
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
success_msg: "Congratulations. You are using ansible version {{ ansible_version.full }}"
|
||||
delegate_to: localhost
|
||||
when:
|
||||
- ansible_service_mgr != 'systemd' or restic_force_cron | default(false) or restic_schedule_type == "cronjob"
|
||||
- ansible_facts['service_mgr'] != 'systemd' or restic_force_cron | default(false) or restic_schedule_type == "cronjob"
|
||||
register: old_af
|
||||
failed_when: false
|
||||
ignore_errors: true
|
||||
|
|
|
|||
|
|
@ -3,4 +3,4 @@
|
|||
|
||||
- name: Message
|
||||
ansible.builtin.fail:
|
||||
msg: 'Your {{ ansible_system }} is not yet supported'
|
||||
msg: 'Your {{ ansible_facts["system"] }} is not yet supported'
|
||||
|
|
|
|||
|
|
@ -3,4 +3,4 @@
|
|||
|
||||
- name: Message
|
||||
ansible.builtin.debug:
|
||||
msg: 'Your {{ ansible_system }} is not supported'
|
||||
msg: 'Your {{ ansible_facts["system"] }} is not supported'
|
||||
|
|
|
|||
|
|
@ -24,18 +24,18 @@
|
|||
loop_control:
|
||||
loop_var: loop_distribution
|
||||
vars:
|
||||
distribution: '{{ ansible_distribution }}'
|
||||
distribution_version: '{{ ansible_distribution_version }}'
|
||||
distribution_major_version: '{{ ansible_distribution_major_version }}'
|
||||
distribution: '{{ ansible_facts["distribution"] }}'
|
||||
distribution_version: '{{ ansible_facts["distribution_version"] }}'
|
||||
distribution_major_version: '{{ ansible_facts["distribution_major_version"] }}'
|
||||
|
||||
- name: Schedule restic backup
|
||||
ansible.builtin.include_tasks: 'schedule.yml'
|
||||
loop_control:
|
||||
loop_var: loop_distribution
|
||||
vars:
|
||||
distribution: '{{ ansible_distribution }}'
|
||||
distribution_version: '{{ ansible_distribution_version }}'
|
||||
distribution_major_version: '{{ ansible_distribution_major_version }}'
|
||||
distribution: '{{ ansible_facts["distribution"] }}'
|
||||
distribution_version: '{{ ansible_facts["distribution_version"] }}'
|
||||
distribution_major_version: '{{ ansible_facts["distribution_major_version"] }}'
|
||||
|
||||
- name: Set user permissions on folders
|
||||
ansible.builtin.include_tasks: 'permissions.yml'
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
- name: (SCHEDULE) (SYSTEMD) create systemd timer
|
||||
when:
|
||||
- ansible_service_mgr == 'systemd'
|
||||
- ansible_facts['service_mgr'] == 'systemd'
|
||||
- restic_schedule_type == "systemd"
|
||||
- restic_create_schedule | bool
|
||||
block:
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@
|
|||
- name: (SCHEDULE) create restic systemd timer
|
||||
ansible.builtin.include_tasks: restic_create_systemd.yml
|
||||
when:
|
||||
- ansible_service_mgr == 'systemd'
|
||||
- ansible_facts['service_mgr'] == 'systemd'
|
||||
- restic_schedule_type == "systemd"
|
||||
- restic_create_schedule | bool
|
||||
|
||||
- name: (SCHEDULE) delete systemd timers if available
|
||||
ansible.builtin.include_tasks: restic_delete_systemd.yml
|
||||
when:
|
||||
- ansible_service_mgr == 'systemd'
|
||||
- ansible_facts['service_mgr'] == 'systemd'
|
||||
- restic_schedule_type == "cronjob" or restic_force_cron | default(false)
|
||||
- restic_create_schedule | bool
|
||||
|
||||
|
|
@ -21,13 +21,13 @@
|
|||
ansible.builtin.include_tasks: restic_create_cron.yml
|
||||
when:
|
||||
- restic_create_schedule | bool
|
||||
- ansible_service_mgr != 'systemd' or restic_force_cron | default(false) or restic_schedule_type == "cronjob"
|
||||
- ansible_facts['service_mgr'] != 'systemd' or restic_force_cron | default(false) or restic_schedule_type == "cronjob"
|
||||
|
||||
- name: (SCHEDULE) remove restic cronjobs
|
||||
ansible.builtin.include_tasks: restic_delete_cron.yml
|
||||
when:
|
||||
- restic_create_schedule | bool
|
||||
- ansible_service_mgr == 'systemd'
|
||||
- ansible_facts['service_mgr'] == 'systemd'
|
||||
- not restic_force_cron | default(false)
|
||||
- restic_schedule_type != "cronjob"
|
||||
- not restic_do_not_cleanup_cron | bool
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ trap "rm -f $pid" SIGINT
|
|||
if [ -e $pid ]; then
|
||||
echo "Another version of this restic backup script is already running!"
|
||||
{% if item.mail_on_error is defined and item.mail_on_error == true %}
|
||||
mail -s "starting restic backup failed on {{ ansible_hostname }}" {{ item.mail_address }} <<< "Another restic backup process is already running. We canceled starting a new restic backup script running at {{ ansible_hostname }} at $(date -u '+%Y-%m-%d %H:%M:%S').
|
||||
mail -s "starting restic backup failed on {{ ansible_facts['hostname'] }}" {{ item.mail_address }} <<< "Another restic backup process is already running. We canceled starting a new restic backup script running at {{ ansible_facts['hostname'] }} at $(date -u '+%Y-%m-%d %H:%M:%S').
|
||||
{%- if item.src is defined -%}
|
||||
{{ ' ' }}We tried to backup '{{ item.src }}'.
|
||||
{%- endif -%}
|
||||
|
|
@ -245,7 +245,7 @@ then
|
|||
else
|
||||
echo "$(date -u '+%Y-%m-%d %H:%M:%S') ERROR" {{ pre_backup_cmd_result_log }}
|
||||
{% if item.mail_on_error is defined and item.mail_on_error == true %}
|
||||
mail -s "restic backup failed on {{ ansible_hostname }}" {{ item.mail_address }} <<< "Something went wrong while running restic backup script running at {{ ansible_hostname }} at $(date -u '+%Y-%m-%d %H:%M:%S').
|
||||
mail -s "restic backup failed on {{ ansible_facts['hostname'] }}" {{ item.mail_address }} <<< "Something went wrong while running restic backup script running at {{ ansible_facts['hostname'] }} at $(date -u '+%Y-%m-%d %H:%M:%S').
|
||||
{%- if item.src is defined -%}
|
||||
{{ ' ' }}We tried to backup '{{ item.src }}'.
|
||||
{%- endif -%}
|
||||
|
|
@ -292,7 +292,7 @@ case $BACKUP_EXIT_CODE in
|
|||
*)
|
||||
echo "$(date -u '+%Y-%m-%d %H:%M:%S') ERROR" {{ backup_result_log }}
|
||||
{% if item.mail_on_error is defined and item.mail_on_error == true %}
|
||||
mail -s "restic backup failed on {{ ansible_hostname }}" {{ item.mail_address }} <<< "Something went wrong while running restic backup script running at {{ ansible_hostname }} at $(date -u '+%Y-%m-%d %H:%M:%S').
|
||||
mail -s "restic backup failed on {{ ansible_facts['hostname'] }}" {{ item.mail_address }} <<< "Something went wrong while running restic backup script running at {{ ansible_facts['hostname'] }} at $(date -u '+%Y-%m-%d %H:%M:%S').
|
||||
{%- if item.src is defined -%}
|
||||
{{ ' ' }}We tried to backup '{{ item.src }}'.
|
||||
{%- endif -%}
|
||||
|
|
@ -321,7 +321,7 @@ then
|
|||
else
|
||||
echo "$(date -u '+%Y-%m-%d %H:%M:%S') ERROR" {{ forget_result_log }}
|
||||
{% if item.mail_on_error is defined and item.mail_on_error == true %}
|
||||
mail -s "restic backup failed on {{ ansible_hostname }}" {{ item.mail_address }} <<< "Something went wrong while running restic backup script running at {{ ansible_hostname }} at $(date -u '+%Y-%m-%d %H:%M:%S').
|
||||
mail -s "restic backup failed on {{ ansible_facts['hostname'] }}" {{ item.mail_address }} <<< "Something went wrong while running restic backup script running at {{ ansible_facts['hostname'] }} at $(date -u '+%Y-%m-%d %H:%M:%S').
|
||||
{%- if item.src is defined -%}
|
||||
{{ ' ' }}We tried to backup '{{ item.src }}'.
|
||||
{%- endif -%}
|
||||
|
|
@ -346,7 +346,7 @@ then
|
|||
else
|
||||
echo "$(date -u '+%Y-%m-%d %H:%M:%S') ERROR" {{ post_backup_cmd_result_log }}
|
||||
{% if item.mail_on_error is defined and item.mail_on_error == true %}
|
||||
mail -s "restic backup failed on {{ ansible_hostname }}" {{ item.mail_address }} <<< "Something went wrong while running restic backup script running at {{ ansible_hostname }} at $(date -u '+%Y-%m-%d %H:%M:%S').
|
||||
mail -s "restic backup failed on {{ ansible_facts['hostname'] }}" {{ item.mail_address }} <<< "Something went wrong while running restic backup script running at {{ ansible_facts['hostname'] }} at $(date -u '+%Y-%m-%d %H:%M:%S').
|
||||
{%- if item.src is defined -%}
|
||||
{{ ' ' }}We tried to backup '{{ item.src }}'.
|
||||
{%- endif -%}
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ restic_create_paths:
|
|||
restic_bin_path: '{{ restic_download_path }}/bin/restic-{{ restic_version }}'
|
||||
|
||||
restic_url_r: 'https://github.com/restic/restic/releases/download/'
|
||||
arch: '{{ ansible_architecture }}'
|
||||
arch: '{{ ansible_facts["architecture"] }}'
|
||||
restic_platform: '{{ _platform_map[arch] | default(arch) }}'
|
||||
restic_system: '{{ ansible_system | lower }}'
|
||||
restic_system: '{{ ansible_facts["system"] | lower }}'
|
||||
restic_url_v: 'v{{ restic_version }}/restic_{{ restic_version }}_'
|
||||
restic_file: '{{ restic_system }}_{{ restic_platform }}.bz2'
|
||||
restic_url_default: '{{ restic_url_r }}{{ restic_url_v }}{{ restic_file }}'
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
---
|
||||
restic_os_variables:
|
||||
files:
|
||||
- '{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml'
|
||||
- '{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml'
|
||||
- '{{ ansible_distribution }}.yml'
|
||||
- '{{ ansible_os_family }}.yml'
|
||||
- '{{ ansible_system }}.yml'
|
||||
- '{{ ansible_facts["distribution"] }}-{{ ansible_facts["distribution_version"] }}.yml'
|
||||
- '{{ ansible_facts["distribution"] }}-{{ ansible_facts["distribution_major_version"] }}.yml'
|
||||
- '{{ ansible_facts["distribution"] }}.yml'
|
||||
- '{{ ansible_facts["os_family"] }}.yml'
|
||||
- '{{ ansible_facts["system"] }}.yml'
|
||||
- 'defaults.yml'
|
||||
paths:
|
||||
- 'vars'
|
||||
|
|
|
|||
Loading…
Reference in a new issue