-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.yml
110 lines (95 loc) · 3.62 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
---
# tasks file for sbaerlocher.veeam-agent
- name: add OS specific variables
include_vars: "{{ loop_vars }}"
with_first_found:
- files:
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml"
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
- "{{ ansible_distribution }}.yml"
- "{{ ansible_os_family }}.yml"
- "defaults.yml"
paths:
- "vars"
loop_control:
loop_var: loop_vars
tags:
- configuration
- packages
- name: include distribution tasks
include_tasks: "{{ loop_distribution }}"
with_first_found:
- files:
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml"
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
- "{{ ansible_distribution }}.yml"
- "{{ ansible_os_family }}.yml"
- "defaults.yml"
paths:
- "distribution"
loop_control:
loop_var: loop_distribution
tags:
- configuration
- packages
- name: install veeam
package:
name: veeam
when: ansible_os_family == 'Linux'
tags:
- packages
# Veeam Backup & Replication
- block:
- name: check if veeam B&R exist
command: veeamconfig vbrserver list
register: veeam_vbrserver_list
- name: create veeam B&R
command: "veeamconfig vbrserver add --name {{ veeam.vbrserver.name }} --address {{ veeam.vbrserver.endpoint }} --login {{ veeam.vbrserver.login }} --domain {{ veeam.vbrserver.domain }} --password {{ veeam.vbrserver.password }}"
register: veeam_create_repository
when: veeam.vbrserver not in veeam_vbrserver_list.stdout
when: veeam.vbrserver.name is defined and ansible_os_family == 'Linux'
tags:
- configuration
# Veeam local
- block:
- name: check if veeam repo exist
command: veeamconfig repository list
register: veeam_repository_list
- name: create veeam repo
command: "veeamconfig repository create --name {{ veeam.repo.name }} --location {{ veeam.repo.path }}"
register: veeam_create_repository
when: veeam.repo.name not in veeam_repository_list.stdout
when: veeam.repo.name is defined and ansible_os_family == 'Linux'
tags:
- configuration
- block:
- name: load repository list
command: "veeamconfig repository list"
register: veeam_repository_list
- name: load veeam repository name
set_fact:
veeam_repository_name: "{{ veeam_repository_list.stdout_lines.1.split(' ').0 | string }}"
- name: check if veeam job exist
command: "veeamconfig job list"
when: ansible_os_family == 'Linux'
register: veeam_job_list
- name: create veeam job
command: "veeamconfig job create --name {{ veeam.job.name }} --repoName {{ }} --maxPoints {{ veeam.job.restopoints }} --backupallsystem"
register: veeam_create_job
when: 'veeam.job.name not in veeam_job_list.stdout'
- name: load veeam job info
command: "veeamconfig job info --name {{ veeam.job.name }}"
register: veeam_job_info
- name: load veeam Job id
set_fact:
veeam_job_id: "{{ veeam_job_info.stdout_lines.1 | regex_replace(' ID: ', '') | string }}"
- name: check if veeam schedule exist
shell: "veeamconfig schedule show --jobId '{{ veeam_job_id }}' 2>/dev/null"
register: veeam_schedule_show
ignore_errors: yes
- name: create veeam schedule
command: "veeamconfig schedule set --jobId {{ veeam_job_id }} --at {{ veeam.job.at | default('20:00') }} --daily"
when: "'Run automatically: enabled' not in veeam_schedule_show.stdout"
when: ansible_os_family == 'Linux'
tags:
- configuration