Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend configuration options #10

Merged
merged 4 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ bareos_dir_catalogs: []
# A list of consoled to configure.
bareos_dir_consoles: []

# A list of counters to configure.
bareos_dir_counters: []

# A list of clients to configure.
bareos_dir_clients: []

Expand Down
5 changes: 4 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ bareos_dir_tls_verify_peer: no
# A list of catalogs to configure.
bareos_dir_catalogs: []

# A list of consoled to configure.
# A list of consoles to configure.
bareos_dir_consoles: []

# A list of counters to configure.
bareos_dir_counters: []

# A list of clients to configure.
bareos_dir_clients: []

Expand Down
4 changes: 4 additions & 0 deletions meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ argument_specs:
type: "list"
default: []
description: "A list of consoled to configure."
bareos_dir_counters:
type: "list"
default: []
description: "A list of counters to configure."
bareos_dir_clients:
type: "list"
default: []
Expand Down
7 changes: 7 additions & 0 deletions tasks/assert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@
- bareos_dir_consoles is iterable
quiet: true

- name: assert | Test bareos_dir_counters
ansible.builtin.assert:
that:
- bareos_dir_counters is defined
- bareos_dir_counters is iterable
quiet: true

- name: assert | Test bareos_dir_clients
ansible.builtin.assert:
that:
Expand Down
15 changes: 15 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,21 @@
- Check configuration
- Reload bareos-dir

- name: Place counter
ansible.builtin.template:
src: counter.conf.j2
dest: "/etc/bareos/bareos-dir.d/counter/{{ item.name }}.conf"
owner: bareos
group: bareos
mode: "0644"
backup: "{{ bareos_dir_backup_configurations }}"
loop: "{{ bareos_dir_counters }}"
loop_control:
label: "{{ item.name }}"
notify:
- Check configuration
- Reload bareos-dir

- name: Place client
ansible.builtin.template:
src: client.conf.j2
Expand Down
3 changes: 3 additions & 0 deletions templates/client.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Client {
{% if item.tls_verify_peer is defined %}
TLS Verify Peer = {{ item.tls_verify_peer | ternary('Yes', 'No') }}
{% endif %}
{% if item.client_enabled is defined %}
Enabled = {{ item.client_enabled | ternary('yes', 'no') }}
{% endif %}
}
{% else %}
# This file is not enabled.
Expand Down
21 changes: 21 additions & 0 deletions templates/counter.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{ ansible_managed | comment }}

{% if item.enabled is defined and item.enabled or item.enabled is not defined %}
Counter {
Name = "{{ item.name }}"
{% if item.description is defined %}
Description = "{{ item.description }}"
{% endif %}
{% if item.catalog is defined %}
Catalog = "{{ item.catalog }}"
{% endif %}
{% if item.minimum is defined %}
Minimum = {{ item.minimum }}
{% endif %}
{% if item.maximum is defined %}
Maximum = {{ item.maximum }}
{% endif %}
}
{% else %}
# This file is not enabled.
{% endif %}
38 changes: 37 additions & 1 deletion templates/fileset.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,49 @@ FileSet {
{% endif %}
{% if item.include.options.compression is defined %}
Compression = {{ item.include.options.compression }}
{% endif %}
{% if item.include.options.no_atime is defined %}
No Atime = {{ item.include.options.no_atime | ternary('yes', 'no') }}
{% endif %}
{% if item.include.options.wilds is defined %}
{% for wild in item.include.options.wilds %}
Wild = "{{ wild }}"
{% endfor %}
{% endif %}
{% if item.include.options.wildfiles is defined %}
{% for wildfile in item.include.options.wildfiles %}
Wild File = "{{ wildfile }}"
{% endfor %}
{% endif %}
{% if item.include.options.wilddirs is defined %}
{% for wilddir in item.include.options.wilddirs %}
Wild Dir = "{{ wilddir }}"
{% endfor %}
{% endif %}
{% if item.include.options.regexs is defined %}
{% for regex in item.include.options.regexs %}
Regex = "{{ regex }}"
{% endfor %}
{% endif %}
{% if item.include.options.regexfiles is defined %}
{% for regexfile in item.include.options.regexfiles %}
Regex File = "{{ regexfile }}"
{% endfor %}
{% endif %}
{% if item.include.options.regexdirs is defined %}
{% for regexdirs in item.include.options.regexdirs %}
Regex Dir = "{{ regexdir }}"
{% endfor %}
{% endif %}
{% if item.include.options.exclude is defined %}
Exclude = {{ item.include.options.exclude | ternary('yes', 'no') }}
{% endif %}
}
{% if item.include.plugin is defined %}
Plugin = {{ item.include.plugin }}
{% endif %}
{% if item.include.exclude_dirs_containing is defined %}
Exclude Dir Containing = {{ item.include.exclude_dirs_containing }}
Exclude Dir Containing = {{ item.include.exclude_dirs_containing }}
{% endif %}

