diff --git a/defaults/main.yml b/defaults/main.yml index b27299a..975fd85 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -33,9 +33,12 @@ bareos_dir_tls_verify_peer: false # 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: [] diff --git a/tasks/main.yml b/tasks/main.yml index 51f037e..01393dd 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -88,6 +88,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 diff --git a/templates/client.conf.j2 b/templates/client.conf.j2 index dc37175..7f92e6e 100644 --- a/templates/client.conf.j2 +++ b/templates/client.conf.j2 @@ -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. diff --git a/templates/counter.conf.j2 b/templates/counter.conf.j2 new file mode 100644 index 0000000..6679111 --- /dev/null +++ b/templates/counter.conf.j2 @@ -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 %} diff --git a/templates/fileset.conf.j2 b/templates/fileset.conf.j2 index 5ccce2d..03465ea 100644 --- a/templates/fileset.conf.j2 +++ b/templates/fileset.conf.j2 @@ -17,10 +17,46 @@ 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.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 %} diff --git a/templates/job.conf.j2 b/templates/job.conf.j2 index 6c40609..2fac4ae 100644 --- a/templates/job.conf.j2 +++ b/templates/job.conf.j2 @@ -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 %} @@ -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 }} @@ -45,6 +72,106 @@ {% if item.maximum_concurrent_jobs is defined %} Maximum Concurrent Jobs = {{ item.maximum_concurrent_jobs }} {% endif %} +{% 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 %} # This file is not enabled. diff --git a/templates/pool.conf.j2 b/templates/pool.conf.j2 index a45cf51..54ccde6 100644 --- a/templates/pool.conf.j2 +++ b/templates/pool.conf.j2 @@ -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 %} @@ -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. diff --git a/templates/schedule.conf.j2 b/templates/schedule.conf.j2 index 2a41234..8d299ef 100644 --- a/templates/schedule.conf.j2 +++ b/templates/schedule.conf.j2 @@ -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. diff --git a/templates/storage.conf.j2 b/templates/storage.conf.j2 index df1de97..3b8f777 100644 --- a/templates/storage.conf.j2 +++ b/templates/storage.conf.j2 @@ -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') }} @@ -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.