Skip to content

Commit

Permalink
Add clients.
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-de-bock committed Aug 22, 2023
1 parent cba2080 commit 04c29fe
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 9 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Install and configure BareOS Director on your system.

|GitHub|GitLab|Quality|Downloads|Version|
|------|------|-------|---------|-------|
|[![github](https://github.com/robertdebock/ansible-role-bareos_dir/workflows/Ansible%20Molecule/badge.svg)](https://github.com/robertdebock/ansible-role-bareos_dir/actions)|[![gitlab](https://gitlab.com/robertdebock-iac/ansible-role-bareos_dir/badges/master/pipeline.svg)](https://gitlab.com/robertdebock-iac/ansible-role-bareos_dir)|[![quality](https://img.shields.io/ansible/quality/)](https://galaxy.ansible.com/robertdebock/bareos_dir)|[![downloads](https://img.shields.io/ansible/role/d/)](https://galaxy.ansible.com/robertdebock/bareos_dir)|[![Version](https://img.shields.io/github/release/robertdebock/ansible-role-bareos_dir.svg)](https://github.com/robertdebock/ansible-role-bareos_dir/releases/)|
|[![github](https://github.com/robertdebock/ansible-role-bareos_dir/workflows/Ansible%20Molecule/badge.svg)](https://github.com/robertdebock/ansible-role-bareos_dir/actions)|[![gitlab](https://gitlab.com/robertdebock-iac/ansible-role-bareos_dir/badges/master/pipeline.svg)](https://gitlab.com/robertdebock-iac/ansible-role-bareos_dir)|[![quality](https://img.shields.io/ansible/quality/63105)](https://galaxy.ansible.com/robertdebock/bareos_dir)|[![downloads](https://img.shields.io/ansible/role/d/63105)](https://galaxy.ansible.com/robertdebock/bareos_dir)|[![Version](https://img.shields.io/github/release/robertdebock/ansible-role-bareos_dir.svg)](https://github.com/robertdebock/ansible-role-bareos_dir/releases/)|

## [Example Playbook](#example-playbook)

Expand All @@ -22,6 +22,10 @@ This example is taken from [`molecule/default/converge.yml`](https://github.com/
bareos_dir_password: "secretpassword"
bareos_dir_max_concurrent_jobs: 10
bareos_dir_messages: Daemon
bareos_dir_clients:
- name: client1
address: 127.0.0.1
password: "MySecretPassword"
```

The machine needs to be prepared. In CI this is done using [`molecule/default/prepare.yml`](https://github.com/robertdebock/ansible-role-bareos_dir/blob/master/molecule/default/prepare.yml):
Expand Down Expand Up @@ -63,6 +67,12 @@ bareos_dir_hostname: "{{ ansible_fqdn }}"
bareos_dir_queryfile: "/usr/lib/bareos/scripts/query.sql"
# bareos_dir_max_concurrent_jobs: 10 # <- Please set your own value.
# bareos_dir_messages: Daemon # <- Please set your own.

# You need to configure Director with all clients.
# bareos_dir_clients:
# - name: client1
# address: 127.0.0.1
# password: "MySecretPassword"
```

## [Requirements](#requirements)
Expand Down
13 changes: 12 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,15 @@ bareos_dir_hostname: "{{ ansible_fqdn }}"
# bareos_dir_password: "secretpassword" # <- Please set your own password.
bareos_dir_queryfile: "/usr/lib/bareos/scripts/query.sql"
# bareos_dir_max_concurrent_jobs: 10 # <- Please set your own value.
# bareos_dir_messages: Daemon # <- Please set your own.
# bareos_dir_message: Daemon # <- Please set your own.

# You need to configure Director with all clients.
# bareos_dir_clients:
# - name: client1
# address: 127.0.0.1
# password: "MySecretPassword"

bareos_dir_messages:
- name: "Standard"
director: "dir-1 = all, !skipped, !restored"
description: "Send all messages to the Director."
8 changes: 7 additions & 1 deletion meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ argument_specs:
bareos_dir_max_concurrent_jobs:
type: "int"
description: "The maximum number of concurrent jobs."
bareos_dir_messages:
bareos_dir_message:
type: "str"
description: "The messages to show."
bareos_dir_clients:
type: "list"
description: "A list of clients to configure."
bareos_dir_messages:
type: "list"
description: "A list of messages to configure."
10 changes: 9 additions & 1 deletion molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,12 @@
- role: ansible-role-bareos_dir
bareos_dir_password: "secretpassword"
bareos_dir_max_concurrent_jobs: 10
bareos_dir_messages: Daemon
bareos_dir_message: Daemon
bareos_dir_clients:
- name: client1
address: 127.0.0.1
password: "MySecretPassword"
bareos_dir_messages:
- name: "Standard"
director: "dir-1 = all, !skipped, !restored"
description: "Send all messages to the Director."
60 changes: 58 additions & 2 deletions tasks/assert.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,66 @@
- bareos_dir_max_concurrent_jobs is number
quiet: yes

- name: assert | Test if bareos_dir_message is set correctly
ansible.builtin.assert:
that:
- bareos_dir_message is defined
- bareos_dir_message is string
- bareos_dir_message is not none
quiet: yes

- name: assert | Test if bareos_dir_clients is set correctly
ansible.builtin.assert:
that:
- bareos_dir_clients is iterable
- bareos_dir_clients is not none
quiet: yes
when:
- bareos_dir_clients is defined

- name: assert | Test if items in bareos_dir_clients are set correctly
ansible.builtin.assert:
that:
- item.name is defined
- item.name is string
- item.name is not none
- item.address is defined
- item.address is string
- item.address is not none
- item.password is defined
- item.password is string
- item.password is not none
quiet: yes
loop: "{{ bareos_dir_clients }}"
loop_control:
label: "{{ item.name }}"
when:
- bareos_dir_clients is defined

- name: assert | Test if bareos_dir_messages is set correctly
ansible.builtin.assert:
that:
- bareos_dir_messages is defined
- bareos_dir_messages is string
- bareos_dir_messages is iterable
- bareos_dir_messages is not none
quiet: yes
when:
- bareos_dir_messages is defined

- name: assert | Test if items in bareos_dir_messages are set correctly
ansible.builtin.assert:
that:
- item.name is defined
- item.name is string
- item.name is not none
- item.director is defined
- item.director is string
- item.director is not none
- item.description is defined
- item.description is string
- item.description is not none
quiet: yes
loop: "{{ bareos_dir_messages }}"
loop_control:
label: "{{ item.name }}"
when:
- bareos_dir_messages is defined
13 changes: 13 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@
notify:
- Restart bareos-dir

- name: Place messages
ansible.builtin.template:
src: message.conf.j2
dest: "/etc/bareos/bareos-dir.d/messages/{{ item.name | capitalize }}.conf"
owner: bareos
group: bareos
mode: "0640"
loop: "{{ bareos_dir_messages }}"
loop_control:
label: "{{ item.name }}"
notify:
- Restart bareos-dir

- name: Start bareos-dir
ansible.builtin.service:
name: bareos-dir
Expand Down
4 changes: 1 addition & 3 deletions templates/bareos-dir.conf.j2
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# {{ ansible_managed }}

# Based on https://docs.bareos.org/Configuration/Director.html

Director {
Name = {{ bareos_dir_hostname }}
Password = {{ bareos_dir_password }}
QueryFile = "{{ bareos_dir_queryfile }}"
Maximum Concurrent Jobs = {{ bareos_dir_max_concurrent_jobs }}
Messages = {{ bareos_dir_messages }}
Messages = {{ bareos_dir_message }}
}
7 changes: 7 additions & 0 deletions templates/message.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# {{ ansible_managed }}

Messages {
Name = {{ item.name }}
Director = {{ item.director }}
Description = {{ item.description }}
}

0 comments on commit 04c29fe

Please sign in to comment.