mirror of
https://github.com/DO1JLR/ansible_playbook_servers.git
synced 2024-09-14 19:53:56 +02:00
Improve mailserver groups
This commit is contained in:
parent
cc475fe06d
commit
8d61560693
6 changed files with 86 additions and 31 deletions
4
roles/mailserver_preperation/README.md
Normal file
4
roles/mailserver_preperation/README.md
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
Requirements:
|
||||||
|
- unbound for dns from localhost
|
||||||
|
- rspamd... maybe
|
||||||
|
...
|
|
@ -1,12 +1,23 @@
|
||||||
---
|
---
|
||||||
set_additional_nameserver: true
|
|
||||||
additional_v4nameserver: '46.182.19.48'
|
|
||||||
additional_v6nameserver: '2a02:2970:1002::18'
|
|
||||||
additional_dns_maildomains: "{{ ansible_fqdn }}"
|
|
||||||
|
|
||||||
# which is the reverse dns and dns name of this mail server
|
# which is the reverse dns and dns name of this mail server
|
||||||
mailserver_domain: "{{ ansible_fqdn }}"
|
mailserver_domain: "{{ ansible_fqdn }}"
|
||||||
|
|
||||||
|
# configure proper dns resolution
|
||||||
|
set_additional_nameserver: true
|
||||||
|
additional_v4nameserver: '46.182.19.48'
|
||||||
|
additional_v6nameserver: '2a02:2970:1002::18'
|
||||||
|
|
||||||
|
# add additional entrys do your local /etc/hosts for the localhost entry
|
||||||
|
additional_dns_maildomains: "{{ mailserver_domain }}"
|
||||||
|
|
||||||
|
# mailser settings
|
||||||
|
mailserver__user: 'vmail'
|
||||||
|
mailserver__group: 'vmail'
|
||||||
|
mailserver__home: '/var/vmail'
|
||||||
|
mailserver__shell: '/bin/false'
|
||||||
|
|
||||||
|
|
||||||
mailserver__domains: []
|
mailserver__domains: []
|
||||||
# - fqdn: example.com
|
# - fqdn: example.com
|
||||||
|
|
||||||
|
|
30
roles/mailserver_preperation/tasks/hosts.yml
Normal file
30
roles/mailserver_preperation/tasks/hosts.yml
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
---
|
||||||
|
- name: "set {{ mailserver_domain }} as hostname"
|
||||||
|
become: true
|
||||||
|
hostname:
|
||||||
|
name: "{{ mailserver_domain }}"
|
||||||
|
|
||||||
|
- name: Add hostname to /etc/hosts
|
||||||
|
become: true
|
||||||
|
lineinfile:
|
||||||
|
dest: /etc/hosts
|
||||||
|
regexp: "^127.0.1.1"
|
||||||
|
line: "127.0.1.1 {{ inventory_hostname }} {{ ansible_hostname }} {{ additional_dns_maildomains }}"
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Set /etc/mailname
|
||||||
|
become: true
|
||||||
|
copy:
|
||||||
|
dest: "/etc/mailname"
|
||||||
|
content: "{{ mailserver_domain }}"
|
||||||
|
|
||||||
|
- name: set own dns resolver
|
||||||
|
become: true
|
||||||
|
template:
|
||||||
|
src: templates/resolve.conf.j2
|
||||||
|
dest: /etc/resolv.conf
|
||||||
|
mode: 0644
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
|
||||||
|
|
|
@ -2,33 +2,11 @@
|
||||||
- include_tasks: versioncheck.yml
|
- include_tasks: versioncheck.yml
|
||||||
when: submodules_versioncheck|bool
|
when: submodules_versioncheck|bool
|
||||||
|
|
||||||
- name: "set {{ inventory_hostname }} as hostname"
|
- name: configure local hostnames
|
||||||
become: true
|
include_tasks: hosts.yml
|
||||||
hostname:
|
|
||||||
name: "{{ inventory_hostname }}"
|
|
||||||
|
|
||||||
- name: Add hostname to /etc/hosts
|
- name: configure vmail user
|
||||||
become: true
|
include_tasks: user.yml
|
||||||
lineinfile:
|
|
||||||
dest: /etc/hosts
|
|
||||||
regexp: "^127.0.1.1"
|
|
||||||
line: "127.0.1.1 {{ inventory_hostname }} {{ ansible_hostname }} {{ additional_dns_maildomains }}"
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: Set /etc/mailname
|
|
||||||
become: true
|
|
||||||
copy:
|
|
||||||
dest: "/etc/mailname"
|
|
||||||
content: "{{ inventory_hostname }}"
|
|
||||||
|
|
||||||
- name: set own dns resolver
|
|
||||||
become: true
|
|
||||||
template:
|
|
||||||
src: templates/resolve.conf.j2
|
|
||||||
dest: /etc/resolv.conf
|
|
||||||
mode: 0644
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
|
|
||||||
- name: configure mariadb
|
- name: configure mariadb
|
||||||
include_tasks: mariadb.yml
|
include_tasks: mariadb.yml
|
||||||
|
|
32
roles/mailserver_preperation/tasks/user.yml
Normal file
32
roles/mailserver_preperation/tasks/user.yml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
---
|
||||||
|
- name: create mail group
|
||||||
|
group:
|
||||||
|
name: "{{ mailserver__group }}"
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Create mail user
|
||||||
|
become: true
|
||||||
|
user:
|
||||||
|
name: "{{ mailserver__user }}"
|
||||||
|
home: "{{ mailserver__home }}"
|
||||||
|
group: "{{ mailserver__group }}"
|
||||||
|
shell: "{{ mailserver__shell }}"
|
||||||
|
|
||||||
|
- name: Create mail user sieve directory
|
||||||
|
become: true
|
||||||
|
file:
|
||||||
|
path: "{{ mailserver__home }}/sieve/global"
|
||||||
|
state: directory
|
||||||
|
owner: vmail
|
||||||
|
group: vmail
|
||||||
|
mode: 0770
|
||||||
|
recurse: true
|
||||||
|
|
||||||
|
- name: Create mail user mailbox directory
|
||||||
|
bevome: true
|
||||||
|
file:
|
||||||
|
path: /var/vmail/mailboxes
|
||||||
|
state: directory
|
||||||
|
owner: vmail
|
||||||
|
group: vmail
|
||||||
|
mode: 0770
|
|
@ -1,3 +1,3 @@
|
||||||
---
|
---
|
||||||
playbook_version_number: 32 # should be int
|
playbook_version_number: 33 # should be int
|
||||||
playbook_version_path: 'role-mailserver_roles-ansile_github.com.version'
|
playbook_version_path: 'role-mailserver_roles-ansile_github.com.version'
|
||||||
|
|
Loading…
Reference in a new issue