-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from idsys-unibe-ch/feature/mrolli/3-support-se…
…nder_canonical-map Support sender_canoncial lookup tables
- Loading branch information
Showing
15 changed files
with
262 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
- name: Deploy different Postfix lookup tables | ||
|
||
hosts: all | ||
vars: | ||
postfix_sender_canonicals: | ||
- root: elmar.fudge@example.com | ||
- user1@test.com: road.runner@example.com | ||
postfix_sender_canonical_ldap_config: | ||
server_host: "ldap://ldap01.mycompany.com" | ||
start_tls: "yes" | ||
version: "3" | ||
bind: "no" | ||
search_base: "ou=users,dc=mycompany,dc=com" | ||
query_filter: "(uid=%s)" | ||
result_attribute: "mail" | ||
|
||
tasks: | ||
- name: "Include unibe_idsys.postfix" | ||
ansible.builtin.include_role: | ||
name: "unibe_idsys.postfix" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
role_name_check: 1 | ||
dependency: | ||
name: galaxy | ||
driver: | ||
name: podman | ||
platforms: | ||
- name: ${MOLECULE_DISTRO:-rockylinux9} | ||
image: "geerlingguy/docker-${MOLECULE_DISTRO:-rockylinux9}-ansible:latest" | ||
command: ${MOLECULE_DOCKER_COMMAND:-""} | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:rw | ||
cgroupns_mode: host | ||
privileged: true | ||
pre_build_image: true | ||
provisioner: | ||
name: ansible | ||
playbooks: | ||
converge: ${MOLECULE_PLAYBOOK:-converge.yml} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
--- | ||
- name: Verify the different lookup maps work correctly | ||
hosts: all | ||
gather_facts: false | ||
|
||
tasks: | ||
- name: Sender canonical for root is correctly set | ||
ansible.builtin.lineinfile: | ||
path: /etc/postfix/sender_canonical | ||
regexp: "^root\\s+elmar.fudge@example.com$" | ||
state: absent | ||
check_mode: true | ||
register: sender_canonical | ||
changed_when: false | ||
failed_when: not sender_canonical.found | ||
|
||
- name: Sender canonical for user1@test.com is correctly set | ||
ansible.builtin.lineinfile: | ||
path: /etc/postfix/sender_canonical | ||
regexp: "^user1@test.com\\s+road.runner@example.com$" | ||
state: absent | ||
check_mode: true | ||
register: sender_canonical | ||
changed_when: false | ||
failed_when: not sender_canonical.found | ||
|
||
- name: Check ldap-canonical.cf for option start_tls | ||
ansible.builtin.lineinfile: | ||
path: /etc/postfix/ldap-sender_canonical.cf | ||
regexp: "^start_tls = yes$" | ||
state: absent | ||
check_mode: true | ||
register: ldap_option | ||
changed_when: false | ||
failed_when: not ldap_option.found | ||
|
||
- name: Check ldap-canonical.cf for option result_attribute | ||
ansible.builtin.lineinfile: | ||
path: /etc/postfix/ldap-sender_canonical.cf | ||
regexp: "^result_attribute = mail$" | ||
state: absent | ||
check_mode: true | ||
register: ldap_option | ||
changed_when: false | ||
failed_when: not ldap_option.found | ||
|
||
- name: Check if both tables are in the sender_canonical_map | ||
ansible.builtin.lineinfile: | ||
path: /etc/postfix/main.cf | ||
regexp: "^sender_canonical_map = hash:/etc/postfix/sender_canonical, ldap:/etc/postfix/ldap-sender_canonical.cf$" | ||
state: absent | ||
check_mode: true | ||
register: ldap_option | ||
changed_when: false | ||
failed_when: not ldap_option.found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
- name: Manage configuration parameter file | ||
when: postfix_sender_canonical_ldap_config.server_host is defined | ||
notify: | ||
- reload-postfix | ||
block: | ||
- name: Prepare template variable | ||
ansible.builtin.set_fact: | ||
__postfix_config_params: "{{ postfix_sender_canonical_ldap_config }}" | ||
|
||
- name: Add table to sender_canonical_map in main.cf | ||
ansible.builtin.set_fact: | ||
__postfix_sender_canonical_maps: "{{ __postfix_sender_canonical_maps + ['ldap:{{ __postfix_sender_canonical_ldap_config_path }}'] }}" | ||
|
||
- name: "Manage entries in {{ __postfix_sender_canonical_ldap_config_path }}" | ||
ansible.builtin.template: | ||
src: "configfile.j2" | ||
dest: "{{ __postfix_sender_canonical_ldap_config_path }}" | ||
mode: 0644 | ||
|
||
- name: Remove mapping files | ||
when: postfix_sender_canonical_ldap_config.server_host is not defined | ||
notify: | ||
- reload-postfix | ||
block: | ||
- name: Remove map file | ||
ansible.builtin.file: | ||
path: "{{ __postfix_sender_canonical_ldap_config_path }}" | ||
state: absent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
- name: Manage mapping entries | ||
when: postfix_sender_canonicals | length > 0 | ||
notify: | ||
- rebuild_sender_canonical_db | ||
- reload-postfix | ||
block: | ||
- name: Prepare template variable | ||
ansible.builtin.set_fact: | ||
__postfix_mappings: "{{ postfix_sender_canonicals }}" | ||
|
||
- name: Add table to sender_canonical_map in main.cf | ||
ansible.builtin.set_fact: | ||
__postfix_sender_canonical_maps: "{{ __postfix_sender_canonical_maps + ['hash:{{ __postfix_sender_canonical_path }}'] }}" | ||
|
||
- name: "Manage entries in {{ __postfix_sender_canonical_path }}" | ||
ansible.builtin.template: | ||
src: "mapfile.j2" | ||
dest: "{{ __postfix_sender_canonical_path }}" | ||
mode: 0644 | ||
|
||
- name: Remove mapping files | ||
when: postfix_sender_canonicals | length == 0 | ||
notify: | ||
- reload-postfix | ||
block: | ||
- name: Remove map file | ||
ansible.builtin.file: | ||
path: "{{ __postfix_sender_canonical_path }}" | ||
state: absent | ||
|
||
- name: Remove db file | ||
ansible.builtin.file: | ||
path: "{{ __postfix_sender_canonical_path }}.db" | ||
state: absent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# {{ ansible_managed }} | ||
|
||
{% for param, value in __postfix_config_params.items() %} | ||
{{ param }} = {{ value }} | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# {{ ansible_managed }} | ||
|
||
{% for mapping in __postfix_mappings %} | ||
{% for key, value in mapping.items() %} | ||
{{ key }} {{ value }} | ||
{% endfor %} | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters