First commit

This commit is contained in:
chapeau 2024-09-06 21:26:58 +02:00
commit 960e480172
78 changed files with 3350 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.vault.key

15
README.md Normal file
View file

@ -0,0 +1,15 @@
## Ansible repo
Ces rôles ont été rédigés pour gérer mon infrastructure, sans être prévus pour plus de flexibilité. Je vous déconseille d'essayer de les réutiliser tels quels, mais n'hésitez pas à en récupérer des morceaux !
### Usage
Pour créer un nouveau LXC : copiez dans l'inventaire la config d'un autre LXC, en modifiant son hostname, son ip, et ses ressources si besoin. Son id sur proxmox sera (200 + [dernier octet de l'ip]). Puis `ansible-playbook all.yml -i inventory.yml`.
### Plan d'adressage
client.chapo.li: 10.255.1.0/24
hw.chapo.li: 10.255.2.0/24
vm.chapo.li: 10.255.3.0/24
gw.chapo.li: 192.168.1.0/24
wg.chapo.li: 172.31.0.0/24

38
all.yml Normal file
View file

@ -0,0 +1,38 @@
- hosts: localhost
roles:
- { role: proxmox, tags: proxmox }
- hosts: managed
gather_facts: false
roles:
- { role: users, tags: users }
- { role: basics, tags: basics }
- hosts: dns
roles:
- { role: dns, tags: dns }
- hosts: docker
roles:
- { role: docker, tags: docker }
- hosts: grafana
roles:
- { role: grafana, tags: grafana }
- hosts: mail
roles:
- { role: mail, tags: [ never, mail ] }
- hosts: backup
roles:
- { role: backup, tags: backup }
# - hosts: acme
# roles:
# - role: certbot-dns
# tags: acme
# vars:
# cert:
# name: "{{ acme_domain }}"
# alias: "{{ acme_alias|default([]) }}"

2
ansible.cfg Normal file
View file

@ -0,0 +1,2 @@
[persistent_connection]
command_timeout = 30

15
group_vars/all.yml Normal file
View file

@ -0,0 +1,15 @@
users:
- username: chapeau
pubkeys: |
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBq5W7km9DCODGY2PCmvhxpI48MAC/OFB6qxr0+IGka6 chapeau@sonya
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDVo0afJGYBXBOrg8vyfF8V3S39ffyGIR7GEb0e2BPEaMFdIaVzQ8rThfoRdMeqeGaNdVCixjbW1T22OKGpecGVEEaS5QBCFK+01dB0mvRWIMWXhKJssduBnN8lLdScmsCzHBWV4/49YI090dn1r/I6AuYfghnYDTzlpcaPS+GZ+NQd6an/tWSGd5lnvSSJmE5XmYxfzXa7d3HjI55BsC8ELsOGhKd8Odnw2x8HSwOwvjEfmfjfdDxqxeBXVCO85ZXN9XTuB60PRrpMmUKrATMyHnWnhhQ7x9t6Vq/2CAGYUvJ8jQFGQlsczCpB6QRTbVI44TNo5lVFK2V6H5Q+dGGt
tsig_secret: !vault |
$ANSIBLE_VAULT;1.1;AES256
30336261386531323332306131356334343636363137326165313031346636333736646563636232
3362383734353337633466643466666163313133363437620a643132656530623065346133303939
34323736626335616536373964376465303930366462333162663565383634346536386637336137
3833616632373431350a383637386466386330626130653233663338613464363963346433623832
66313663353631616661303263386633336161666638353130376334333933363436633663643930
3435323461346162333738376437323430313536376234636531
certbot_dns_server: 10.255.3.2

25
group_vars/backup.yml Normal file
View file

@ -0,0 +1,25 @@
healthcheck_key: !vault |
$ANSIBLE_VAULT;1.1;AES256
38323736393330396431333130356230646465353236626236353435336133313037306439396636
6635643631303766373263643863346361356463303434300a353935653334636231363062636530
63326434393036616466633234616135303730376434383631373134623862336535653339346266
3934396233316532660a363461616531353633646132663833313533633534366232623537383138
31643961393737613537306433653362613537326530623630646364656331623937
restic_password: !vault |
$ANSIBLE_VAULT;1.1;AES256
36323932383164393831383731386638366234383730303234636166616532646239396165653033
3030633165393137383237323339646237663366663630340a323432336333393739616532316530
38663961633130386664666134663633343535336562343366636663313730303138313764373632
6437626434623963300a623737366333356532346332653838636562663462336339646165343330
30303530323232643732666463653533376664333462316636323537396565643838623734303766
3862396237333634323262616633353336643734636336656133
restic_repo: s3:http://jung.vm.chapo.li:9000
restic_minio_key: !vault |
$ANSIBLE_VAULT;1.1;AES256
65616536396231356138346565633861396133363035376235363562313238656233366263396432
3036383532653561643266303937646666313263656136330a306331353163356437643231646266
30396530306533626166643334383934366439396134323031326631363261653638623337313831
3033633762373437640a396438316539353330353662323066323761333838643832393261616335
64366337346365666661303931623538353434336530326561393739333666666638396239653538
3635336533363534323731636361623933623539663433353430

17
group_vars/dns.yml Normal file
View file

@ -0,0 +1,17 @@
soa: dns.chapoline.me
dns_mail: me.chapoline.me
secondaries:
- '127.0.0.1'
zone_list:
- name: client.chapo.li
records: []
- name: hw.chapo.li
records: []
- name: vm.chapo.li
records: []
- name: gw.chapo.li
records: []
- name: wg.chapo.li
records: []

27
group_vars/mail.yml Normal file
View file

@ -0,0 +1,27 @@
mail:
external_hostname: smtp.chapoline.me
roundcube_db_password: !vault |
$ANSIBLE_VAULT;1.1;AES256
39353861626231303564633834313462313064663339356262323431626432313539363265303230
6662633863643662366166303737326265663866313434390a356337373465653865613065393231
61663431646537343263666535626663306564333335623965336163303737643963656666666265
3161373436663263330a626666633464326563633465396331356338636161333065363161383833
6632
des_key: !vault |
$ANSIBLE_VAULT;1.1;AES256
33323837383564316433386532613334336430376433303731333062616661623338383639383164
3839333739643235646133643638313130656632303236340a666337353536613932313761303536
65636366346334383266373063646630613162366564336461613138626336303961646233373932
3834366131333663620a626263653233313266376533353161623833366639323364616565616634
64666639656436313763306133303137313036633461666461356235313764353563
rspamd_admin_hash: !vault |
$ANSIBLE_VAULT;1.1;AES256
35623765393030313665636563326262363133333565393862336439333265343533323163613765
3237393265353163323264653738363938363132333636610a316330303562613234353463343564
36613032386563383965343539666439316334643930373738333631303364363735343338636361
3436333939393061300a316136613832336431306463356136356138636563646432386537333263
39356336363461656431316339313637656239666563363938646432313364633538313461646163
34303032323866353962383761383831653161343164353632326333643466343961633461663234
61356539306562346339626236663033313866343937313038653963666365303862653765633136
30633237346263313134363361326131396661646466353732613362613965613964376634653138
6166

10
group_vars/nginx.yml Normal file
View file

@ -0,0 +1,10 @@
nginx:
vhost:
- name: grafana.truc
alias: []
ssl: True
redirect: False
location:
- route: "/"
dest: "proxy_pass http://grafana.home:3000;"
ws: False

198
inventory.yml Normal file
View file

@ -0,0 +1,198 @@
all:
vars:
ansible_python_interpreter: /usr/bin/python3
lxc:
hosts:
dns.vm.chapo.li:
ansible_host: 10.255.3.1
resources: { cpu: 1, ram: 1024, swap: 1024, disk: 16 }
dns_local: True
dns-ext.vm.chapo.li:
ansible_host: 10.255.3.2
resources: { cpu: 1, ram: 1024, swap: 1024, disk: 16 }
dns_local: False
cloud.vm.chapo.li:
ansible_host: 10.255.3.3
resources: { cpu: 4, ram: 8192, swap: 1024, disk: 256 }
grafana.vm.chapo.li:
ansible_host: 10.255.3.4
resources: { cpu: 1, ram: 1024, swap: 1024, disk: 64 }
cname: [ prometheus.vm.chapo.li ]
galene.vm.chapo.li:
ansible_host: 10.255.3.5
resources: { cpu: 1, ram: 1024, swap: 1024, disk: 8 }
vault.vm.chapo.li:
ansible_host: 10.255.3.6
resources: { cpu: 1, ram: 1024, swap: 1024, disk: 32 }
health.vm.chapo.li:
ansible_host: 10.255.3.7
resources: { cpu: 1, ram: 1024, swap: 1024, disk: 8 }
cryptpad.vm.chapo.li:
ansible_host: 10.255.3.8
resources: { cpu: 2, ram: 2048, swap: 1024, disk: 128 }
cryptpad-cse.vm.chapo.li:
ansible_host: 10.255.3.9
resources: { cpu: 2, ram: 2048, swap: 1024, disk: 128 }
wikijs.vm.chapo.li:
ansible_host: 10.255.3.10
resources: { cpu: 1, ram: 2048, swap: 1024, disk: 16 }
git.vm.chapo.li:
ansible_host: 10.255.3.11
resources: { cpu: 2, ram: 1024, swap: 1024, disk: 64 }
bot.vm.chapo.li:
ansible_host: 10.255.3.12
resources: { cpu: 1, ram: 1024, swap: 1024, disk: 8 }
todo.vm.chapo.li:
ansible_host: 10.255.3.13
resources: { cpu: 1, ram: 1024, swap: 1024, disk: 16 }
mail.vm.chapo.li:
ansible_host: 10.255.3.14
resources: { cpu: 1, ram: 1024, swap: 1024, disk: 32 }
xmpp.vm.chapo.li:
ansible_host: 10.255.3.15
resources: { cpu: 1, ram: 1024, swap: 1024, disk: 32 }
sharkey.vm.chapo.li:
ansible_host: 10.255.3.16
resources: { cpu: 4, ram: 4096, swap: 1024, disk: 128 }
vars:
ansible_user: root
managed:
children:
lxc:
hosts:
gandalf.hw.chapo.li:
ansible_host: 10.255.2.1
dns:
hosts:
dns.vm.chapo.li:
dns-ext.vm.chapo.li:
grafana:
hosts:
grafana.vm.chapo.li:
mail:
hosts:
mail.vm.chapo.li:
docker:
hosts:
cloud.vm.chapo.li:
vault.vm.chapo.li:
health.vm.chapo.li:
cryptpad.vm.chapo.li:
cryptpad-cse.vm.chapo.li:
wikijs.vm.chapo.li:
git.vm.chapo.li:
todo.vm.chapo.li:
sharkey.vm.chapo.li:
backup:
hosts:
vault.vm.chapo.li:
backup:
pre_hook: [ "docker compose -f /root/vaultwarden/docker-compose.yml down" ]
paths: [ "/root/vaultwarden/data" ]
post_hook: [ "docker compose -f /root/vaultwarden/docker-compose.yml up -d" ]
cryptpad.vm.chapo.li:
backup:
pre_hook: [ "docker compose -f /root/docker-compose.yml down" ]
paths: [ "/root/data" ]
post_hook: [ "docker compose -f /root/docker-compose.yml up -d" ]
git.vm.chapo.li:
backup:
pre_hook:
- docker exec -u git -it -w /tmp forgejo bash -c 'forgejo dump --file /tmp/forgejo.zip'
- docker cp forgejo:/tmp/forgejo.zip /tmp
- docker exec -u git -it -w /tmp forgejo bash -c 'rm /tmp/forgejo.zip'
- mkdir /tmp/backup
- unzip /tmp/forgejo.zip -d /tmp/backup
- docker exec forgejo-db-1 pg_dump -U forgejo > /tmp/backup/pgdump.sql
paths: [ "/tmp/backup" ]
post_hook: [ "rm -r /tmp/backup" ]
todo.vm.chapo.li:
vikunja_password: !vault |
$ANSIBLE_VAULT;1.1;AES256
31653361396266666232303366643335343061383331383063356131653739623037353735666633
6365303139613334633536363466616262356261643831660a616338316339656638396164666530
36653538313537373539656362313638386531393039323738633466323132346636643061373330
3266333762623739380a653362656232323165616263366264653834653938366463333361666465
3465
backup:
pre_hook:
- docker exec -i -w /tmp vikunja-db-1 bash -c 'mysqldump --password={{ vikunja_password }} vikunja > /tmp/vikunja-backup.sql'
- docker cp vikunja-db-1:/tmp/vikunja-backup.sql /tmp
- docker exec -i -w /tmp vikunja-db-1 bash -c 'rm /tmp/vikunja-backup.sql'
paths: [ /root/vikunja/files /tmp/vikunja-backup.sql ]
post_hook: [ "rm -r /tmp/vikunja-backup.sql" ]
mail.vm.chapo.li:
backup:
pre_hook: []
paths: [ /data/vmail ]
post_hook: []
xmpp.vm.chapo.li:
backup:
pre_hook: []
paths: [ /var/lib/prosody ]
post_hook: []
sharkey.vm.chapo.li:
backup:
pre_hook: [ "docker exec -it sharkey-db-1 pg_dump firefish --user example-firefish-user --format=plain > /tmp/sharkey.sql" ]
paths: [ "/root/sharkey/files", "/tmp/sharkey.sql" ]
post_hook: [ "rm /tmp/sharkey.sql" ]
unmanaged:
hosts:
freebox.gw.chapo.li:
ansible_host: 192.168.1.254
cirdan.gw.chapo.li:
ansible_host: 192.168.1.250
cirdan.client.chapo.li:
ansible_host: 10.255.1.254
cirdan.hw.chapo.li:
ansible_host: 10.255.2.254
cirdan.vm.chapo.li:
ansible_host: 10.255.3.254
cirdan.wg.chapo.li:
ansible_host: 172.31.0.254
amber.wg.chapo.li:
ansible_host: 172.31.0.128
dillon.vm.chapo.li:
ansible_host: 10.255.3.100
jung.vm.chapo.li:
ansible_host: 10.255.3.101
localhost:
ansible_connection: local

View file

@ -0,0 +1,24 @@
- name: Install restic
apt:
pkg:
- restic
- curl
- name: Template backup.sh
template:
src: backup.sh.j2
dest: /root/backup.sh
mode: 0755
- name: Template creds
template:
src: creds.j2
dest: /root/creds
mode: 0600
- name: Setup cron
cron:
name: Backup
minute: 0
hour: 4
job: /root/backup.sh

View file

@ -0,0 +1,39 @@
#!/bin/bash
info() { printf "\n%s %s\n\n" "$( date )" "$*" >&2; }
trap 'echo $( date ) Backup interrupted >&2; exit 2' INT TERM
info "Starting backup"
. creds
# Prehook start
{% for cmd in backup.pre_hook %}
{{ cmd }}
{% endfor %}
# Prehook end
restic backup {% for path in backup.paths %}{{ path }} {% endfor %}
backup_exit=$?
restic forget --prune --keep-daily 7 --keep-weekly 4 --keep-monthly 12
prune_exit=$?
# Posthook start
{% for cmd in backup.post_hook %}
{{ cmd }}
{% endfor %}
# Posthook end
# use highest exit code as global exit code
global_exit=$(( backup_exit > prune_exit ? backup_exit : prune_exit ))
if [ ${global_exit} -eq 0 ]; then
info "Backup and Prune finished successfully"
curl -m 10 --retry 5 https://health.chapoline.me/ping/{{ healthcheck_key }}/{{ (inventory_hostname|split("."))[0] }}?create=1
elif [ ${global_exit} -eq 1 ]; then
info "Backup and/or Prune finished with warnings"
curl -m 10 --retry 5 https://health.chapoline.me/ping/{{ healthcheck_key }}/{{ (inventory_hostname|split("."))[0] }}/1?create=1
else
info "Backup and/or Prune finished with errors"
curl -m 10 --retry 5 https://health.chapoline.me/ping/{{ healthcheck_key }}/{{ (inventory_hostname|split("."))[0] }}/2?create=1
fi
exit ${global_exit}

View file

@ -0,0 +1,4 @@
export RESTIC_PASSWORD={{ restic_password }}
export RESTIC_REPOSITORY={{ restic_repo }}/{{ (inventory_hostname|split("."))[0] }}
export AWS_ACCESS_KEY_ID=backup
export AWS_SECRET_ACCESS_KEY={{ restic_minio_key }}

View file

@ -0,0 +1,24 @@
- name: Install some things
apt:
pkg:
- bash-completion
- unattended-upgrades
- ca-certificates
- ldnsutils
- htop
- net-tools
- tcpdump
- git
- apt-dater-host
update_cache: true
become: true
- name: Generate apt-dater config
local_action:
module: template
src: host.xml.j2
dest: ~/docker-apt-dater/hosts.d/host.xml
run_once: True

View file

@ -0,0 +1,11 @@
<group name="LXC">
{% for host in groups['lxc'] %}
<host ssh-user="chapeau" name="{{ host }}" ssh-host="{{ hostvars[host].ansible_host }}"/>
{% endfor %}
</group>
<group name="Autres">
{% for host in groups['managed'] | difference(groups['lxc']) %}
<host ssh-user="chapeau" name="{{ host }}" ssh-host="{{ hostvars[host].ansible_host }}"/>
{% endfor %}
</group>

View file

@ -0,0 +1,12 @@
usage:
```yml
- name: Install real certs
ansible.builtin.include_role:
name: certbot-dns
loop:
- name: example.vm.chapo.li
alias: [ cname.vm.chapo.li ]
loop_control:
loop_var: cert
```

View file

@ -0,0 +1,29 @@
- name: Install certbot
apt:
pkg:
- certbot
- python3-certbot-dns-rfc2136
- name: Deploy secret file
template:
src: dns-secret.ini.j2
dest: /root/dns-secret.ini
mode: 0600
- name: Query lets encrypt certificate
shell: 'letsencrypt certonly -n --dns-rfc2136 --dns-rfc2136-credentials /root/dns-secret.ini -m {{ letsencrypt_email|default("me@chapoline.me") }} --expand --agree-tos -d {{ cert.name }} {% for a in cert.alias %} -d {{a}}{% endfor %} --deploy-hook "{{ cert.renewal_hook }}"'
ignore_errors: true
- name: Create a few symbolic links
file:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
state: link
force: true
loop:
- src: "/etc/letsencrypt/live/{{ cert.name }}/privkey.pem"
dest: "/etc/ssl/private/{{ cert.name }}.key"
- src: "/etc/letsencrypt/live/{{ cert.name }}/cert.pem"
dest: "/etc/ssl/private/{{ cert.name }}.crt"
- src: "/etc/letsencrypt/live/{{ cert.name }}/fullchain.pem"
dest: "/etc/ssl/private/{{ cert.name }}.chain.crt"

View file

@ -0,0 +1,12 @@
# Target DNS server (IPv4 or IPv6 address, not a hostname)
dns_rfc2136_server = {{ certbot_dns_server }}
# Target DNS port
dns_rfc2136_port = 53
# TSIG key name
dns_rfc2136_name = letsencrypt.
# TSIG key secret
dns_rfc2136_secret = {{ tsig_secret }}
# TSIG key algorithm
dns_rfc2136_algorithm = HMAC-SHA256
# TSIG sign SOA query (optional, default: false)
dns_rfc2136_sign_query = false

View file

@ -0,0 +1,5 @@
- name: Restart bind9
service:
name: bind9
state: restarted
when: check1.failed == false

88
roles/dns/tasks/main.yml Normal file
View file

@ -0,0 +1,88 @@
- name: Generate zone var
set_fact:
zones: |
{%- set r = [] -%}
{%- for z in zone_list -%}
{%- set rec = [] -%}
{%- for h in groups['all'] -%}
{%- if z.name == h[-(z.name|length):] and 'ansible_host' in hostvars[h] -%}
{%- set _ = rec.append({
"name": h,
"ip": hostvars[h]['ansible_host']
}) -%}
{%- for c in hostvars[h]['cname']|default([]) -%}
{%- set _ = rec.append({
"name": c,
"ip": h + ".",
"type": "CNAME"
}) -%}
{%- endfor -%}
{%- endif -%}
{%- endfor -%}
{%- set _ = r.append({
"name": z.name,
"records": rec
}) -%}
{%- endfor -%}
{{ r }}
when: dns_local
- name: Install bind
apt:
pkg:
- bind9
- bind9-utils
- ldnsutils
update_cache: true
- name: Create zones directory
file:
path: /etc/bind/master
state: directory
owner: bind
group: bind
mode: 0755
notify: Restart bind9
- name: Create named.conf
template:
src: named.conf.j2
dest: /etc/bind/named.conf
notify: Restart bind9
- name: Create named.conf.local
template:
src: named.conf.local.j2
dest: /etc/bind/named.conf.local
notify: Restart bind9
- name: Create named.conf.options
template:
src: named.conf.options.j2
dest: /etc/bind/named.conf.options
notify: Restart bind9
- name: Create log directory
file:
path: /var/log/named
state: directory
owner: bind
group: bind
mode: 0755
notify: Restart bind9
- name: Create zone files
template:
src: db.j2
dest: "/etc/bind/master/{{ item.name }}.db"
mode: 0644
owner: bind
group: bind
loop: "{{ zones|default(zone_list) }}"
notify: Restart bind9
# - name: Create reverse zone files
- name: Check configuration integrity
shell: "named-checkconf -zj /etc/bind/named.conf"
register: check1

14
roles/dns/templates/db.j2 Normal file
View file

@ -0,0 +1,14 @@
$ORIGIN {{ item.name }}.
$TTL {{ item.ttl|default('60') }}
@ IN SOA {{ soa }}. {{ dns_mail }}. (
{{ now().timestamp()|round|int }} ; serial
3600 ; refresh
1800 ; retry
3600000 ; expire
3600 ) ; minimum TTL
;
@ IN NS {{ soa }}.
;
{% for record in item.records|default([]) %}
{{ "{:30}".format(record.name[:(record.name|length)-(item.name|length)-1]) }} IN {{ "{:5}".format(record.type|default('A')) }} {{ record.ip }}
{% endfor %}

View file

@ -0,0 +1,2 @@
include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";

View file

@ -0,0 +1,31 @@
{% if not dns_local %}
key "letsencrypt" {
algorithm hmac-sha256;
secret "{{ tsig_secret }}";
};
{% endif %}
view "internal" {
match-clients { internals; };
{% for zone in zones|default(zone_list) %}
zone "{{ zone.name }}" IN {
type primary;
notify yes;
file "/etc/bind/master/{{ zone.name }}.db";
{% if not dns_local %}
update-policy {
grant letsencrypt zonesub txt;
};
{% endif %}
};
{% endfor %}
};
view "public" {
{% for zone in zones|default(zone_list) %}
zone "{{ zone.name }}" IN {
in-view internal;
};
{% endfor %}
};

View file

@ -0,0 +1,43 @@
acl "secondaries" {
{% for ip in secondaries %}
{{ ip }};
{% endfor %}
};
acl "internals" {
localnets;
10.0.0.0/8;
172.16.0.0/12;
192.168.0.0/16;
127.0.0.0/8;
};
options {
directory "/var/cache/bind";
recursion yes;
auth-nxdomain no;
listen-on { any; };
listen-on-v6 { none; };
allow-transfer { secondaries; };
allow-query { internals; };
allow-query-cache { internals; };
allow-recursion { internals; };
also-notify { {{ secondaries|join("; ") }}; };
version none;
querylog yes;
};
logging {
channel querylog {
file "/var/log/named/querylog";
severity debug 3;
print-time yes;
};
category queries { querylog; };
};

View file

@ -0,0 +1,30 @@
# Docker installation
# Following https://docs.docker.com/engine/install/debian/
- name: Install docker dependencies
ansible.builtin.apt:
pkg:
- ca-certificates
- curl
- gnupg2
update_cache: true
- name: Add Docker apt key
ansible.builtin.apt_key:
url: https://download.docker.com/linux/debian/gpg
state: present
- name: Add Docker source to apt
ansible.builtin.template:
src: docker.list.j2
dest: /etc/apt/sources.list.d/docker.list
- name: Install Docker
ansible.builtin.apt:
pkg:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-buildx-plugin
- docker-compose-plugin
update_cache: true

View file

@ -0,0 +1 @@
deb https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable

View file

@ -0,0 +1,9 @@
- name: Restart prometheus
service:
name: prometheus
state: restarted
- name: Restart nginx
service:
name: nginx
state: restarted

View file

@ -0,0 +1,56 @@
- name: Install dependencies
ansible.builtin.apt:
pkg:
- ca-certificates
- curl
- gnupg2
update_cache: true
- name: Add grafana apt key
ansible.builtin.apt_key:
url: https://apt.grafana.com/gpg.key
state: present
- name: Add grafana source to apt
ansible.builtin.template:
src: grafana.list.j2
dest: /etc/apt/sources.list.d/grafana.list
- name: Install Prometheus and Grafana
apt:
pkg:
- prometheus
- grafana
- nginx
update_cache: true
- name: Deploy prometheus config
ansible.builtin.template:
src: prometheus.yml.j2
dest: /etc/prometheus/prometheus.yml
notify: Restart prometheus
- name: Deploy nginx configuration
ansible.builtin.template:
src: grafana.conf.j2
dest: /etc/nginx/sites-enabled/grafana.conf
notify: Restart nginx
- name: Install self-signed certs
ansible.builtin.include_role:
name: openssl
loop:
- name: "{{ inventory_hostname }}"
alias: "{{ cname }}"
loop_control:
loop_var: cert
- name: Install real certificates
include_role:
name: certbot-dns
loop:
- name: "{{ inventory_hostname }}"
alias: "{{ cname }}"
renewal_hook: "systemctl restart nginx"
loop_control:
loop_var: cert

View file

@ -0,0 +1,72 @@
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream grafana {
server localhost:3000;
}
server {
listen 0.0.0.0:80 ;
listen [::0]:80 ;
server_name {{ inventory_hostname }} {{ cname[0] }} ;
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 0.0.0.0:443 http2 ssl ;
listen [::0]:443 http2 ssl ;
server_name {{ inventory_hostname }} ;
ssl_certificate /etc/ssl/private/{{ inventory_hostname }}.chain.crt;
ssl_certificate_key /etc/ssl/private/{{ inventory_hostname }}.key;
ssl_trusted_certificate /etc/ssl/private/{{ inventory_hostname }}.crt;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
ssl_stapling on;
ssl_stapling_verify on;
include mime.types;
location / {
proxy_set_header Host $host;
proxy_pass http://grafana;
}
# Proxy Grafana Live WebSocket connections.
location /api/live/ {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_pass http://grafana;
}
}
server {
listen 0.0.0.0:443 http2 ssl ;
listen [::0]:443 http2 ssl ;
server_name {{ cname[0] }} ;
ssl_certificate /etc/ssl/private/{{ inventory_hostname }}.chain.crt;
ssl_certificate_key /etc/ssl/private/{{ inventory_hostname }}.key;
ssl_trusted_certificate /etc/ssl/private/{{ inventory_hostname }}.crt;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
ssl_stapling on;
ssl_stapling_verify on;
include mime.types;
location / {
proxy_set_header Host $host;
proxy_pass http://localhost:9090/;
}
}

View file

@ -0,0 +1 @@
deb https://apt.grafana.com stable main

View file

@ -0,0 +1,45 @@
# Sample config for Prometheus.
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager).
external_labels:
monitor: 'example'
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets: ['localhost:9093']
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'
# Override the global default and scrape targets from this job every 5 seconds.
scrape_interval: 5s
scrape_timeout: 5s
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['0.0.0.0:9090']
- job_name: proxmox
metrics_path: /pve
params:
target: ['gandalf.hw.chapo.li']
static_configs:
- targets: ['gandalf.hw.chapo.li:9221']

View file

@ -0,0 +1,51 @@
$ANSIBLE_VAULT;1.1;AES256
36353065306361613936366637383861373334336261303339666232306162386432393133386639
3065323565353738333632643164353931346535373332330a623433303066376436323461343531
31626166633633633066656637396661613761383664336135306661353661353330626232323262
3333626339343765350a303034366264616434383635366166346361626561303261613762646463
35366566336536626465366166343236663133646633313336653331346462383536303063333732
34346662313130366333393962653136356234636134613536376565643037323966396465353363
37306137323730363738333630333838323038376231623039666163333366313439373330343230
62623063333436313039363236656465353065306661333861303838363036336638316432336637
61613532383039666631656537336133326438356337666138353461353163363235353366333132
63313739336331643566303061643135633135333462336462356239636236323236333565353435
35323335636136646339313734643961366363323363663164363064633239646365323235393862
35333239616134333166386364643839373861656437303931383262636632336466383238326566
31336363633462313434646133356430633630383365366135386464303365626165333636623562
62336465363339353138303166656462306466363764323236613236376339366464306230393033
62383135366132393662376439373532323236643661373332316433386631633032663262663837
63333935646162323561343138373134373431393861396463333831396339326239663939336364
62653061346266376139326639316630323932623164353564386237313732623463636632353963
65386335373661363662626565656465396130363338613937633464396331373233353432303531
30666263643861636234626632616261326462656438356265373432306264346163643263643366
61346565353361396166376466613237646631343065383562353565316134643765336132633466
30316163303665626662356239306235346439393732653934343264343131363036623561393337
33323334353837333936626630363765303637636235303737323438363738373863616639633131
63346333343664316364396638323532303539656237613939376430396166643134636361313266
62326363316331653130346563616164323464363135653035303934323266613064636239343062
37306365633034623964393531363734333534336363613061313464616331633265396131333038
38353038346433386336356133323238366566376535393862636462383866316463313933323735
30356337353836373336653535666164373236343932306164663165646136613139666134653232
36623061313663656333653935353239346439346539333264663835666263653864306432643237
65336134616236393736643530306236646235633961316662653231346135386165666632383763
37303161336632353536333564336562666533633565373664366263636537333231613334653634
66626335336562383766303865366438306630363935316534373435316236396433393165353639
32303631353630636264396261646439653866306230363237643238373836306263623764646531
31353165636238666236313139666133633730333162656231633336323034383835613833336361
61393561613738313062653933383163376135323838373062313565383336376663303566323365
35623337353635356661313239376233633339643464663565633638303933633236613835346438
35303463356335343134306163393464393662373161313932326131643264623162363931356435
65356564623036353564636631396363393930313833383232633634343436303939316433623864
34346465383838326362666661646537393530613037303034623062363933306336323831623733
65333761393337346531653136393363343762653065316161633237356432323466326130383461
36353434346366386166326536346136336466373632343039313232623432663331623531356666
63626465376538663665613563646435343361613766353438636565373236346631323663336238
38653766353338623333356135653137356431616463376337353063323533396234663234383233
39643031316233303136616632643439656632316531663335376238613031653036646463333132
36343936613936333562643338636565316235613665613064356133303433656632376230663436
34666365303364303835356365393932373934623062613530663536653537363837613633356331
33386130616333303030316662333163363736383637303334366339363339316162623137353965
34326435653331353735326139343834613831633835333362346136343838343966616532636135
34376130393131633930383963343362623435333464326137616235666533303962386564663538
34613630336465326137393462616563366438663361663165333030643830336136383534613330
3566663038383139303236373037653564663332323063313637

View file

@ -0,0 +1,51 @@
$ANSIBLE_VAULT;1.1;AES256
34373038383865303365643833333365336234336433306163316438343635613762616239633661
6436323136396232336238633530396130633238643934300a323162663336373362616132383366
31626131326462306232646239306161393438386435656237346530623236336464646264356438
3436653965393366300a343333653862356465633234373935383338336239386566373736623133
35653364383435376531653337356138323863623636303335373934366534613930346633356630
39316266303138353062313364353234653330313163646132626338363966323334306266653163
65396362626566666564366337643766633034613732666537663734383138646133333166303466
34326538303361343631323339323137336634366133303265623631316335383537343930623363
63336466623766383765616430633665326565643232343830613830626330303239346136326338
38396666623163313363303736313936616135373463376364666536366334626131343833373736
66333463336435343066373538623538656236313335383530383737373838643932386338613136
66323865666438646464663462313366653238306338653838393939643463623233333564653963
31646532366530386565313564623035373664653433323965333861363730666565643531383137
63376464376534373235303836666364336638366164316639623061396562626232366131386634
31303636373835396235613036343966396434366264653263333265346664306632353134363331
37383938336139633338346437613832323236363030326536666565333838333032356135616331
33346662623833653861646330343965313633653539666430633033373333376334323863333739
38653563343564313730633761323264613663353131653964376230333438663935383034323332
63323139313662616261393834396134663265333732303839333961306439333937363161353136
33353433346432343537376337316166613239346536326337303639363435636336326465343132
39653633316437343662396366386339636132303238366632363633633632396430343036353833
34323939636163393066616134313830643537626437353563343963303865323262333635346361
34373865346162623039383030613161643962343031666536396461323363366631383236333536
64343535306664623834646239343762613439326466393533373538363137643665333036393430
66376561326337363536653965643561333837623032346437333565363862316534653438326362
62376164626266396132663939643562356538333739303061313538343832313234623961323235
38383037383462653331323436326461636237623661363032353735633433336464333239323866
62643539333164343365626535393538336337373163366564313933613137363166333566613331
66303032363862356438623230323330323963626237336463356665393337643731663837393762
31616433303364623065626130653466663831636166653462363264623462343530376236646637
36343534353864396162386634353738633063323064326233383237363163323063376231366430
32326431613462316437643664333962633562623238626433323039623964643134346238303035
39623763306231643131363033613762633333396362653132653966303931653036626330383166
37323339303139643966383736643263653034633334376533303235313936616666653265336531
36643565316532663963616566643133353737333632653262666535316262613130306463316665
38666534313033383461366239383731663165646432636238386365633235343863383038643638
62613463363133303931363763386131633838396562366565633336636636333339623838616439
63373739353863376437636436663231356364333039333937653366666130643438313865326235
63356138303039613539636662386537353031663666316434363361313033373461356662663562
63343237326639356365613162336537613864633366393830303763633032646339386636633766
63396162386331636234373835326635326233343265356134623866666430346535636534633930
64626533373861613434313830373434383066613761653831616138346335636136303333303562
32356437313364633164313732613230653636386635313533323861333735333361616634303733
65663539656335383065643334626234373232386262323638636563653037323630646333376634
34613837343836666434393639616634616632633264333437663536333263656466353939373535
38386230656264613830323634373061376463663438373334303034323232323037373032343633
32303363323938653632343330626465313666313363393331383435346362303230356561333838
63626565386464376163353562303837396133316161323735383164666534663733363861613838
65316531386635303764393936366132396332333032633562323332636562653135653864343266
3335663761303762623536613436383264373830663034643539

View file

@ -0,0 +1,17 @@
$ANSIBLE_VAULT;1.1;AES256
61643135343633303439303132663361613766396535393363633030643632323461376564393164
3564613065373637656431616331663364653064356265350a653961323737336233363163323538
35623437373066306232666263356438396433366136663035366438323561333237386364306664
6566613638326661620a323564343035356136363138353437316232616637663539346638653236
65316663313461363261333833666338663233346339653635613764316363306232356566333065
36373132323034363531363132623631633833666534333435623938623966623634306231366332
31623463373065336539396338343831386663363831373035383932353935326131356562363262
37383266623431353963353535343435356366303733643236396533613631306164663333373261
61636330313437623638363863666638613264346131323865653135626162373962633637346430
37383934353563383631383235613834306166343861653730616337353731653338393762663832
63383533616235306133663161343434363538303765353236643039393933656163343963646236
30313738656630363061623261376266666433393539653738633034393433313431333137353732
37353530623431383939626331353566623564306439666131646536643136613830613332313835
33656635646336646334353932316133356535353038383434633835343663356632613732363237
35626162333234326432646136663634376666396365303163303433343831643835663963386562
63343462383066303331

View file

@ -0,0 +1 @@
mail.chapoline.me

View file

@ -0,0 +1,31 @@
$ANSIBLE_VAULT;1.1;AES256
62313664313865343438613834613262653332616165623932643164623037396235383263346631
3664343331386362333464666163623065616633303735300a636338666232616638626134646537
30363864613465343562646562633362653861353862633834396366366237356366316635343264
6435313033646135330a346664303830393962353734303866623261343835623833376261323938
66636439353263333530336137323239663566363561653232376662316138343230386363643130
65303166313839323266613536386361376139356630336437623963346434643763306134303363
36396565313239336631323137336136663338366331636462303762666339376662613434336232
61363039323161303133383534356433626562656162313134366232646530666135383337383938
31323734343264343337366432346635383336663435323732313965323434333865663631386331
62653934366266386531663433656161646161323266373134623164373363383030643339306437
62323330313764316339626333626632663234333833386630626263363339646636376636666431
39326462393861316236323534396633656664326331336136303361616362663164646236613764
35303361373239313636306232346361303430393763373132626364313466343239303736363666
37646165663862653634633330626235363164326264373662363036323964626639323233623430
31373564393237386630313835353532643838346239646235633866613364326339663631663363
39323038616466346231303461386236366464623665376136633333346433326465643036393964
32373232623662643161333166383439303462343231386436306665336134333262323636336138
30663734623262633865626539363864323865383832303434373034383861373666653466303334
64623237626563356135626136373936623838636539653430376365643831373835643233623935
62373830303137653531393965326561333832363965326566633538336130396632323735353263
32666334633565363566326664623439363138636337643730653262653138383238373332346637
39623336303238386533616134653933643565363333636330616433313666633735373438343730
33613337356238633735366265356364353236353835376137626431643937376562386339383966
38616266643566333033316562633166383933663736333038386336323532373831663963363833
35353135303130613436376462336435343830386239316135666561366331393034386262343335
64333863323432656264363939366265373733376331313838396432333034633536376639323239
37633532626431383633303033656439396438653165353539376166373530336665303735376664
33616165376631323833623866383533386161386230383465663561636639656536363038343532
38356337643464363065393237663037653961313935316135336132333132653661613637313734
6464363931356536663765373364653265326366313065373033

View file

@ -0,0 +1,6 @@
$ANSIBLE_VAULT;1.1;AES256
63323966653031336261343365373838626663316230396237393334373066653664303037386562
6538373635343637333366626164626239656238653564630a636231636135373634343936626436
32663266363238633538613265663939343832306230343839396436383831383237306434633562
6463653463353432360a666137306536326530633065376133323962326562393964656361616663
63373432346231333130356330366233656137663037616330626530623164656161

View file

@ -0,0 +1,10 @@
$ANSIBLE_VAULT;1.1;AES256
61336263633734623034333865633061663330336266646331393734653238613132623039393938
6461303137323666393232623161666531396230386633380a386161643264636465623964623661
64636434326138386165353138313061643333323538356562643036636366643731613562343431
6461323566393462360a356661653133656430373362383532643962633865613630303536333761
30616261626639313862376130373034656532633763623530653134313461373536316531383230
65303930616534643139643534643735633365343232623033626563663835653966643965643065
64396536613965356139626138633930626130316464623263663139613864306334306132396563
61363065333162333963643738306464616265633038363763633930316237396261623663356330
3236

View file

@ -0,0 +1,19 @@
- name: Restart apache2
service:
name: apache2
state: restarted
- name: Restart postfix
service:
name: postfix
state: restarted
- name: Restart dovecot
service:
name: dovecot
state: restarted
- name: Restart rspamd
service:
name: rspamd
state: restarted

181
roles/mail/tasks/main.yml Normal file
View file

@ -0,0 +1,181 @@
- name: Install everything for doing mails
apt:
pkg:
- pwgen
- postfix
- apache2
- rspamd
- redis-server
- swaks
- mutt
- certbot
- python3-certbot-apache
- dovecot-pop3d
- dovecot-imapd
- dovecot-managesieved
- dovecot-lmtpd
update_cache: true
- name: Create dbconfig-common dir
file:
path: /etc/dbconfig-common
state: directory
recurse: yes
- name: Template db configuration
template:
src: db-roundcube.conf.j2
dest: /etc/dbconfig-common/roundcube.conf
- name: Install everything for doing mails
apt:
pkg:
- roundcube
- roundcube-plugins
- roundcube-plugins-extra
- roundcube-sqlite3
update_cache: true
- name: Enable the Apache2 module rewrite
apache2_module:
state: present
name: rewrite
- name: Template apache configuration
template:
src: roundcube.conf.j2
dest: /etc/apache2/sites-enabled/roundcube.conf
notify: Restart apache2
- name: Template roundcube configuration
template:
src: config.inc.php.j2
dest: /etc/roundcube/config.inc.php
notify: Restart apache2
- name: Template roundcube db configuration
template:
src: debian-db.php.j2
dest: /etc/roundcube/debian-db.php
notify: Restart apache2
- name: Generate postfix conf
template:
src: "{{ item }}.j2"
dest: "/etc/postfix/{{ item }}"
loop:
- email2email
- main.cf
- master.cf
- virtual_alias
- virtual_domains
- virtual_mailbox
notify: Restart postfix
- name: Copy postfix conf
copy:
src: "{{ item }}"
dest: "/etc/postfix/{{ item }}"
loop:
- email2email
- virtual_alias
- virtual_domains
- virtual_mailbox
notify: Restart postfix
- name: Copy mailname
copy:
src: mailname
dest: /etc/mailname
notify: Restart apache2
- name: Compile postfix files
command: "{{ item }}"
loop:
- postmap /etc/postfix/virtual_alias
- postmap /etc/postfix/virtual_domains
- postmap /etc/postfix/virtual_mailbox
- postmap /etc/postfix/email2email
notify: Restart postfix
#useradd -d /data/vmail -m -r vmail
- name: Add user vmail
user:
name: vmail
create_home: yes
home: /data/vmail
system: true
- name: Create conf dir
file:
path: "{{ item }}"
state: directory
recurse: yes
loop:
- /etc/dovecot/conf.d
- /etc/dovecot/sieve
- /etc/dovecot/sieve-after
- /etc/rspamd/dkim
- /etc/rspamd/local.d
- /etc/rspamd/override.d
- name: Generate dovecot conf
template:
src: "dovecot/{{ item }}.j2"
dest: "/etc/dovecot/{{ item }}"
loop:
- users
- conf.d/10-auth.conf
- conf.d/90-sieve.conf
- conf.d/10-mail.conf
- conf.d/20-imap.conf
- conf.d/20-lmtp.conf
- conf.d/10-ssl.conf
- conf.d/15-mailboxes.conf
- conf.d/10-master.conf
- sieve/rspamd-learn-spam.sh
- sieve/learn-ham.sieve
- sieve/learn-spam.sieve
- sieve/rspamd-learn-ham.sh
- sieve-after/spam-to-folder.sieve
notify: Restart dovecot
- name: Create autoconfig dir
file:
path: /var/www/html/autoconfig-mail
state: directory
recurse: yes
- name: Template autoconfig file
template:
src: config-v1.1.xml.j2
dest: /var/www/html/autoconfig-mail/config-v1.1.xml
- name: Generate rspamd conf
template:
src: "rspamd/{{ item }}.j2"
dest: "/etc/rspamd/{{ item }}"
loop:
- dkim/canebier.fr.2023061901.key
- dkim/chapoline.me.2023061901.key
- override.d/classifier-bayes.conf
- override.d/redis.conf
- override.d/milter_headers.conf
- local.d/worker-controller.inc
- local.d/dkim_signing.conf
- local.d/actions.conf
notify: Restart rspamd
- name: Generate letsencrypt certificates
command: "certbot --apache -d {{ mail.external_hostname }} --no-redirect -m {{ letsencrypt_email|default('me@chapoline.me') }} --agree-tos --deploy-hook 'systemctl restart postfix dovecot'"
- name: Compile dovecot files
command: "{{ item }}"
loop:
- sievec /etc/dovecot/sieve/learn-ham.sieve
- sievec /etc/dovecot/sieve/learn-spam.sieve
- sievec /etc/dovecot/sieve-after/spam-to-folder.sieve
notify: Restart dovecot

View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<clientConfig version="1.1">
<emailProvider id="chapoline.me">
<domain>chapoline.me</domain>
<displayName>Chapoline's Mail Service</displayName>
<displayShortName>Chapoline</displayShortName>
<incomingServer type="imap">
<hostname>{{ mail.external_hostname }}</hostname>
<port>143</port>
<socketType>STARTTLS</socketType>
<authentication>password-cleartext</authentication>
<username>%EMAILADDRESS%</username>
</incomingServer>
<outgoingServer type="smtp">
<hostname>{{ mail.external_hostname }}</hostname>
<port>587</port>
<socketType>STARTTLS</socketType>
<authentication>password-cleartext</authentication>
<username>%EMAILADDRESS%</username>
</outgoingServer>
</emailProvider>
</clientConfig>

View file

@ -0,0 +1,86 @@
<?php
/*
+-----------------------------------------------------------------------+
| Local configuration for the Roundcube Webmail installation. |
| |
| This is a sample configuration file only containing the minimum |
| setup required for a functional installation. Copy more options |
| from defaults.inc.php to this file to override the defaults. |
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) The Roundcube Dev Team |
| |
| Licensed under the GNU General Public License version 3 or |
| any later version with exceptions for skins & plugins. |
| See the README file for a full license statement. |
+-----------------------------------------------------------------------+
*/
$config = array();
// Do not set db_dsnw here, use dpkg-reconfigure roundcube-core to configure database!
include_once("/etc/roundcube/debian-db-roundcube.php");
// The IMAP host chosen to perform the log-in.
// Leave blank to show a textbox at login, give a list of hosts
// to display a pulldown menu or set one host as string.
// Enter hostname with prefix ssl:// to use Implicit TLS, or use
// prefix tls:// to use STARTTLS.
// Supported replacement variables:
// %n - hostname ($_SERVER['SERVER_NAME'])
// %t - hostname without the first part
// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
// %s - domain name after the '@' from e-mail address provided at login screen
// For example %n = mail.domain.tld, %t = domain.tld
$config['default_host'] = 'tls://{{ mail.external_hostname }}';
// SMTP server host (for sending mails).
// Enter hostname with prefix ssl:// to use Implicit TLS, or use
// prefix tls:// to use STARTTLS.
// Supported replacement variables:
// %h - user's IMAP hostname
// %n - hostname ($_SERVER['SERVER_NAME'])
// %t - hostname without the first part
// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
// %z - IMAP domain (IMAP hostname without the first part)
// For example %n = mail.domain.tld, %t = domain.tld
$config['smtp_server'] = 'tls://{{ mail.external_hostname }}';
// SMTP port. Use 25 for cleartext, 465 for Implicit TLS, or 587 for STARTTLS (default)
$config['smtp_port'] = 587;
// SMTP username (if required) if you use %u as the username Roundcube
// will use the current username for login
$config['smtp_user'] = '%u';
// SMTP password (if required) if you use %p as the password Roundcube
// will use the current user's password for login
$config['smtp_pass'] = '%p';
// provide an URL where a user can get support for this Roundcube installation
// PLEASE DO NOT LINK TO THE ROUNDCUBE.NET WEBSITE HERE!
$config['support_url'] = '';
// Name your service. This is displayed on the login screen and in the window title
$config['product_name'] = 'Roundcube Webmail';
// This key is used to encrypt the users imap password which is stored
// in the session record. For the default cipher method it must be
// exactly 24 characters long.
// YOUR KEY MUST BE DIFFERENT THAN THE SAMPLE VALUE FOR SECURITY REASONS
$config['des_key'] = '{{ mail.des_key }}';
// List of active plugins (in plugins/ directory)
// Debian: install roundcube-plugins first to have any
$config['plugins'] = array(
'managesieve',
);
// skin name: folder from skins/
$config['skin'] = 'elastic';
// Disable spellchecking
// Debian: spellchecking needs additional packages to be installed, or calling external APIs
// see defaults.inc.php for additional informations
$config['enable_spellcheck'] = false;

View file

@ -0,0 +1,86 @@
# automatically generated by the maintainer scripts of roundcube
# any changes you make will be preserved, though your comments
# will be lost! to change your settings you should edit this
# file and then run "dpkg-reconfigure roundcube"
# dbc_install: configure database with dbconfig-common?
# set to anything but "true" to opt out of assistance
dbc_install='true'
# dbc_upgrade: upgrade database with dbconfig-common?
# set to anything but "true" to opt out of assistance
dbc_upgrade='true'
# dbc_remove: deconfigure database with dbconfig-common?
# set to anything but "true" to opt out of assistance
dbc_remove='true'
# dbc_dbtype: type of underlying database to use
# this exists primarily to let dbconfig-common know what database
# type to use when a package supports multiple database types.
# don't change this value unless you know for certain that this
# package supports multiple database types
dbc_dbtype='sqlite'
# dbc_dbuser: database user
# the name of the user who we will use to connect to the database.
dbc_dbuser='roundcube'
# dbc_dbpass: database user password
# the password to use with the above username when connecting
# to a database, if one is required
dbc_dbpass='{{ mail.roundcube_db_password }}'
# dbc_dballow: allowed host to connect from
# only for database types that support specifying the host from
# which the database user is allowed to connect from
# this string defines for which host the dbc_dbuser is allowed
# to connect
# this value is only really used again when you reconfigure the
# package
dbc_dballow='localhost'
# dbc_dbserver: database host.
# leave unset to use localhost (or a more efficient local method
# if it exists).
dbc_dbserver='localhost'
# dbc_dbport: remote database port
# leave unset to use the default. only applicable if you are
# using a remote database.
dbc_dbport='3306'
# dbc_dbname: name of database
# this is the name of your application's database.
dbc_dbname='roundcube'
# dbc_dbadmin: name of the administrative user
# this is the administrative user that is used to create all of the above
# The exception is the MySQL/MariaDB localhost case, where this value is
# ignored and instead is determined from /etc/mysql/debian.cnf.
dbc_dbadmin='root'
# dbc_basepath: base directory to hold database files
# leave unset to use the default. only applicable if you are
# using a local (filesystem based) database.
dbc_basepath='/usr/local'
##
## postgresql specific settings. if you don't use postgresql,
## you can safely ignore all of these
##
# dbc_ssl: should we require ssl?
# set to "true" to require that connections use ssl
dbc_ssl=''
# dbc_authmethod_admin: authentication method for admin
# dbc_authmethod_user: authentication method for dbuser
# see the section titled "AUTHENTICATION METHODS" in
# /usr/share/doc/dbconfig-common/README.pgsql for more info
dbc_authmethod_admin=''
dbc_authmethod_user=''
##
## end postgresql specific settings
##

View file

@ -0,0 +1,18 @@
<?php
##
## database access settings in php format
## automatically generated from /etc/dbconfig-common/roundcube.conf
## by /usr/sbin/dbconfig-generate-include
##
## by default this file is managed via ucf, so you shouldn't have to
## worry about manual changes being silently discarded. *however*,
## you'll probably also want to edit the configuration file mentioned
## above too.
##
$dbuser='roundcube';
$dbpass='{{ mail.roundcube_db_password }}';
$basepath='/usr/local';
$dbname='roundcube';
$dbserver='localhost';
$dbport='3306';
$dbtype='sqlite';

View file

@ -0,0 +1,127 @@
##
## Authentication processes
##
# Disable LOGIN command and all other plaintext authentications unless
# SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
# matches the local IP (ie. you're connecting from the same computer), the
# connection is considered secure and plaintext authentication is allowed.
# See also ssl=required setting.
#disable_plaintext_auth = yes
# Authentication cache size (e.g. 10M). 0 means it's disabled. Note that
# bsdauth and PAM require cache_key to be set for caching to be used.
#auth_cache_size = 0
# Time to live for cached data. After TTL expires the cached record is no
# longer used, *except* if the main database lookup returns internal failure.
# We also try to handle password changes automatically: If user's previous
# authentication was successful, but this one wasn't, the cache isn't used.
# For now this works only with plaintext authentication.
#auth_cache_ttl = 1 hour
# TTL for negative hits (user not found, password mismatch).
# 0 disables caching them completely.
#auth_cache_negative_ttl = 1 hour
# Space separated list of realms for SASL authentication mechanisms that need
# them. You can leave it empty if you don't want to support multiple realms.
# Many clients simply use the first one listed here, so keep the default realm
# first.
#auth_realms =
# Default realm/domain to use if none was specified. This is used for both
# SASL realms and appending @domain to username in plaintext logins.
#auth_default_realm =
# List of allowed characters in username. If the user-given username contains
# a character not listed in here, the login automatically fails. This is just
# an extra check to make sure user can't exploit any potential quote escaping
# vulnerabilities with SQL/LDAP databases. If you want to allow all characters,
# set this value to empty.
#auth_username_chars = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@
# Username character translations before it's looked up from databases. The
# value contains series of from -> to characters. For example "#@/@" means
# that '#' and '/' characters are translated to '@'.
#auth_username_translation =
# Username formatting before it's looked up from databases. You can use
# the standard variables here, eg. %Lu would lowercase the username, %n would
# drop away the domain if it was given, or "%n-AT-%d" would change the '@' into
# "-AT-". This translation is done after auth_username_translation changes.
#auth_username_format = %Lu
# If you want to allow master users to log in by specifying the master
# username within the normal username string (ie. not using SASL mechanism's
# support for it), you can specify the separator character here. The format
# is then <username><separator><master username>. UW-IMAP uses "*" as the
# separator, so that could be a good choice.
#auth_master_user_separator =
# Username to use for users logging in with ANONYMOUS SASL mechanism
#auth_anonymous_username = anonymous
# Maximum number of dovecot-auth worker processes. They're used to execute
# blocking passdb and userdb queries (eg. MySQL and PAM). They're
# automatically created and destroyed as needed.
#auth_worker_max_count = 30
# Host name to use in GSSAPI principal names. The default is to use the
# name returned by gethostname(). Use "$ALL" (with quotes) to allow all keytab
# entries.
#auth_gssapi_hostname =
# Kerberos keytab to use for the GSSAPI mechanism. Will use the system
# default (usually /etc/krb5.keytab) if not specified. You may need to change
# the auth service to run as root to be able to read this file.
#auth_krb5_keytab =
# Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon and
# ntlm_auth helper. <doc/wiki/Authentication/Mechanisms/Winbind.txt>
#auth_use_winbind = no
# Path for Samba's ntlm_auth helper binary.
#auth_winbind_helper_path = /usr/bin/ntlm_auth
# Time to delay before replying to failed authentications.
#auth_failure_delay = 2 secs
# Require a valid SSL client certificate or the authentication fails.
#auth_ssl_require_client_cert = no
# Take the username from client's SSL certificate, using
# X509_NAME_get_text_by_NID() which returns the subject's DN's
# CommonName.
#auth_ssl_username_from_cert = no
# Space separated list of wanted authentication mechanisms:
# plain login digest-md5 cram-md5 ntlm rpa apop anonymous gssapi otp
# gss-spnego
# NOTE: See also disable_plaintext_auth setting.
auth_mechanisms = plain login
##
## Password and user databases
##
#
# Password database is used to verify user's password (and nothing more).
# You can have multiple passdbs and userdbs. This is useful if you want to
# allow both system users (/etc/passwd) and virtual users to login without
# duplicating the system users into virtual database.
#
# <doc/wiki/PasswordDatabase.txt>
#
# User database specifies where mails are located and what user/group IDs
# own them. For single-UID configuration use "static" userdb.
#
# <doc/wiki/UserDatabase.txt>
#!include auth-deny.conf.ext
#!include auth-master.conf.ext
#!include auth-system.conf.ext
#!include auth-sql.conf.ext
#!include auth-ldap.conf.ext
!include auth-passwdfile.conf.ext
#!include auth-checkpassword.conf.ext
#!include auth-static.conf.ext

View file

@ -0,0 +1,421 @@
##
## Mailbox locations and namespaces
##
# Location for users' mailboxes. The default is empty, which means that Dovecot
# tries to find the mailboxes automatically. This won't work if the user
# doesn't yet have any mail, so you should explicitly tell Dovecot the full
# location.
#
# If you're using mbox, giving a path to the INBOX file (eg. /var/mail/%u)
# isn't enough. You'll also need to tell Dovecot where the other mailboxes are
# kept. This is called the "root mail directory", and it must be the first
# path given in the mail_location setting.
#
# There are a few special variables you can use, eg.:
#
# %u - username
# %n - user part in user@domain, same as %u if there's no domain
# %d - domain part in user@domain, empty if there's no domain
# %h - home directory
#
# See doc/wiki/Variables.txt for full list. Some examples:
#
# mail_location = maildir:~/Maildir
# mail_location = mbox:~/mail:INBOX=/var/mail/%u
# mail_location = mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%n
#
# <doc/wiki/MailLocation.txt>
#
mail_location = maildir:~/Maildir
# If you need to set multiple mailbox locations or want to change default
# namespace settings, you can do it by defining namespace sections.
#
# You can have private, shared and public namespaces. Private namespaces
# are for user's personal mails. Shared namespaces are for accessing other
# users' mailboxes that have been shared. Public namespaces are for shared
# mailboxes that are managed by sysadmin. If you create any shared or public
# namespaces you'll typically want to enable ACL plugin also, otherwise all
# users can access all the shared mailboxes, assuming they have permissions
# on filesystem level to do so.
namespace inbox {
# Namespace type: private, shared or public
#type = private
# Hierarchy separator to use. You should use the same separator for all
# namespaces or some clients get confused. '/' is usually a good one.
# The default however depends on the underlying mail storage format.
separator = .
# Prefix required to access this namespace. This needs to be different for
# all namespaces. For example "Public/".
#prefix =
# Physical location of the mailbox. This is in same format as
# mail_location, which is also the default for it.
#location =
# There can be only one INBOX, and this setting defines which namespace
# has it.
inbox = yes
# If namespace is hidden, it's not advertised to clients via NAMESPACE
# extension. You'll most likely also want to set list=no. This is mostly
# useful when converting from another server with different namespaces which
# you want to deprecate but still keep working. For example you can create
# hidden namespaces with prefixes "~/mail/", "~%u/mail/" and "mail/".
#hidden = no
# Show the mailboxes under this namespace with LIST command. This makes the
# namespace visible for clients that don't support NAMESPACE extension.
# "children" value lists child mailboxes, but hides the namespace prefix.
#list = yes
# Namespace handles its own subscriptions. If set to "no", the parent
# namespace handles them (empty prefix should always have this as "yes")
#subscriptions = yes
# See 15-mailboxes.conf for definitions of special mailboxes.
}
# Example shared namespace configuration
#namespace {
#type = shared
#separator = /
# Mailboxes are visible under "shared/user@domain/"
# %%n, %%d and %%u are expanded to the destination user.
#prefix = shared/%%u/
# Mail location for other users' mailboxes. Note that %variables and ~/
# expands to the logged in user's data. %%n, %%d, %%u and %%h expand to the
# destination user's data.
#location = maildir:%%h/Maildir:INDEX=~/Maildir/shared/%%u
# Use the default namespace for saving subscriptions.
#subscriptions = no
# List the shared/ namespace only if there are visible shared mailboxes.
#list = children
#}
# Should shared INBOX be visible as "shared/user" or "shared/user/INBOX"?
#mail_shared_explicit_inbox = no
# System user and group used to access mails. If you use multiple, userdb
# can override these by returning uid or gid fields. You can use either numbers
# or names. <doc/wiki/UserIds.txt>
#mail_uid =
#mail_gid =
# Group to enable temporarily for privileged operations. Currently this is
# used only with INBOX when either its initial creation or dotlocking fails.
# Typically this is set to "mail" to give access to /var/mail.
mail_privileged_group = mail
# Grant access to these supplementary groups for mail processes. Typically
# these are used to set up access to shared mailboxes. Note that it may be
# dangerous to set these if users can create symlinks (e.g. if "mail" group is
# set here, ln -s /var/mail ~/mail/var could allow a user to delete others'
# mailboxes, or ln -s /secret/shared/box ~/mail/mybox would allow reading it).
#mail_access_groups =
# Allow full filesystem access to clients. There's no access checks other than
# what the operating system does for the active UID/GID. It works with both
# maildir and mboxes, allowing you to prefix mailboxes names with eg. /path/
# or ~user/.
#mail_full_filesystem_access = no
# Dictionary for key=value mailbox attributes. This is used for example by
# URLAUTH and METADATA extensions.
#mail_attribute_dict =
# A comment or note that is associated with the server. This value is
# accessible for authenticated users through the IMAP METADATA server
# entry "/shared/comment".
#mail_server_comment = ""
# Indicates a method for contacting the server administrator. According to
# RFC 5464, this value MUST be a URI (e.g., a mailto: or tel: URL), but that
# is currently not enforced. Use for example mailto:admin@example.com. This
# value is accessible for authenticated users through the IMAP METADATA server
# entry "/shared/admin".
#mail_server_admin =
##
## Mail processes
##
# Don't use mmap() at all. This is required if you store indexes to shared
# filesystems (NFS or clustered filesystem).
#mmap_disable = no
# Rely on O_EXCL to work when creating dotlock files. NFS supports O_EXCL
# since version 3, so this should be safe to use nowadays by default.
#dotlock_use_excl = yes
# When to use fsync() or fdatasync() calls:
# optimized (default): Whenever necessary to avoid losing important data
# always: Useful with e.g. NFS when write()s are delayed
# never: Never use it (best performance, but crashes can lose data)
#mail_fsync = optimized
# Locking method for index files. Alternatives are fcntl, flock and dotlock.
# Dotlocking uses some tricks which may create more disk I/O than other locking
# methods. NFS users: flock doesn't work, remember to change mmap_disable.
#lock_method = fcntl
# Directory where mails can be temporarily stored. Usually it's used only for
# mails larger than >= 128 kB. It's used by various parts of Dovecot, for
# example LDA/LMTP while delivering large mails or zlib plugin for keeping
# uncompressed mails.
#mail_temp_dir = /tmp
# Valid UID range for users, defaults to 500 and above. This is mostly
# to make sure that users can't log in as daemons or other system users.
# Note that denying root logins is hardcoded to dovecot binary and can't
# be done even if first_valid_uid is set to 0.
#first_valid_uid = 500
#last_valid_uid = 0
# Valid GID range for users, defaults to non-root/wheel. Users having
# non-valid GID as primary group ID aren't allowed to log in. If user
# belongs to supplementary groups with non-valid GIDs, those groups are
# not set.
#first_valid_gid = 1
#last_valid_gid = 0
# Maximum allowed length for mail keyword name. It's only forced when trying
# to create new keywords.
#mail_max_keyword_length = 50
# ':' separated list of directories under which chrooting is allowed for mail
# processes (ie. /var/mail will allow chrooting to /var/mail/foo/bar too).
# This setting doesn't affect login_chroot, mail_chroot or auth chroot
# settings. If this setting is empty, "/./" in home dirs are ignored.
# WARNING: Never add directories here which local users can modify, that
# may lead to root exploit. Usually this should be done only if you don't
# allow shell access for users. <doc/wiki/Chrooting.txt>
#valid_chroot_dirs =
# Default chroot directory for mail processes. This can be overridden for
# specific users in user database by giving /./ in user's home directory
# (eg. /home/./user chroots into /home). Note that usually there is no real
# need to do chrooting, Dovecot doesn't allow users to access files outside
# their mail directory anyway. If your home directories are prefixed with
# the chroot directory, append "/." to mail_chroot. <doc/wiki/Chrooting.txt>
#mail_chroot =
# UNIX socket path to master authentication server to find users.
# This is used by imap (for shared users) and lda.
#auth_socket_path = /var/run/dovecot/auth-userdb
# Directory where to look up mail plugins.
#mail_plugin_dir = /usr/lib/dovecot/modules
# Space separated list of plugins to load for all services. Plugins specific to
# IMAP, LDA, etc. are added to this list in their own .conf files.
#mail_plugins =
##
## Mailbox handling optimizations
##
# Mailbox list indexes can be used to optimize IMAP STATUS commands. They are
# also required for IMAP NOTIFY extension to be enabled.
#mailbox_list_index = yes
# Trust mailbox list index to be up-to-date. This reduces disk I/O at the cost
# of potentially returning out-of-date results after e.g. server crashes.
# The results will be automatically fixed once the folders are opened.
#mailbox_list_index_very_dirty_syncs = yes
# Should INBOX be kept up-to-date in the mailbox list index? By default it's
# not, because most of the mailbox accesses will open INBOX anyway.
#mailbox_list_index_include_inbox = no
# The minimum number of mails in a mailbox before updates are done to cache
# file. This allows optimizing Dovecot's behavior to do less disk writes at
# the cost of more disk reads.
#mail_cache_min_mail_count = 0
# When IDLE command is running, mailbox is checked once in a while to see if
# there are any new mails or other changes. This setting defines the minimum
# time to wait between those checks. Dovecot can also use inotify and
# kqueue to find out immediately when changes occur.
#mailbox_idle_check_interval = 30 secs
# Save mails with CR+LF instead of plain LF. This makes sending those mails
# take less CPU, especially with sendfile() syscall with Linux and FreeBSD.
# But it also creates a bit more disk I/O which may just make it slower.
# Also note that if other software reads the mboxes/maildirs, they may handle
# the extra CRs wrong and cause problems.
#mail_save_crlf = no
# Max number of mails to keep open and prefetch to memory. This only works with
# some mailbox formats and/or operating systems.
#mail_prefetch_count = 0
# How often to scan for stale temporary files and delete them (0 = never).
# These should exist only after Dovecot dies in the middle of saving mails.
#mail_temp_scan_interval = 1w
# How many slow mail accesses sorting can perform before it returns failure.
# With IMAP the reply is: NO [LIMIT] Requested sort would have taken too long.
# The untagged SORT reply is still returned, but it's likely not correct.
#mail_sort_max_read_count = 0
protocol !indexer-worker {
# If folder vsize calculation requires opening more than this many mails from
# disk (i.e. mail sizes aren't in cache already), return failure and finish
# the calculation via indexer process. Disabled by default. This setting must
# be 0 for indexer-worker processes.
#mail_vsize_bg_after_count = 0
}
##
## Maildir-specific settings
##
# By default LIST command returns all entries in maildir beginning with a dot.
# Enabling this option makes Dovecot return only entries which are directories.
# This is done by stat()ing each entry, so it causes more disk I/O.
# (For systems setting struct dirent->d_type, this check is free and it's
# done always regardless of this setting)
#maildir_stat_dirs = no
# When copying a message, do it with hard links whenever possible. This makes
# the performance much better, and it's unlikely to have any side effects.
#maildir_copy_with_hardlinks = yes
# Assume Dovecot is the only MUA accessing Maildir: Scan cur/ directory only
# when its mtime changes unexpectedly or when we can't find the mail otherwise.
#maildir_very_dirty_syncs = no
# If enabled, Dovecot doesn't use the S=<size> in the Maildir filenames for
# getting the mail's physical size, except when recalculating Maildir++ quota.
# This can be useful in systems where a lot of the Maildir filenames have a
# broken size. The performance hit for enabling this is very small.
#maildir_broken_filename_sizes = no
# Always move mails from new/ directory to cur/, even when the \Recent flags
# aren't being reset.
#maildir_empty_new = no
##
## mbox-specific settings
##
# Which locking methods to use for locking mbox. There are four available:
# dotlock: Create <mailbox>.lock file. This is the oldest and most NFS-safe
# solution. If you want to use /var/mail/ like directory, the users
# will need write access to that directory.
# dotlock_try: Same as dotlock, but if it fails because of permissions or
# because there isn't enough disk space, just skip it.
# fcntl : Use this if possible. Works with NFS too if lockd is used.
# flock : May not exist in all systems. Doesn't work with NFS.
# lockf : May not exist in all systems. Doesn't work with NFS.
#
# You can use multiple locking methods; if you do the order they're declared
# in is important to avoid deadlocks if other MTAs/MUAs are using multiple
# locking methods as well. Some operating systems don't allow using some of
# them simultaneously.
#
# The Debian value for mbox_write_locks differs from upstream Dovecot. It is
# changed to be compliant with Debian Policy (section 11.6) for NFS safety.
# Dovecot: mbox_write_locks = dotlock fcntl
# Debian: mbox_write_locks = fcntl dotlock
#
#mbox_read_locks = fcntl
#mbox_write_locks = fcntl dotlock
# Maximum time to wait for lock (all of them) before aborting.
#mbox_lock_timeout = 5 mins
# If dotlock exists but the mailbox isn't modified in any way, override the
# lock file after this much time.
#mbox_dotlock_change_timeout = 2 mins
# When mbox changes unexpectedly we have to fully read it to find out what
# changed. If the mbox is large this can take a long time. Since the change
# is usually just a newly appended mail, it'd be faster to simply read the
# new mails. If this setting is enabled, Dovecot does this but still safely
# fallbacks to re-reading the whole mbox file whenever something in mbox isn't
# how it's expected to be. The only real downside to this setting is that if
# some other MUA changes message flags, Dovecot doesn't notice it immediately.
# Note that a full sync is done with SELECT, EXAMINE, EXPUNGE and CHECK
# commands.
#mbox_dirty_syncs = yes
# Like mbox_dirty_syncs, but don't do full syncs even with SELECT, EXAMINE,
# EXPUNGE or CHECK commands. If this is set, mbox_dirty_syncs is ignored.
#mbox_very_dirty_syncs = no
# Delay writing mbox headers until doing a full write sync (EXPUNGE and CHECK
# commands and when closing the mailbox). This is especially useful for POP3
# where clients often delete all mails. The downside is that our changes
# aren't immediately visible to other MUAs.
#mbox_lazy_writes = yes
# If mbox size is smaller than this (e.g. 100k), don't write index files.
# If an index file already exists it's still read, just not updated.
#mbox_min_index_size = 0
# Mail header selection algorithm to use for MD5 POP3 UIDLs when
# pop3_uidl_format=%m. For backwards compatibility we use apop3d inspired
# algorithm, but it fails if the first Received: header isn't unique in all
# mails. An alternative algorithm is "all" that selects all headers.
#mbox_md5 = apop3d
##
## mdbox-specific settings
##
# Maximum dbox file size until it's rotated.
#mdbox_rotate_size = 10M
# Maximum dbox file age until it's rotated. Typically in days. Day begins
# from midnight, so 1d = today, 2d = yesterday, etc. 0 = check disabled.
#mdbox_rotate_interval = 0
# When creating new mdbox files, immediately preallocate their size to
# mdbox_rotate_size. This setting currently works only in Linux with some
# filesystems (ext4, xfs).
#mdbox_preallocate_space = no
##
## Mail attachments
##
# sdbox and mdbox support saving mail attachments to external files, which
# also allows single instance storage for them. Other backends don't support
# this for now.
# Directory root where to store mail attachments. Disabled, if empty.
#mail_attachment_dir =
# Attachments smaller than this aren't saved externally. It's also possible to
# write a plugin to disable saving specific attachments externally.
#mail_attachment_min_size = 128k
# Filesystem backend to use for saving attachments:
# posix : No SiS done by Dovecot (but this might help FS's own deduplication)
# sis posix : SiS with immediate byte-by-byte comparison during saving
# sis-queue posix : SiS with delayed comparison and deduplication
#mail_attachment_fs = sis posix
# Hash format to use in attachment filenames. You can add any text and
# variables: %{md4}, %{md5}, %{sha1}, %{sha256}, %{sha512}, %{size}.
# Variables can be truncated, e.g. %{sha256:80} returns only first 80 bits
#mail_attachment_hash = %{sha1}
# Settings to control adding $HasAttachment or $HasNoAttachment keywords.
# By default, all MIME parts with Content-Disposition=attachment, or inlines
# with filename parameter are consired attachments.
# add-flags - Add the keywords when saving new mails or when fetching can
# do it efficiently.
# content-type=type or !type - Include/exclude content type. Excluding will
# never consider the matched MIME part as attachment. Including will only
# negate an exclusion (e.g. content-type=!foo/* content-type=foo/bar).
# exclude-inlined - Exclude any Content-Disposition=inline MIME part.
#mail_attachment_detection_options =

View file

@ -0,0 +1,127 @@
#default_process_limit = 100
#default_client_limit = 1000
# Default VSZ (virtual memory size) limit for service processes. This is mainly
# intended to catch and kill processes that leak memory before they eat up
# everything.
#default_vsz_limit = 256M
# Login user is internally used by login processes. This is the most untrusted
# user in Dovecot system. It shouldn't have access to anything at all.
#default_login_user = dovenull
# Internal user is used by unprivileged processes. It should be separate from
# login user, so that login processes can't disturb other processes.
#default_internal_user = dovecot
service imap-login {
inet_listener imap {
#port = 143
}
inet_listener imaps {
#port = 993
#ssl = yes
}
# Number of connections to handle before starting a new process. Typically
# the only useful values are 0 (unlimited) or 1. 1 is more secure, but 0
# is faster. <doc/wiki/LoginProcess.txt>
#service_count = 1
# Number of processes to always keep waiting for more connections.
#process_min_avail = 0
# If you set service_count=0, you probably need to grow this.
#vsz_limit = $default_vsz_limit
}
service pop3-login {
inet_listener pop3 {
#port = 110
}
inet_listener pop3s {
#port = 995
#ssl = yes
}
}
service submission-login {
inet_listener submission {
#port = 587
}
}
service lmtp {
unix_listener /var/spool/postfix/private/dovecot-lmtp {
group = postfix
mode = 0600
user = postfix
}
}
service imap {
# Most of the memory goes to mmap()ing files. You may need to increase this
# limit if you have huge mailboxes.
#vsz_limit = $default_vsz_limit
# Max. number of IMAP processes (connections)
#process_limit = 1024
}
service pop3 {
# Max. number of POP3 processes (connections)
#process_limit = 1024
}
service submission {
# Max. number of SMTP Submission processes (connections)
#process_limit = 1024
}
service auth {
# auth_socket_path points to this userdb socket by default. It's typically
# used by dovecot-lda, doveadm, possibly imap process, etc. Users that have
# full permissions to this socket are able to get a list of all usernames and
# get the results of everyone's userdb lookups.
#
# The default 0666 mode allows anyone to connect to the socket, but the
# userdb lookups will succeed only if the userdb returns an "uid" field that
# matches the caller process's UID. Also if caller's uid or gid matches the
# socket's uid or gid the lookup succeeds. Anything else causes a failure.
#
# To give the caller full permissions to lookup all users, set the mode to
# something else than 0666 and Dovecot lets the kernel enforce the
# permissions (e.g. 0777 allows everyone full permissions).
unix_listener auth-userdb {
#mode = 0666
#user =
#group =
}
# Postfix smtp-auth
unix_listener /var/spool/postfix/private/auth {
mode = 0660
user = postfix
group = postfix
}
# Auth process is run as this user.
#user = $default_internal_user
}
service auth-worker {
# Auth worker process is run as root by default, so that it can access
# /etc/shadow. If this isn't necessary, the user should be changed to
# $default_internal_user.
#user = root
}
service dict {
# If dict proxy is used, mail processes should have access to its socket.
# For example: mode=0660, group=vmail and global mail_access_groups=vmail
unix_listener dict {
#mode = 0600
#user =
#group =
}
}

View file

@ -0,0 +1,80 @@
##
## SSL settings
##
# SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>
ssl = required
# PEM encoded X.509 SSL/TLS certificate and private key. They're opened before
# dropping root privileges, so keep the key file unreadable by anyone but
# root. Included doc/mkcert.sh can be used to easily generate self-signed
# certificate, just make sure to update the domains in dovecot-openssl.cnf
ssl_cert = </etc/letsencrypt/live/{{ mail.external_hostname }}/fullchain.pem
ssl_key = </etc/letsencrypt/live/{{ mail.external_hostname }}/privkey.pem
# If key file is password protected, give the password here. Alternatively
# give it when starting dovecot with -p parameter. Since this file is often
# world-readable, you may want to place this setting instead to a different
# root owned 0600 file by using ssl_key_password = <path.
#ssl_key_password =
# PEM encoded trusted certificate authority. Set this only if you intend to use
# ssl_verify_client_cert=yes. The file should contain the CA certificate(s)
# followed by the matching CRL(s). (e.g. ssl_ca = </etc/ssl/certs/ca.pem)
#ssl_ca =
# Require that CRL check succeeds for client certificates.
#ssl_require_crl = yes
# Directory and/or file for trusted SSL CA certificates. These are used only
# when Dovecot needs to act as an SSL client (e.g. imapc backend or
# submission service). The directory is usually /etc/ssl/certs in
# Debian-based systems and the file is /etc/pki/tls/cert.pem in
# RedHat-based systems. Note that ssl_client_ca_file isn't recommended with
# large CA bundles, because it leads to excessive memory usage.
#ssl_client_ca_dir =
ssl_client_ca_dir = /etc/ssl/certs
#ssl_client_ca_file =
# Require valid cert when connecting to a remote server
#ssl_client_require_valid_cert = yes
# Request client to send a certificate. If you also want to require it, set
# auth_ssl_require_client_cert=yes in auth section.
#ssl_verify_client_cert = no
# Which field from certificate to use for username. commonName and
# x500UniqueIdentifier are the usual choices. You'll also need to set
# auth_ssl_username_from_cert=yes.
#ssl_cert_username_field = commonName
# SSL DH parameters
# Generate new params with `openssl dhparam -out /etc/dovecot/dh.pem 4096`
# Or migrate from old ssl-parameters.dat file with the command dovecot
# gives on startup when ssl_dh is unset.
ssl_dh = </usr/share/dovecot/dh.pem
# Minimum SSL protocol version to use. Potentially recognized values are SSLv3,
# TLSv1, TLSv1.1, and TLSv1.2, depending on the OpenSSL version used.
#ssl_min_protocol = TLSv1
# SSL ciphers to use, the default is:
#ssl_cipher_list = ALL:!kRSA:!SRP:!kDHd:!DSS:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK:!RC4:!ADH:!LOW@STRENGTH
# To disable non-EC DH, use:
#ssl_cipher_list = ALL:!DH:!kRSA:!SRP:!kDHd:!DSS:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK:!RC4:!ADH:!LOW@STRENGTH
# Colon separated list of elliptic curves to use. Empty value (the default)
# means use the defaults from the SSL library. P-521:P-384:P-256 would be an
# example of a valid value.
#ssl_curve_list =
# Prefer the server's order of ciphers over client's.
#ssl_prefer_server_ciphers = no
# SSL crypto device to use, for valid values run "openssl engine"
#ssl_crypto_device =
# SSL extra options. Currently supported options are:
# compression - Enable compression.
# no_ticket - Disable SSL session tickets.
#ssl_options =

View file

@ -0,0 +1,90 @@
##
## Mailbox definitions
##
# Each mailbox is specified in a separate mailbox section. The section name
# specifies the mailbox name. If it has spaces, you can put the name
# "in quotes". These sections can contain the following mailbox settings:
#
# auto:
# Indicates whether the mailbox with this name is automatically created
# implicitly when it is first accessed. The user can also be automatically
# subscribed to the mailbox after creation. The following values are
# defined for this setting:
#
# no - Never created automatically.
# create - Automatically created, but no automatic subscription.
# subscribe - Automatically created and subscribed.
#
# special_use:
# A space-separated list of SPECIAL-USE flags (RFC 6154) to use for the
# mailbox. There are no validity checks, so you could specify anything
# you want in here, but it's not a good idea to use flags other than the
# standard ones specified in the RFC:
#
# \All - This (virtual) mailbox presents all messages in the
# user's message store.
# \Archive - This mailbox is used to archive messages.
# \Drafts - This mailbox is used to hold draft messages.
# \Flagged - This (virtual) mailbox presents all messages in the
# user's message store marked with the IMAP \Flagged flag.
# \Important - This (virtual) mailbox presents all messages in the
# user's message store deemed important to user.
# \Junk - This mailbox is where messages deemed to be junk mail
# are held.
# \Sent - This mailbox is used to hold copies of messages that
# have been sent.
# \Trash - This mailbox is used to hold messages that have been
# deleted.
#
# comment:
# Defines a default comment or note associated with the mailbox. This
# value is accessible through the IMAP METADATA mailbox entries
# "/shared/comment" and "/private/comment". Users with sufficient
# privileges can override the default value for entries with a custom
# value.
# NOTE: Assumes "namespace inbox" has been defined in 10-mail.conf.
namespace inbox {
# These mailboxes are widely used and could perhaps be created automatically:
mailbox Drafts {
special_use = \Drafts
}
mailbox Junk {
special_use = \Junk
auto = subscribe
autoexpunge = 30d
}
mailbox Trash {
special_use = \Trash
auto = subscribe
autoexpunge = 30d
}
# For \Sent mailboxes there are two widely used names. We'll mark both of
# them as \Sent. User typically deletes one of them if duplicates are created.
mailbox Sent {
special_use = \Sent
}
mailbox "Sent Messages" {
special_use = \Sent
}
# If you have a virtual "All messages" mailbox:
#mailbox virtual/All {
# special_use = \All
# comment = All my messages
#}
# If you have a virtual "Flagged" mailbox:
#mailbox virtual/Flagged {
# special_use = \Flagged
# comment = All my flagged messages
#}
# If you have a virtual "Important" mailbox:
#mailbox virtual/Important {
# special_use = \Important
# comment = All my important messages
#}
}

View file

@ -0,0 +1,99 @@
##
## IMAP specific settings
##
# If nothing happens for this long while client is IDLEing, move the connection
# to imap-hibernate process and close the old imap process. This saves memory,
# because connections use very little memory in imap-hibernate process. The
# downside is that recreating the imap process back uses some resources.
#imap_hibernate_timeout = 0
# Maximum IMAP command line length. Some clients generate very long command
# lines with huge mailboxes, so you may need to raise this if you get
# "Too long argument" or "IMAP command line too large" errors often.
#imap_max_line_length = 64k
# IMAP logout format string:
# %i - total number of bytes read from client
# %o - total number of bytes sent to client
# %{fetch_hdr_count} - Number of mails with mail header data sent to client
# %{fetch_hdr_bytes} - Number of bytes with mail header data sent to client
# %{fetch_body_count} - Number of mails with mail body data sent to client
# %{fetch_body_bytes} - Number of bytes with mail body data sent to client
# %{deleted} - Number of mails where client added \Deleted flag
# %{expunged} - Number of mails that client expunged, which does not
# include automatically expunged mails
# %{autoexpunged} - Number of mails that were automatically expunged after
# client disconnected
# %{trashed} - Number of mails that client copied/moved to the
# special_use=\Trash mailbox.
# %{appended} - Number of mails saved during the session
#imap_logout_format = in=%i out=%o deleted=%{deleted} expunged=%{expunged} \
# trashed=%{trashed} hdr_count=%{fetch_hdr_count} \
# hdr_bytes=%{fetch_hdr_bytes} body_count=%{fetch_body_count} \
# body_bytes=%{fetch_body_bytes}
# Override the IMAP CAPABILITY response. If the value begins with '+',
# add the given capabilities on top of the defaults (e.g. +XFOO XBAR).
#imap_capability =
# How long to wait between "OK Still here" notifications when client is
# IDLEing.
#imap_idle_notify_interval = 2 mins
# ID field names and values to send to clients. Using * as the value makes
# Dovecot use the default value. The following fields have default values
# currently: name, version, os, os-version, support-url, support-email,
# revision.
#imap_id_send =
# ID fields sent by client to log. * means everything.
#imap_id_log =
# Workarounds for various client bugs:
# delay-newmail:
# Send EXISTS/RECENT new mail notifications only when replying to NOOP
# and CHECK commands. Some clients ignore them otherwise, for example OSX
# Mail (<v2.1). Outlook Express breaks more badly though, without this it
# may show user "Message no longer in server" errors. Note that OE6 still
# breaks even with this workaround if synchronization is set to
# "Headers Only".
# tb-extra-mailbox-sep:
# Thunderbird gets somehow confused with LAYOUT=fs (mbox and dbox) and
# adds extra '/' suffixes to mailbox names. This option causes Dovecot to
# ignore the extra '/' instead of treating it as invalid mailbox name.
# tb-lsub-flags:
# Show \Noselect flags for LSUB replies with LAYOUT=fs (e.g. mbox).
# This makes Thunderbird realize they aren't selectable and show them
# greyed out, instead of only later giving "not selectable" popup error.
#
# The list is space-separated.
#imap_client_workarounds =
# Host allowed in URLAUTH URLs sent by client. "*" allows all.
#imap_urlauth_host =
# Enable IMAP LITERAL- extension (replaces LITERAL+)
#imap_literal_minus = no
# What happens when FETCH fails due to some internal error:
# disconnect-immediately:
# The FETCH is aborted immediately and the IMAP client is disconnected.
# disconnect-after:
# The FETCH runs for all the requested mails returning as much data as
# possible. The client is finally disconnected without a tagged reply.
# no-after:
# Same as disconnect-after, but tagged NO reply is sent instead of
# disconnecting the client. If the client attempts to FETCH the same failed
# mail more than once, the client is disconnected. This is to avoid clients
# from going into infinite loops trying to FETCH a broken mail.
#imap_fetch_failure = disconnect-immediately
protocol imap {
# Space separated list of plugins to load (default is global mail_plugins).
mail_plugins = $mail_plugins quota imap_sieve
# Maximum number of IMAP connections allowed for a user from each IP address.
# NOTE: The username is compared case-sensitively.
#mail_max_userip_connections = 10
}

View file

@ -0,0 +1,40 @@
##
## LMTP specific settings
##
# Support proxying to other LMTP/SMTP servers by performing passdb lookups.
#lmtp_proxy = no
# When recipient address includes the detail (e.g. user+detail), try to save
# the mail to the detail mailbox. See also recipient_delimiter and
# lda_mailbox_autocreate settings.
#lmtp_save_to_detail_mailbox = no
# Verify quota before replying to RCPT TO. This adds a small overhead.
#lmtp_rcpt_check_quota = no
# Add "Received:" header to mails delivered.
#lmtp_add_received_header = yes
# Which recipient address to use for Delivered-To: header and Received:
# header. The default is "final", which is the same as the one given to
# RCPT TO command. "original" uses the address given in RCPT TO's ORCPT
# parameter, "none" uses nothing. Note that "none" is currently always used
# when a mail has multiple recipients.
#lmtp_hdr_delivery_address = final
# Workarounds for various client bugs:
# whitespace-before-path:
# Allow one or more spaces or tabs between `MAIL FROM:' and path and between
# `RCPT TO:' and path.
# mailbox-for-path:
# Allow using bare Mailbox syntax (i.e., without <...>) instead of full path
# syntax.
#
# The list is space-separated.
#lmtp_client_workarounds =
protocol lmtp {
# Space separated list of plugins to load (default is global mail_plugins).
mail_plugins = $mail_plugins sieve
}

View file

@ -0,0 +1,221 @@
##
## Settings for the Sieve interpreter
##
# Do not forget to enable the Sieve plugin in 15-lda.conf and 20-lmtp.conf
# by adding it to the respective mail_plugins= settings.
# The Sieve interpreter can retrieve Sieve scripts from several types of
# locations. The default `file' location type is a local filesystem path
# pointing to a Sieve script file or a directory containing multiple Sieve
# script files. More complex setups can use other location types such as
# `ldap' or `dict' to fetch Sieve scripts from remote databases.
#
# All settings that specify the location of one ore more Sieve scripts accept
# the following syntax:
#
# location = [<type>:]path[;<option>[=<value>][;...]]
#
# If the type prefix is omitted, the script location type is 'file' and the
# location is interpreted as a local filesystem path pointing to a Sieve script
# file or directory. Refer to Pigeonhole wiki or INSTALL file for more
# information.
plugin {
# The location of the user's main Sieve script or script storage. The LDA
# Sieve plugin uses this to find the active script for Sieve filtering at
# delivery. The "include" extension uses this location for retrieving
# :personal" scripts. This is also where the ManageSieve service will store
# the user's scripts, if supported.
#
# Currently only the 'file:' location type supports ManageSieve operation.
# Other location types like 'dict:' and 'ldap:' can currently only
# be used as a read-only script source ().
#
# For the 'file:' type: use the ';active=' parameter to specify where the
# active script symlink is located.
# For other types: use the ';name=' parameter to specify the name of the
# default/active script.
sieve = file:~/sieve;active=~/.dovecot.sieve
# The default Sieve script when the user has none. This is the location of a
# global sieve script file, which gets executed ONLY if user's personal Sieve
# script doesn't exist. Be sure to pre-compile this script manually using the
# sievec command line tool if the binary is not stored in a global location.
# --> See sieve_before for executing scripts before the user's personal
# script.
#sieve_default = /var/lib/dovecot/sieve/default.sieve
# The name by which the default Sieve script (as configured by the
# sieve_default setting) is visible to the user through ManageSieve.
#sieve_default_name =
# Location for ":global" include scripts as used by the "include" extension.
#sieve_global =
# The location of a Sieve script that is run for any message that is about to
# be discarded; i.e., it is not delivered anywhere by the normal Sieve
# execution. This only happens when the "implicit keep" is canceled, by e.g.
# the "discard" action, and no actions that deliver the message are executed.
# This "discard script" can prevent discarding the message, by executing
# alternative actions. If the discard script does nothing, the message is
# still discarded as it would be when no discard script is configured.
#sieve_discard =
# Location Sieve of scripts that need to be executed before the user's
# personal script. If a 'file' location path points to a directory, all the
# Sieve scripts contained therein (with the proper `.sieve' extension) are
# executed. The order of execution within that directory is determined by the
# file names, using a normal 8bit per-character comparison.
#
# Multiple script locations can be specified by appending an increasing number
# to the setting name. The Sieve scripts found from these locations are added
# to the script execution sequence in the specified order. Reading the
# numbered sieve_before settings stops at the first missing setting, so no
# numbers may be skipped.
#sieve_before = /var/lib/dovecot/sieve.d/
#sieve_before2 = ldap:/etc/sieve-ldap.conf;name=ldap-domain
#sieve_before3 = (etc...)
# Identical to sieve_before, only the specified scripts are executed after the
# user's script (only when keep is still in effect!). Multiple script
# locations can be specified by appending an increasing number.
#sieve_after =
#sieve_after2 =
#sieve_after2 = (etc...)
sieve_after = /etc/dovecot/sieve-after
# Which Sieve language extensions are available to users. By default, all
# supported extensions are available, except for deprecated extensions or
# those that are still under development. Some system administrators may want
# to disable certain Sieve extensions or enable those that are not available
# by default. This setting can use '+' and '-' to specify differences relative
# to the default. For example `sieve_extensions = +imapflags' will enable the
# deprecated imapflags extension in addition to all extensions were already
# enabled by default.
#sieve_extensions = +notify +imapflags
# Which Sieve language extensions are ONLY available in global scripts. This
# can be used to restrict the use of certain Sieve extensions to administrator
# control, for instance when these extensions can cause security concerns.
# This setting has higher precedence than the `sieve_extensions' setting
# (above), meaning that the extensions enabled with this setting are never
# available to the user's personal script no matter what is specified for the
# `sieve_extensions' setting. The syntax of this setting is similar to the
# `sieve_extensions' setting, with the difference that extensions are
# enabled or disabled for exclusive use in global scripts. Currently, no
# extensions are marked as such by default.
#sieve_global_extensions =
# The Pigeonhole Sieve interpreter can have plugins of its own. Using this
# setting, the used plugins can be specified. Check the Dovecot wiki
# (wiki2.dovecot.org) or the pigeonhole website
# (http://pigeonhole.dovecot.org) for available plugins.
# The sieve_extprograms plugin is included in this release.
#sieve_plugins =
# The maximum size of a Sieve script. The compiler will refuse to compile any
# script larger than this limit. If set to 0, no limit on the script size is
# enforced.
#sieve_max_script_size = 1M
# The maximum number of actions that can be performed during a single script
# execution. If set to 0, no limit on the total number of actions is enforced.
#sieve_max_actions = 32
# The maximum number of redirect actions that can be performed during a single
# script execution. If set to 0, no redirect actions are allowed.
#sieve_max_redirects = 4
# The maximum number of personal Sieve scripts a single user can have. If set
# to 0, no limit on the number of scripts is enforced.
# (Currently only relevant for ManageSieve)
#sieve_quota_max_scripts = 0
# The maximum amount of disk storage a single user's scripts may occupy. If
# set to 0, no limit on the used amount of disk storage is enforced.
# (Currently only relevant for ManageSieve)
#sieve_quota_max_storage = 0
# The primary e-mail address for the user. This is used as a default when no
# other appropriate address is available for sending messages. If this setting
# is not configured, either the postmaster or null "<>" address is used as a
# sender, depending on the action involved. This setting is important when
# there is no message envelope to extract addresses from, such as when the
# script is executed in IMAP.
#sieve_user_email =
# The path to the file where the user log is written. If not configured, a
# default location is used. If the main user's personal Sieve (as configured
# with sieve=) is a file, the logfile is set to <filename>.log by default. If
# it is not a file, the default user log file is ~/.dovecot.sieve.log.
#sieve_user_log =
# Specifies what envelope sender address is used for redirected messages.
# The following values are supported for this setting:
#
# "sender" - The sender address is used (default).
# "recipient" - The final recipient address is used.
# "orig_recipient" - The original recipient is used.
# "user_email" - The user's primary address is used. This is
# configured with the "sieve_user_email" setting. If
# that setting is unconfigured, "user_mail" is equal to
# "recipient".
# "postmaster" - The postmaster_address configured for the LDA.
# "<user@domain>" - Redirected messages are always sent from user@domain.
# The angle brackets are mandatory. The null "<>" address
# is also supported.
#
# This setting is ignored when the envelope sender is "<>". In that case the
# sender of the redirected message is also always "<>".
#sieve_redirect_envelope_from = sender
## TRACE DEBUGGING
# Trace debugging provides detailed insight in the operations performed by
# the Sieve script. These settings apply to both the LDA Sieve plugin and the
# IMAPSIEVE plugin.
#
# WARNING: On a busy server, this functionality can quickly fill up the trace
# directory with a lot of trace files. Enable this only temporarily and as
# selective as possible.
# The directory where trace files are written. Trace debugging is disabled if
# this setting is not configured or if the directory does not exist. If the
# path is relative or it starts with "~/" it is interpreted relative to the
# current user's home directory.
#sieve_trace_dir =
# The verbosity level of the trace messages. Trace debugging is disabled if
# this setting is not configured. Possible values are:
#
# "actions" - Only print executed action commands, like keep,
# fileinto, reject and redirect.
# "commands" - Print any executed command, excluding test commands.
# "tests" - Print all executed commands and performed tests.
# "matching" - Print all executed commands, performed tests and the
# values matched in those tests.
#sieve_trace_level =
# Enables highly verbose debugging messages that are usually only useful for
# developers.
#sieve_trace_debug = no
# Enables showing byte code addresses in the trace output, rather than only
# the source line numbers.
#sieve_trace_addresses = no
# From elsewhere to Junk folder
imapsieve_mailbox1_name = Junk
imapsieve_mailbox1_causes = COPY
imapsieve_mailbox1_before = file:/etc/dovecot/sieve/learn-spam.sieve
# From Junk folder to elsewhere
imapsieve_mailbox2_name = *
imapsieve_mailbox2_from = Junk
imapsieve_mailbox2_causes = COPY
imapsieve_mailbox2_before = file:/etc/dovecot/sieve/learn-ham.sieve
sieve_pipe_bin_dir = /etc/dovecot/sieve
sieve_global_extensions = +vnd.dovecot.pipe
sieve_plugins = sieve_imapsieve sieve_extprograms
}

View file

@ -0,0 +1,6 @@
require ["fileinto"];
if header :contains "X-Spam" "Yes" {
fileinto "Junk";
stop;
}

View file

@ -0,0 +1,5 @@
require ["vnd.dovecot.pipe", "copy", "imapsieve", "variables"];
if string "${mailbox}" "Trash" {
stop;
}
pipe :copy "rspamd-learn-ham.sh";

View file

@ -0,0 +1,2 @@
require ["vnd.dovecot.pipe", "copy", "imapsieve"];
pipe :copy "rspamd-learn-spam.sh";

View file

@ -0,0 +1,2 @@
#!/bin/sh
exec /usr/bin/rspamc learn_ham

View file

@ -0,0 +1,2 @@
#!/bin/sh
exec /usr/bin/rspamc learn_spam

View file

@ -0,0 +1,4 @@
caroline@canebier.fr:{BLF-CRYPT}$2y$05$zyPlVHzlKYpXWEobQmNScOwMWpNfyVhMDgMzY7BxOZVMP3xyd7tqa:1337:1337::/data/vmail/caroline::
me@chapoline.me:{BLF-CRYPT}$2y$05$zyPlVHzlKYpXWEobQmNScOwMWpNfyVhMDgMzY7BxOZVMP3xyd7tqa:1337:1337::/data/vmail/caroline::
bruno@canebier.fr:{SHA512-CRYPT}$6$DfBrsqKgmpsBGZi5$eXKRFHVlNpj9pbB6OjfuQrvTTu2yuJDkhwUiGLra6QQLS37ioaWyYLcSgAbRZpHNqjdmGzxGFcs8rrtgFgSNV0:1337:1337::/data/vmail/parents::
pascale@canebier.fr:{SHA512-CRYPT}$6$DfBrsqKgmpsBGZi5$eXKRFHVlNpj9pbB6OjfuQrvTTu2yuJDkhwUiGLra6QQLS37ioaWyYLcSgAbRZpHNqjdmGzxGFcs8rrtgFgSNV0:1337:1337::/data/vmail/parents::

View file

@ -0,0 +1,66 @@
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = no
# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on
# fresh installs.
compatibility_level = 2
smtp_tls_CApath=/etc/ssl/certs
smtp_tls_security_level=may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = {{ mail.external_hostname }}
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, localhost
relayhost =
mynetworks = 127.0.0.0/8, 192.168.0.0/16, 10.0.0.0/8
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = ipv4
virtual_mailbox_domains = hash:/etc/postfix/virtual_domains
virtual_mailbox_maps = hash:/etc/postfix/virtual_mailbox
virtual_alias_maps = hash:/etc/postfix/virtual_alias
virtual_transport=lmtp:unix:private/dovecot-lmtp
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_tls_auth_only = yes
smtpd_tls_security_level=may
smtpd_tls_auth_only=yes
smtpd_tls_cert_file=/etc/letsencrypt/live/{{ mail.external_hostname }}/fullchain.pem
smtpd_tls_key_file=/etc/letsencrypt/live/{{ mail.external_hostname }}/privkey.pem
smtp_tls_security_level=may
smtpd_sender_login_maps=hash:/etc/postfix/email2email
#smtpd_sender_restrictions=permit_mynetworks,reject_sender_login_mismatch,permit_sasl_authenticated,reject
smtpd_milters=inet:127.0.0.1:11332
non_smtpd_milters=inet:127.0.0.1:11332
milter_mail_macros=i {mail_addr} {client_addr} {client_name} {auth_authen}
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
#smtpd_sasl_exceptions_networks = $mynetworks

View file

@ -0,0 +1,126 @@
#
# Postfix master process configuration file. For details on the format
# of the file, see the master(5) manual page (command: "man 5 master" or
# on-line: http://www.postfix.org/master.5.html).
#
# Do not forget to execute "postfix reload" after editing this file.
#
# ==========================================================================
# service type private unpriv chroot wakeup maxproc command + args
# (yes) (yes) (no) (never) (100)
# ==========================================================================
smtp inet n - y - - smtpd
#smtp inet n - y - 1 postscreen
#smtpd pass - - y - - smtpd
#dnsblog unix - - y - 0 dnsblog
#tlsproxy unix - - y - 0 tlsproxy
submission inet n - y - - smtpd
-o syslog_name=postfix/submission
-o smtpd_tls_security_level=encrypt
-o smtpd_sasl_auth_enable=yes
-o smtpd_tls_auth_only=yes
-o smtpd_reject_unlisted_recipient=no
# -o smtpd_client_restrictions=$mua_client_restrictions
# -o smtpd_helo_restrictions=$mua_helo_restrictions
# -o smtpd_sender_restrictions=$mua_sender_restrictions
-o smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,defer_unauth_destination
-o smtpd_relay_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
-o milter_macro_daemon_name=ORIGINATING
# -o smtpd_sender_restrictions=permit_mynetworks,reject_sender_login_mismatch,permit_sasl_authenticated,reject
#smtps inet n - y - - smtpd
# -o syslog_name=postfix/smtps
# -o smtpd_tls_wrappermode=yes
# -o smtpd_sasl_auth_enable=yes
# -o smtpd_reject_unlisted_recipient=no
# -o smtpd_client_restrictions=$mua_client_restrictions
# -o smtpd_helo_restrictions=$mua_helo_restrictions
# -o smtpd_sender_restrictions=$mua_sender_restrictions
# -o smtpd_recipient_restrictions=
# -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
# -o milter_macro_daemon_name=ORIGINATING
#628 inet n - y - - qmqpd
pickup unix n - y 60 1 pickup
cleanup unix n - y - 0 cleanup
qmgr unix n - n 300 1 qmgr
#qmgr unix n - n 300 1 oqmgr
tlsmgr unix - - y 1000? 1 tlsmgr
rewrite unix - - y - - trivial-rewrite
bounce unix - - y - 0 bounce
defer unix - - y - 0 bounce
trace unix - - y - 0 bounce
verify unix - - y - 1 verify
flush unix n - y 1000? 0 flush
proxymap unix - - n - - proxymap
proxywrite unix - - n - 1 proxymap
smtp unix - - y - - smtp
relay unix - - y - - smtp
-o syslog_name=postfix/$service_name
# -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq unix n - y - - showq
error unix - - y - - error
retry unix - - y - - error
discard unix - - y - - discard
local unix - n n - - local
virtual unix - n n - - virtual
lmtp unix - - y - - lmtp
anvil unix - - y - 1 anvil
scache unix - - y - 1 scache
postlog unix-dgram n - n - 1 postlogd
#
# ====================================================================
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# Many of the following services use the Postfix pipe(8) delivery
# agent. See the pipe(8) man page for information about ${recipient}
# and other message envelope options.
# ====================================================================
#
# maildrop. See the Postfix MAILDROP_README file for details.
# Also specify in main.cf: maildrop_destination_recipient_limit=1
#
maildrop unix - n n - - pipe
flags=DRXhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
#
# ====================================================================
#
# Recent Cyrus versions can use the existing "lmtp" master.cf entry.
#
# Specify in cyrus.conf:
# lmtp cmd="lmtpd -a" listen="localhost:lmtp" proto=tcp4
#
# Specify in main.cf one or more of the following:
# mailbox_transport = lmtp:inet:localhost
# virtual_transport = lmtp:inet:localhost
#
# ====================================================================
#
# Cyrus 2.1.5 (Amos Gouaux)
# Also specify in main.cf: cyrus_destination_recipient_limit=1
#
#cyrus unix - n n - - pipe
# flags=DRX user=cyrus argv=/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${user}
#
# ====================================================================
# Old example of delivery via Cyrus.
#
#old-cyrus unix - n n - - pipe
# flags=R user=cyrus argv=/cyrus/bin/deliver -e -m ${extension} ${user}
#
# ====================================================================
#
# See the Postfix UUCP_README file for configuration details.
#
uucp unix - n n - - pipe
flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
#
# Other external delivery methods.
#
ifmail unix - n n - - pipe
flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp unix - n n - - pipe
flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix - n n - 2 pipe
flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman unix - n n - - pipe
flags=FRX user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py ${nexthop} ${user}

View file

@ -0,0 +1,19 @@
<VirtualHost *:80>
ServerName {{ inventory_hostname }}
ServerAlias {{ mail.external_hostname }}
Alias /.well-known/autoconfig/mail /var/www/html/autoconfig-mail
DocumentRoot /var/lib/roundcube/public_html
Include /etc/roundcube/apache.conf
<Location /rspamd>
Require all granted
</Location>
RewriteEngine On
RewriteRule ^/rspamd$ /rspamd/ [R,L]
RewriteRule ^/rspamd/(.*) http://localhost:11334/$1 [P,L]
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

View file

@ -0,0 +1,3 @@
reject = 150;
add_header = 6;
greylist = 4;

View file

@ -0,0 +1,2 @@
path = "/etc/rspamd/dkim/$domain.$selector.key";
selector_map = "/etc/rspamd/dkim_selectors.map";

View file

@ -0,0 +1 @@
password = "{{ mail.rspamd_admin_hash }}"

View file

@ -0,0 +1 @@
autolearn = true;

View file

@ -0,0 +1 @@
extended_spam_headers = true;

View file

@ -0,0 +1 @@
servers = "127.0.0.1";

View file

@ -0,0 +1,5 @@
- name: Restart nginx
service:
name: nginx
state: restarted
when: check_nginx.failed == false

View file

@ -0,0 +1,28 @@
- name: Install dependencies
apt:
pkg:
- nginx
- certbot
- python3-certbot-nginx
- name: Query lets encrypt certificate
shell: 'letsencrypt certonly -n --nginx -m {{ letsencrypt_email|default("me@chapoline.me") }} --expand --agree-tos -d {{ item.name }} {% for a in item.alias %} -d {{a}}{% endfor %}'
ignore_errors: true
notify: Restart nginx
- name: Create a few symbolic links
file:
src: "{{ item2.src }}"
dest: "{{ item2.dest }}"
state: link
force: true
loop:
- src: "/etc/letsencrypt/live/{{ item.name }}/privkey.pem"
dest: "/etc/ssl/private/{{ item.name }}.key"
- src: "/etc/letsencrypt/live/{{ item.name }}/cert.pem"
dest: "/etc/ssl/private/{{ item.name }}.crt"
- src: "/etc/letsencrypt/live/{{ item.name }}/fullchain.pem"
dest: "/etc/ssl/private/{{ item.name }}.chain.crt"
loop_control:
loop_var: item2
notify: Restart nginx

View file

@ -0,0 +1,27 @@
- name: Install nginx
package:
name:
- nginx
- python3-cryptography
update_cache: true
- name: Generate certificates
include_tasks: openssl.yml
loop: "{{ nginx.vhost }}"
when: item.ssl
- name: Generate nginx config
template:
src: nginx.conf.j2
dest: "/etc/nginx/sites-enabled/{{ item.name }}.conf"
loop: "{{ nginx.vhost }}"
notify: Restart nginx
# - name: Configure certbot
# include_tasks: certbot.yml
# loop: "{{ nginx.vhost }}"
# when: item.ssl
- name: Check configuration integrity
shell: "nginx -t"
register: check_nginx

View file

@ -0,0 +1,37 @@
- name: Check if certs have already been generated
stat:
path: "/etc/ssl/private/{{ item.name }}.chain.crt"
register: result
- name: Generate self-signed certificates
when: not result.stat.exists
notify: Restart nginx
block:
- name: Generate an OpenSSL private key
openssl_privatekey:
path: "/etc/ssl/private/{{ item.name }}.key"
- name: Generate an OpenSSL Certificate Signing Request
openssl_csr:
path: "/etc/ssl/private/{{ item.name }}.csr"
privatekey_path: "/etc/ssl/private/{{ item.name }}.key"
common_name: "{{ item.name }}"
subject_alt_name: "{{ item2.value | map('regex_replace', '^', 'DNS:') | list }}"
with_dict:
dns_names: "{{ [ item.name ] + item.alias }}"
loop_control:
loop_var: item2
- name: Generate a Self Signed OpenSSL certificate
openssl_certificate:
path: "/etc/ssl/private/{{ item.name }}.crt"
privatekey_path: "/etc/ssl/private/{{ item.name }}.key"
csr_path: "/etc/ssl/private/{{ item.name }}.csr"
provider: selfsigned
- name: Generate fullchain
copy:
src: "/etc/ssl/private/{{ item.name }}.crt"
remote_src: true
dest: "/etc/ssl/private/{{ item.name }}.chain.crt"

View file

@ -0,0 +1,66 @@
server {
listen 0.0.0.0:80 ;
listen [::0]:80 ;
server_name {{ item.name }} ;
{% if item.ssl|default(False) %}
{% if item.redirect|default(True) %}
location / {
return 301 https://$host$request_uri;
}
{% endif %}
{% else %}
{% for loc in item.location %}
location {{ loc.route }} {
{{ loc.dest }}
{% if "proxy_pass" in loc.dest %}
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
{% endif %}
}
{% endfor %}
{% endif %}
}
{% if item.ssl|default(False) %}
server {
listen 0.0.0.0:443 http2 ssl ;
listen [::0]:443 http2 ssl ;
server_name {{ item.name }} ;
ssl_certificate /etc/ssl/private/{{ item.name }}.chain.crt;
ssl_certificate_key /etc/ssl/private/{{ item.name }}.key;
ssl_trusted_certificate /etc/ssl/private/{{ item.name }}.crt;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
ssl_stapling on;
ssl_stapling_verify on;
include mime.types;
{% for loc in item.location %}
location {{ loc.route }} {
{{ loc.dest }}
{% if "proxy_pass" in loc.dest %}
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
{% endif %}
{% if loc.ws|default(False) %}
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
{% endif %}
}
{% endfor %}
}
{% endif %}

12
roles/openssl/README.md Normal file
View file

@ -0,0 +1,12 @@
usage:
```yml
- name: Install self-signed certs
ansible.builtin.include_role:
name: openssl
loop:
- name: example.vm.chapo.li
alias: [ cname.vm.chapo.li ]
loop_control:
loop_var: cert
```

View file

@ -0,0 +1,38 @@
- name: Install dependencies
apt:
pkg:
- python3-cryptography
- name: Check if certs have already been generated
stat:
path: "/etc/ssl/private/{{ cert.name }}.chain.crt"
register: result
- name: Generate self-signed certificates
when: not result.stat.exists
block:
- name: Generate an OpenSSL private key
openssl_privatekey:
path: "/etc/ssl/private/{{ cert.name }}.key"
- name: Generate an OpenSSL Certificate Signing Request
openssl_csr:
path: "/etc/ssl/private/{{ cert.name }}.csr"
privatekey_path: "/etc/ssl/private/{{ cert.name }}.key"
common_name: "{{ cert.name }}"
subject_alt_name: "{{ item.value | map('regex_replace', '^', 'DNS:') | list }}"
with_dict:
dns_names: "{{ [ cert.name ] + cert.alias }}"
- name: Generate a Self Signed OpenSSL certificate
openssl_certificate:
path: "/etc/ssl/private/{{ cert.name }}.crt"
privatekey_path: "/etc/ssl/private/{{ cert.name }}.key"
csr_path: "/etc/ssl/private/{{ cert.name }}.csr"
provider: selfsigned
- name: Generate fullchain
copy:
src: "/etc/ssl/private/{{ cert.name }}.crt"
remote_src: true
dest: "/etc/ssl/private/{{ cert.name }}.chain.crt"

View file

@ -0,0 +1,134 @@
- name: Get VM list from Proxmox
community.general.proxmox_vm_info:
api_host: "{{ proxmox_host }}"
api_user: "{{ proxmox_user|default('root@pam') }}"
api_token_id: '{{ proxmox_token_id }}'
api_token_secret: '{{ proxmox_token_secret }}'
type: lxc
register: vm_list
- name: Filter managed LXC
set_fact:
lxc_list: |
{%- set r = [] -%}
{%- for lxc in (vm_list['proxmox_vms']) -%}
{%- if "tags" in lxc and 'ansible_managed' in lxc['tags'] -%}
{%- set _ = r.append(lxc) -%}
{%- endif -%}
{%- endfor -%}
{{ r }}
- name: List all LXC names
set_fact:
name_list: |
{%- set r = [] -%}
{%- for lxc in lxc_list -%}
{%- set _ = r.append(lxc['name']) -%}
{%- endfor -%}
{{ r }}
- name: Generate a list of LXC to create
set_fact:
to_create: |
{%- set r = [] -%}
{%- for name in groups['lxc'] -%}
{%- if name not in name_list -%}
{%- set _ = r.append(name) -%}
{%- endif -%}
{%- endfor -%}
{{ r }}
- name: Generate a list of LXC to delete
set_fact:
to_delete: |
{%- set r = [] -%}
{%- for lxc in lxc_list -%}
{%- if lxc['name'] not in groups['lxc'] -%}
{%- set _ = r.append(lxc) -%}
{%- endif -%}
{%- endfor -%}
{{ r }}
- name: Generate a list of LXC to modify
set_fact:
to_modify: |
{%- set r = [] -%}
{%- for lxc in lxc_list -%}
{%- if lxc['name'] in groups['lxc']
and not (lxc['maxcpu'] == hostvars[lxc['name']]['resources']['cpu']
and lxc['maxmem'] == hostvars[lxc['name']]['resources']['ram']*1024*1024
and lxc['maxswap'] == hostvars[lxc['name']]['resources']['swap']*1024*1024)
-%}
{%- set _ = r.append(lxc) -%}
{%- endif -%}
{%- endfor -%}
{{ r }}
- name: debug
debug:
msg: "to create: {{ to_create }}, to delete: {{ to_delete|map(attribute='name') }}, to modify: {{ to_modify|map(attribute='name') }}"
- name: Create LXCs
community.general.proxmox:
vmid: "{{ 200 + (hostvars[item]['ansible_host'].split('.')[-1]|int) }}"
node: "{{ proxmox_node }}"
api_host: "{{ proxmox_host }}"
api_user: "{{ proxmox_user|default('root@pam') }}"
api_token_id: '{{ proxmox_token_id }}'
api_token_secret: '{{ proxmox_token_secret }}'
hostname: "{{ item }}"
pubkey: "{{ proxmox_ssh_pubkey }}"
ostemplate: "{{ proxmox_lxc_image }}"
netif:
net0: "name=eth0,gw={{ hostvars[item]['gateway']|default('10.255.3.254') }},ip={{ hostvars[item]['ansible_host'] }}/24,bridge=vmbr0"
cores: "{{ hostvars[item]['resources']['cpu'] }}"
memory: "{{ hostvars[item]['resources']['ram'] }}"
swap: "{{ hostvars[item]['resources']['swap'] }}"
tags:
- "ansible_managed"
onboot: true
state: present
disk: "zpool1:{{ hostvars[item]['resources']['disk'] }}"
features: "nesting=1"
loop: "{{ to_create }}"
- name: Start created LXCs
community.general.proxmox:
vmid: "{{ 200 + (hostvars[item]['ansible_host'].split('.')[-1]|int) }}"
node: "{{ proxmox_node }}"
api_host: "{{ proxmox_host }}"
api_user: "{{ proxmox_user|default('root@pam') }}"
api_token_id: '{{ proxmox_token_id }}'
api_token_secret: '{{ proxmox_token_secret }}'
state: started
loop: "{{ to_create }}"
- name: Delete LXCs
community.general.proxmox:
vmid: "{{ item['vmid'] }}"
node: "{{ proxmox_node }}"
api_host: "{{ proxmox_host }}"
api_user: "{{ proxmox_user|default('root@pam') }}"
api_token_id: '{{ proxmox_token_id }}'
api_token_secret: '{{ proxmox_token_secret }}'
state: absent
loop: "{{ to_delete }}"
when: allow_deletion
- name: Modify LXCs
community.general.proxmox:
vmid: "{{ item['vmid'] }}"
node: "{{ proxmox_node }}"
api_host: "{{ proxmox_host }}"
api_user: "{{ proxmox_user|default('root@pam') }}"
api_token_id: '{{ proxmox_token_id }}'
api_token_secret: '{{ proxmox_token_secret }}'
cores: "{{ hostvars[item['name']]['resources']['cpu'] }}"
memory: "{{ hostvars[item['name']]['resources']['ram'] }}"
swap: "{{ hostvars[item['name']]['resources']['swap'] }}"
hostname: "{{ item['name'] }}"
update: true
loop: "{{ to_modify }}"

View file

@ -0,0 +1,18 @@
proxmox_host: 10.255.2.1
proxmox_user: root@pam
proxmox_token_id: ansible
proxmox_token_secret: !vault |
$ANSIBLE_VAULT;1.1;AES256
38323563363738613538366334666436363561366337313363323833623039363639383564656166
3366633565313364333330353230383764353266633839620a666166623039653832363832303931
34343830393666616431616230633263383766613666646538643164323062393039373736636237
3839643562663235330a356535336562313765616439343265636634346361353636323235393437
36343139323064396436363930616432323230613330646162646532316164643535336630653163
6239643066363838663230346331306563353337616437643264
proxmox_node: gandalf
proxmox_lxc_image: "local:vztmpl/debian-12-standard_12.2-1_amd64.tar.zst"
proxmox_ssh_pubkey: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBq5W7km9DCODGY2PCmvhxpI48MAC/OFB6qxr0+IGka6 chapeau@sonya
allow_deletion: False

View file

@ -0,0 +1,39 @@
- name: Test connection as current user
block:
- name: Ping
ping:
# data: crash
rescue:
- name: Set ansible_user to root
set_fact:
ansible_user: root
- name: Install sudo
apt:
pkg:
- sudo
- name: Create users
user:
name: "{{ item.username }}"
home: "/home/{{ item.username }}"
move_home: true
shell: "{{ item.shell|default('/bin/bash') }}"
groups: sudo
loop: "{{ users }}"
become: true
- name: Add ssh keys
ansible.posix.authorized_key:
user: "{{ item.username }}"
key: "{{ item.pubkeys }}"
exclusive: true
loop: "{{ users }}"
- name: Change sudo policy
lineinfile:
path: /etc/sudoers
regexp: "^%sudo ALL="
line: "%sudo ALL=(ALL) NOPASSWD: ALL"
validate: /usr/sbin/visudo -cf %s
become: true

20
shell.nix Normal file
View file

@ -0,0 +1,20 @@
let
nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-24.05";
pkgs = import nixpkgs { config = {}; overlay = []; };
python-packages = ps: with ps; [
ansible
ansible-core
jinja2
requests
proxmoxer
];
in
pkgs.mkShell {
name = "Ansible perso";
packages = with pkgs; [
(python3.withPackages python-packages)
];
ANSIBLE_FORCE_COLOR = true;
LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive";
}