Skip to content
Open
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
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,47 @@ If no value is provided, `listmaster` will be joined with a @ to the

For example: *listmaster@lists.example.com*.

### Sympa robots

#### *sympa_robots*

With *sympa_robots* the role defines and populates the `robots.conf` files of a multi-domains Sympa server.

*sympa_robots* is a dict, where each key is the *domain* on which the robot operates (mail and web), and the value is a dict which defines the values of all the parameters of the robot. It may contain parameters such as `wwsympa_url`, `listmaster`, `title`, or any other [configuration parameter valid in a `robot.conf` file](https://www.sympa.community/gpldoc/man/sympa_config.5.html), with its associated value(s).

*listmaster* can be defined as an ansible list of emails, or as a string of comma separated email addresses. Compound paramentes can be defined as sub-dicts. For instance:
```
sympa_robots:
lists.mydomain.tld:
listmaster: ...

archive:
web_access: public
mail_access: private
```
will render in the `lists.mydomain.tld/robot.conf` configuration file:
```
# Robot configuration for lists.mydomain.tld
domain lists.mydomain.tld

# Robot's listmaster
listmaster ...

# archive value(s)
archive.web_access public
archive.mail_access private
```
For backwards compatibility, *sympa_robots* can also be defined as a list of dicts where all items have a parameter *domain* defining the robot:
```
sympa_robots:
- domain: lists.mydomain.tld
listmaster: ...

archive:
web_access: public
mail_access: private
```

### Installation

You can pick from different installation methods through the
Expand Down
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ sympa_soap_nginx_snippet: |
fastcgi_pass unix:/run/sympasoap/sympasoap.socket;
}

sympa_robots: {}

sympa_install_odbc_driver: false

sympa_rsyslog_unix_user: "{{ sympa_unix_user }}"
6 changes: 3 additions & 3 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@
- sympa
- sympa-conf

- name: Create configuration files for robots on request
import_tasks: robots.yml
when: sympa_robots | default([]) | count > 0
- name: Create configuration files for robots on request (dict variable)
import_tasks:
file: robots.yml
tags:
- sympa
- sympa-conf
Expand Down
48 changes: 48 additions & 0 deletions tasks/robot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
# Copyright (C) 2020-2022 Stefan Hornburg (Racke) <racke@linuxia.de>
# SPDX-License-Identifier: GPL-2.0-or-later

- name: Create directory for {{ sympa_robot_domain }} robot
file:
state: directory
path: "{{ sympa_configuration_directory }}/{{ sympa_robot_domain }}"
owner: "{{ sympa_unix_user }}"
group: "{{ sympa_unix_group }}"
mode: 0755

- name: Create list data directory for {{ sympa_robot_domain }} robot
file:
state: directory
path: "{{ sympa_list_home_directory }}/{{ sympa_robot_domain }}"
owner: "{{ sympa_unix_user }}"
group: "{{ sympa_unix_group }}"
mode: 0755

- name: Create archives' directory {{ sympa_robot_domain }} robot
file:
state: directory
path: "{{ sympa_installation_directory }}/arc/{{ sympa_robot_domain }}"
owner: "{{ sympa_unix_user }}"
group: "{{ sympa_unix_group }}"
mode: 0755

- debug:
var: "{{ item }}"
verbosity: 2
loop:
- sympa_robot_domain
- sympa_robot
- sympa_robots


- name: Create {{ sympa_robot_domain }} robot configuration file
template:
src: robot.conf.j2
dest: "{{ sympa_configuration_directory }}/{{ sympa_robot_domain }}/robot.conf"
owner: "{{ sympa_unix_user }}"
group: "{{ sympa_unix_group }}"
mode: 0644
notify:
- restart sympa
- restart wwsympa

76 changes: 35 additions & 41 deletions tasks/robots.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,41 @@
---
# Copyright (C) 2020-2022 Stefan Hornburg (Racke) <racke@linuxia.de>
# SPDX-License-Identifier: GPL-2.0-or-later

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did attribution and license get deleted here?

# Sympa robots configuration

