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

feat: Split Storage Daemon config from server #20

Merged
merged 2 commits into from
Aug 31, 2023
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
5 changes: 5 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@
service:
name: apache2
state: restarted

- name: Restart bareos-storage
ansible.builtin.systemd:
name: bareos-storage.service
state: restarted
68 changes: 68 additions & 0 deletions tasks/bareos_sd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
- name: Ensure bareos-storage is installed
ansible.builtin.apt:
name:
- bareos-storage

- name: Configure Sd->Storage resource
template:
src: bareos-sd/storage/bareos-sd.conf.j2
dest: /etc/bareos/bareos-sd.d/storage/bareos-sd.conf
owner: bareos
group: bareos
mode: '0640'
notify: Restart bareos-storage

- name: Configure Sd->Director resource
template:
src: bareos-sd/director/bareos-dir.conf.j2
dest: /etc/bareos/bareos-sd.d/director/bareos-dir.conf
owner: bareos
group: bareos
mode: '0640'
notify: Restart bareos-storage

- name: Configure Storage Daemon block devices
when: bareos_devices is defined
block:
- name: Create file systems
community.general.filesystem:
fstype: "{{ item.fstype | default('ext4') }}"
dev: "{{ item.block_device }}"
force: false
state: present
loop: "{{ bareos_devices }}"
# Create file system only when block_device starts with '/dev/'
when:
- item.block_device is defined
- item.block_device[:5] == '/dev/'

- name: Mount Bareos block devices
ansible.posix.mount:
path: "{{ item.archive_device | default(item.arch_device) }}"
src: "{{ item.block_device }}"
fstype: "{{ item.fstype | default('ext4') }}"
opts: "{{ item.opts | default(omit) }}"
state: "{{ item.state | default('mounted') }}"
loop: "{{ bareos_devices }}"
when: item.block_device is defined

- name: Set permissions on archive devices
ansible.builtin.file:
path: "{{ item.archive_device | default(item.arch_device) }}"
owner: "bareos"
group: "bareos"
mode: "{{ item.mode | default('0750') }}"
state: directory
loop: "{{ bareos_devices }}"

- name: Configure Sd->Device resources
template:
src: bareos-sd/device/device.conf.j2
dest: /etc/bareos/bareos-sd.d/device/{{ item.name }}.conf
owner: bareos
group: bareos
mode: '0640'
loop: "{{ bareos_devices }}"
when: bareos_devices is defined
notify: Restart bareos-storage
57 changes: 0 additions & 57 deletions tasks/bareos_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,6 @@
group: bareos
mode: '0640'

- name: Create bareos sd director config file
template:
src: bareos-sd/director/bareos-dir.conf.j2
dest: /etc/bareos/bareos-sd.d/director/bareos-dir.conf
owner: bareos
group: bareos
mode: '0640'

- name: Create bareos fileset config files
template:
src: bareos-dir/fileset/fileset.conf.j2
Expand Down Expand Up @@ -121,55 +113,6 @@
loop: "{{ bareos_dir_storage }}"
when: bareos_dir_storage is defined

- name: Configure Storage Daemon block devices
when: bareos_devices is defined
block:
- name: Create file systems
community.general.filesystem:
fstype: "{{ item.fstype | default('ext4') }}"
dev: "{{ item.block_device }}"
force: false
state: present
loop: "{{ bareos_devices }}"
# Create file system only when block_device starts with '/dev/'
when: item.block_device[:5] == '/dev/'

- name: Mount Bareos block devices
ansible.posix.mount:
path: "{{ item.archive_device | default(item.arch_device) }}"
src: "{{ item.block_device }}"
fstype: "{{ item.fstype | default('ext4') }}"
opts: "{{ item.opts | default(omit) }}"
state: "{{ item.state | default('mounted') }}"
loop: "{{ bareos_devices }}"

- name: Set permissions on archive devices
ansible.builtin.file:
path: "{{ item.archive_device | default(item.arch_device) }}"
owner: "bareos"
group: "bareos"
mode: "{{ item.mode | default('0750') }}"
state: directory
loop: "{{ bareos_devices }}"

- name: Create bareos device config files
template:
src: bareos-sd/device/device.conf.j2
dest: /etc/bareos/bareos-sd.d/device/{{ item.name }}.conf
owner: bareos
group: bareos
mode: '0640'
loop: "{{ bareos_devices }}"
when: bareos_devices is defined

- name: Create bareos sd storage config file
template:
src: bareos-sd/storage/bareos-sd.conf.j2
dest: /etc/bareos/bareos-sd.d/storage/bareos-sd.conf
owner: bareos
group: bareos
mode: '0640'

- name: Create bareos schedule config files
template:
src: bareos-dir/schedule/schedule.conf.j2
Expand Down
4 changes: 4 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
include_tasks: bareos_server.yml
when: bareos_install_server

- name: Install Bareos Storage Daemon
include_tasks: bareos_sd.yml
when: "'bareos_storage' in group_names or bareos_install_server"

- name: Register clients
include_tasks: register_client.yml
with_items: "{{ bareos_clients }}"
Expand Down
2 changes: 1 addition & 1 deletion templates/bareos-sd/storage/bareos-sd.conf.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Storage {
Name = bareos-sd
Name = {{ inventory_hostname }}-sd
Maximum Concurrent Jobs = 50

# remove comment from "Plugin Directory" to load plugins from specified directory.
Expand Down