{% for file in item.include.files %}
Expand Down
128 changes: 127 additions & 1 deletion templates/job.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,36 @@
{% if item.pool is defined %}
Pool = {{ item.pool }}
{% endif %}
{% if item.next_pool is defined %}
Next Pool = {{ item.next_pool }}
{% endif %}
{% if item.type is defined %}
Type = {{ item.type }}
{% endif %}
{% if item.accurate is defined %}
Accurate = {{ item.accurate | ternary('yes', 'no') }}
{% endif %}
{% if item.always_incremental is defined %}
Always Incremental = {{ item.always_incremental | ternary('yes', 'no') }}
{% endif %}
{% if item.always_incremental_job_retention is defined %}
Always Incremental Job Retention = {{ item.always_incremental_job_retention }}
{% endif %}
{% if item.always_incremental_keep_number is defined %}
Always Incremental Keep Number = {{ item.always_incremental_keep_number }}
{% endif %}
{% if item.always_incremental_max_full_age is defined %}
Always Incremental Max Full Age = {{ item.always_incremental_max_full_age }}
{% endif %}
{% if item.max_full_consolidations is defined %}
Max Full Consolidations = {{ item.max_full_consolidations }}
{% endif %}
{% if item.selection_type is defined %}
Selection Type = {{ item.selection_type }}
{% endif %}
{% if item.selection_pattern is defined %}
Selection Pattern = "{{ item.selection_pattern }}"
{% endif %}
{% if item.description is defined %}
Description = "{{ item.description }}"
{% endif %}
Expand All @@ -25,7 +52,7 @@
Storage = "{{ item.storage }}"
{% endif %}
{% if item.jobdefs is defined %}
Job Defs = "{{ item.jobdefs }}"
JobDefs = "{{ item.jobdefs }}"
{% endif %}
{% if item.level is defined %}
Level = {{ item.level }}
Expand All @@ -47,6 +74,105 @@
{% endif %}
{% if item.plugin_options is defined %}
Dir Plugin Options = {{ item.plugin_options }}
{% if item.max_concurrent_copies is defined %}
Max Concurrent Copies = {{ item.max_concurrent_copies }}
{% endif %}
{% if item.maximum_bandwidth is defined %}
Maximum Bandwidth = {{ item.maximum_bandwidth }}
{% endif %}
{% if item.priority is defined %}
Priority = {{ item.priority }}
{% endif %}
{% if item.allow_mixed_priority is defined %}
Allow Mixed Priority = {{ item.allow_mixed_priority | ternary('yes', 'no') }}
{% endif %}
{% if item.write_bootstrap is defined %}
Write Bootstrap = "{{ item.write_bootstrap }}"
{% endif %}
{% if item.full_backup_pool is defined %}
Full Backup Pool = {{ item.full_backup_pool }}
{% endif %}
{% if item.differential_backup_pool is defined %}
Differential Backup Pool = {{ item.differential_backup_pool }}
{% endif %}
{% if item.incremental_backup_pool is defined %}
Incremental Backup Pool = {{ item.incremental_backup_pool }}
{% endif %}
{% if item.virtual_full_backup_pool is defined %}
Virtual Full Backup Pool = {{ item.virtual_full_backup_pool }}
{% endif %}
{% if item.run_script is defined %}
Run Script {
{% if item.run_script.command is defined %}
Command = "{{ item.run_script.command }}"
{% endif %}
{% if item.run_script.console is defined %}
console = "{{ item.run_script.console }}"
{% endif %}
{% if item.run_script.runs_on_client is defined %}
Runs On Client = {{ item.run_script.runs_on_client | ternary('yes', 'no') }}
{% endif %}
{% if item.run_script.runs_on_failure is defined %}
Runs On Failure = {{ item.run_script.runs_on_failure | ternary('yes', 'no') }}
{% endif %}
{% if item.run_script.runs_when is defined %}
Runs When = {{ item.run_script.runs_when }}
{% endif %}
}
{% endif %}
{% if item.run_before_job is defined %}
RunBeforeJob = {{ item.run_before_job }}
{% endif %}
{% if item.run_after_job is defined %}
RunAfterJob = {{ item.run_after_job }}
{% endif %}
{% if item.spool_data is defined %}
Spool Data = {{ item.spool_data | ternary('yes', 'no') }}
{% endif %}
{% if item.spool_size is defined %}
Spool Size = {{ item.spool_size }}
{% endif %}
{% if item.job_enabled is defined %}
Enabled = {{ item.job_enabled | ternary('yes', 'no') }}
{% endif %}
{% if item.prune_files is defined %}
Prune Files = {{ item.prune_files | ternary('yes', 'no') }}
{% endif %}
{% if item.prune_jobs is defined %}
Prune Jobs = {{ item.prune_jobs | ternary('yes', 'no') }}
{% endif %}
{% if item.prune_volumes is defined %}
Prune Volumes = {{ item.prune_volumes | ternary('yes', 'no') }}
{% endif %}
{% if item.allow_duplicate_jobs is defined %}
Allow Duplicate Jobs = {{ item.allow_duplicate_jobs | ternary('yes', 'no') }}
{% endif %}
{% if item.cancel_lower_level_duplicates is defined %}
Cancel Lower Level Duplicates = {{ item.cancel_lower_level_duplicates | ternary('yes', 'no') }}
{% endif %}
{% if item.cancel_queued_duplicates is defined %}
Cancel Queued Duplicates = {{ item.cancel_queued_duplicates | ternary('yes', 'no') }}
{% endif %}
{% if item.cancel_running_duplicates is defined %}
Cancel Running Duplicates = {{ item.cancel_running_duplicates | ternary('yes', 'no') }}
{% endif %}
{% if item.backup_format is defined %}
Backup Format = {{ item.backup_format }}
{% endif %}
{% if item.max_run_sched_time is defined %}
Max Run Sched Time = {{ item.max_run_sched_time }}
{% endif %}
{% if item.max_run_time is defined %}
Max Run Time = {{ item.max_run_time }}
{% endif %}
{% if item.max_start_delay is defined %}
Max Start Delay = {{ item.max_start_delay }}
{% endif %}
{% if item.max_wait_time is defined %}
Max Wait Time = {{ item.max_wait_time }}
{% endif %}
{% if item.prefer_mounted_volumes is defined %}
Prefer Mounted Volumes = {{ item.prefer_mounted_volumes | ternary('yes', 'no') }}
{% endif %}
}
{% else %}
Expand Down
27 changes: 27 additions & 0 deletions templates/pool.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,30 @@ Pool {
{% if item.recycle is defined %}
Recycle = {{ item.recycle | ternary('Yes', 'No') }}
{% endif %}
{% if item.recycle_oldest_volume is defined %}
Recycle Oldest Volume = {{ item.recycle_oldest_volume | ternary('Yes', 'No') }}
{% endif %}
{% if item.recycle_current_volume is defined %}
Recycle Current Volume = {{ item.recycle_current_volume | ternary('Yes', 'No') }}
{% endif %}
{% if item.recycle_pool is defined %}
Recycle Pool = {{ item.recycle_pool }}
{% endif %}
{% if item.scratch_pool is defined %}
Scratch Pool = {{ item.scratch_pool }}
{% endif %}
{% if item.purge_oldest_volume is defined %}
Purge Oldest Volume = {{ item.purge_oldest_volume | ternary('Yes', 'No') }}
{% endif %}
{% if item.autoprune is defined %}
AutoPrune = {{ item.autoprune | ternary('Yes', 'No') }}
{% endif %}
{% if item.volume_retention is defined %}
Volume Retention = {{ item.volume_retention }}
{% endif %}
{% if item.action_on_purge is defined %}
Action On Purge = {{ item.action_on_purge }}
{% endif %}
{% if item.maximum_volume_bytes is defined %}
Maximum Volume Bytes = {{ item.maximum_volume_bytes }}
{% endif %}
Expand All @@ -22,6 +40,15 @@ Pool {
{% if item.label_format is defined %}
Label Format = "{{ item.label_format }}"
{% endif %}
{% if item.storage is defined %}
Storage = "{{ item.storage }}"
{% endif %}
{% if item.next_pool is defined %}
Next Pool = "{{ item.next_pool }}"
{% endif %}
{% if item.volume_use_duration is defined %}
Volume Use Duration = {{ item.volume_use_duration }}
{% endif %}
}
{% else %}
# This file is not enabled.
Expand Down
3 changes: 3 additions & 0 deletions templates/schedule.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Schedule {
{% for run in item.run %}
Run = {{ run }}
{% endfor %}
{% if item.schedule_enabled is defined %}
Enabled = {{ item.schedule_enabled | ternary('yes', 'no') }}
{% endif %}
}
{% else %}
# This file is not enabled.
Expand Down
9 changes: 9 additions & 0 deletions templates/storage.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ Storage {
Name = "{{ item.name }}"
Address = "{{ item.address }}"
Password = "{{ item.password }}"
{% if item.devices is defined %}
{% for device in item.devices | default([]) %}
Device = "{{ device }}"
{% endfor %}
{% else %}
Device = "{{ item.device }}"
{% endif %}
Media Type = "{{ item.media_type }}"
{% if item.tls_enable is defined %}
TLS Enable = {{ item.tls_enable | ternary('Yes', 'No') }}
Expand All @@ -16,6 +22,9 @@ Storage {
{% if item.maximum_concurrent_jobs is defined %}
Maximum Concurrent Jobs = {{ item.maximum_concurrent_jobs }}
{% endif %}
{% if item.autochanger is defined %}
Auto Changer = {{ item.autochanger | ternary('Yes', 'No') }}
{% endif %}
}
{% else %}
# This file is not enabled.
Expand Down
Loading