- name: Create directory for robots
file:
state: directory
path: "{{ sympa_configuration_directory }}/{{ item.domain }}"
owner: "{{ sympa_unix_user }}"
group: "{{ sympa_unix_group }}"
mode: 0755
when: item.domain != sympa_domain
loop: "{{ sympa_robots }}"
- name: Create configuration files for robots on request (dict variable)
include_tasks:
file: robot.yml
apply:
tags:
- sympa
- sympa-conf
- sympa-robots
loop: "{{ sympa_robots | list }}"
loop_control:
loop_var: sympa_robot_domain
vars:
sympa_robot_domain_query: '"{{ sympa_robot_domain }}"'
sympa_robot: "{{ sympa_robots | community.general.json_query ( sympa_robot_domain_query ) }}"
when:
- sympa_robots is mapping
- sympa_robot_domain != sympa_domain

- name: Create list data directory for robots
file:
state: directory
path: "{{ sympa_list_home_directory }}/{{ item.domain }}"
owner: "{{ sympa_unix_user }}"
group: "{{ sympa_unix_group }}"
mode: 0755
when: item.domain != sympa_domain
loop: "{{ sympa_robots }}"

- name: Create list data directory for robots
file:
state: directory
path: "{{ sympa_list_home_directory }}/{{ item.domain }}"
owner: "{{ sympa_unix_user }}"
group: "{{ sympa_unix_group }}"
mode: 0755
when: item.domain != sympa_domain
loop: "{{ sympa_robots }}"
- name: Create configuration files for robots on request (list variable)
include_tasks:
file: robot.yml
apply:
tags:
- sympa
- sympa-conf
- sympa-robots
loop: "{{ sympa_robots | list }}"
loop_control:
loop_var: sympa_robot
vars:
sympa_robot_domain: "{{ sympa_robot.domain }}"
when:
- sympa_robots is not mapping # then it must be a list of dicts
- sympa_robot_domain != sympa_domain

- name: Create configuration file
template:
src: robot.conf.j2
dest: "{{ sympa_configuration_directory }}/{{ item.domain }}/robot.conf"
owner: "{{ sympa_unix_user }}"
group: "{{ sympa_unix_group }}"
mode: 0644
when: item.domain != sympa_domain
loop: "{{ sympa_robots }}"
notify:
- restart sympa
- restart wwsympa

...
32 changes: 28 additions & 4 deletions templates/robot.conf.j2
Original file line number Diff line number Diff line change
@@ -1,8 +1,32 @@
# Robot configuration for {{ item.domain }}
domain {{ item.domain }}
# Robot configuration for {{ sympa_robot_domain }}
domain {{ sympa_robot_domain }}

# Robot's listmaster
{% if sympa_robot.listmaster is defined %}
listmaster {% if sympa_robot.listmaster is string %}{{ sympa_robot.listmaster }}{% else %}{{ sympa_robot.listmaster | join(',') }}{% endif %}
{% else %}
listmaster listmaster@{{ sympa_robot_domain }}
{% endif %}

{% if sympa_web_fcgi_enabled %}

# Web interface
wwsympa_url {{ sympa_web_fcgi_protocol }}://{{ item.web_domain | default(item.domain) }}/{{ sympa_web_path }}
cookie_domain {{ item.web_domain | default(item.domain) }}
wwsympa_url {{ sympa_web_fcgi_protocol }}://{{ sympa_robot.wwsympa_url | default(sympa_robot.web_domain) | default(sympa_robot_domain) }}/{{ sympa_web_path }}
cookie_domain {{ sympa_robot.wwsympa_url | default(sympa_robot.web_domain) | default(sympa_robot_domain) }}
{% endif %}

{% for robot_param,value in sympa_robot.items() %}

{% if not robot_param in ['domain', 'listmaster', 'wwsympa_url', 'web_domain'] %}

{% if value is mapping %}
# {{ robot_param }} value(s)
{% for sub_el,val in value.items() -%}
{{ robot_param }}.{{ sub_el }} {{ val }}
{% endfor %}
{% else %}
# {{ robot_param }} value
{{ robot_param }} {{ value }}
{%- endif %}
{%- endif %}
{%- endfor %}