diff --git a/group_vars/all.yml b/group_vars/all.yml index 522c8805..9c53e8d1 100644 --- a/group_vars/all.yml +++ b/group_vars/all.yml @@ -1,10 +1,13 @@ --- ### mgrote.postfix-gmail empfaenger_mail: michael.grote@posteo.de - nutzer_gmail: michael.grote@gmail.com - passwort_gmail: "{{ lookup('keepass', 'passwort_gmail', 'password') }}" - postfix_gmail_erlaubte_netzwerke: "127.0.0.0/8 192.168.2.0/24" - mail_nach_cronjob: false + gmail_nutzer_gmail: michael.grote@gmail.com + gmail_nutzer_passwort: "{{ lookup('keepass', 'gmail_nutzer_passwort', 'password') }}" + gmail_postfix_erlaubte_netzwerke: "127.0.0.0/8 192.168.2.0/24" + gmail_mail_nach_cronjob: false + gmail_smtp_server: smtp.gmail.com + gmail_smtp_server_port: 587 + gmail_smtp_use_tls: yes ### mgrote.set_apt_sources acng_server: acng.grote.lan acng_server_port: 9999 diff --git a/keepass_db.kdbx b/keepass_db.kdbx index 639d0549..13f0bc33 100644 Binary files a/keepass_db.kdbx and b/keepass_db.kdbx differ diff --git a/playbooks/service/fileserver.yml b/playbooks/service/fileserver.yml index 042376b8..a57ab311 100644 --- a/playbooks/service/fileserver.yml +++ b/playbooks/service/fileserver.yml @@ -14,5 +14,5 @@ --- - hosts: storage roles: - - { role: mgrote.postfix-gmail, tags: "postfix-gmail" } + - { role: mgrote.postfix-gmail, tags: "gmail" } - { role: mgrote.fileserver_smb, tags: "fileserver_smb" } diff --git a/roles/mgrote.postfix-gmail/README.md b/roles/mgrote.postfix-gmail/README.md index cc3776b8..d41509ea 100644 --- a/roles/mgrote.postfix-gmail/README.md +++ b/roles/mgrote.postfix-gmail/README.md @@ -6,17 +6,16 @@ Installiert und konfiguriert postfix fuer den GMail. ### Funktioniert auf - [x] Ubuntu (>=18.04) - [x] Debian - - [x] ProxMox 6.1 ### Variablen + Defaults ##### Wer soll die Mails bekommen. empfaenger_mail: michael.grote@posteo.de ##### Nutzer fuer GMail -nutzer_gmail: michael.grote@gmail.com +gmail_nutzer_gmail: michael.grote@gmail.com ##### Passwort fuer GMail -passwort_gmail: FKXaOMOPv9bF5kHC +gmail_nutzer_passwort: FKXaOXXXXXX5kHC ##### Soll nach Aufuehrung eines cronjobs eine Mail versendet werden? -mail_nach_cronjob: false +gmail_mail_nach_cronjob: false ##### Netzwerke aus denen postfix Mails annimmt -postfix_gmail_erlaubte_netzwerke: "127.0.0.0/8 192.168.2.0/24" +gmail_postfix_erlaubte_netzwerke: "127.0.0.0/8 192.168.2.0/24" diff --git a/roles/mgrote.postfix-gmail/defaults/main.yml b/roles/mgrote.postfix-gmail/defaults/main.yml index c38ec366..9c84dec8 100644 --- a/roles/mgrote.postfix-gmail/defaults/main.yml +++ b/roles/mgrote.postfix-gmail/defaults/main.yml @@ -1,3 +1,6 @@ --- - mail_nach_cronjob: false - postfix_gmail_erlaubte_netzwerke: "127.0.0.0/8 192.168.2.0/24" + gmail_mail_nach_cronjob: false + gmail_postfix_erlaubte_netzwerke: "127.0.0.0/8 192.168.2.0/24" + gmail_smtp_server: smtp.gmail.com + gmail_smtp_server_port: 587 + gmail_smtp_use_tls: yes diff --git a/roles/mgrote.postfix-gmail/handlers/main.yml b/roles/mgrote.postfix-gmail/handlers/main.yml index 30f5a221..a83d51b5 100644 --- a/roles/mgrote.postfix-gmail/handlers/main.yml +++ b/roles/mgrote.postfix-gmail/handlers/main.yml @@ -8,6 +8,7 @@ name: postfix enabled: yes state: restarted + notify: postfix_testmail - name: postfix_testmail shell: echo "postfix ist eingerichtet" | mail -s "{{ ansible_hostname }} - postfix" {{ empfaenger_mail }} diff --git a/roles/mgrote.postfix-gmail/tasks/main.yml b/roles/mgrote.postfix-gmail/tasks/main.yml index 7c28308e..c08ac580 100644 --- a/roles/mgrote.postfix-gmail/tasks/main.yml +++ b/roles/mgrote.postfix-gmail/tasks/main.yml @@ -30,7 +30,7 @@ - name: Mail Cronjob - Anlegen become: yes - when: mail_nach_cronjob # ohne parameter wird auf true geprueft https://www.buildahomelab.com/2018/11/12/using-ansible-when-statements/ + when: gmail_mail_nach_cronjob # ohne parameter wird auf true geprueft https://www.buildahomelab.com/2018/11/12/using-ansible-when-statements/ ansible.builtin.cron: name: MAILTO env: yes @@ -40,7 +40,7 @@ - name: Mail Cronjob - Entfernen become: yes - when: not mail_nach_cronjob + when: not gmail_mail_nach_cronjob ansible.builtin.cron: name: MAILTO env: yes diff --git a/roles/mgrote.postfix-gmail/templates/main.cf b/roles/mgrote.postfix-gmail/templates/main.cf index 5eb93290..c8da501f 100644 --- a/roles/mgrote.postfix-gmail/templates/main.cf +++ b/roles/mgrote.postfix-gmail/templates/main.cf @@ -1,5 +1,5 @@ -relayhost = [smtp.gmail.com]:587 -smtp_use_tls = yes +relayhost = [{{ gmail_smtp_server }}]:{{ gmail_smtp_server_port }} +smtp_use_tls = {{ gmail_smtp_use_tls }} smtp_sasl_auth_enable = yes smtp_sasl_security_options = smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd @@ -8,6 +8,6 @@ smtp_tls_session_cache_timeout = 3600s inet_protocols = ipv4 append_dot_mydomain = no -mynetworks = {{ postfix_gmail_erlaubte_netzwerke }} +mynetworks = {{ gmail_postfix_erlaubte_netzwerke }} smtpd_relay_restrictions = permit_mynetworks diff --git a/roles/mgrote.postfix-gmail/templates/sasl_passwd b/roles/mgrote.postfix-gmail/templates/sasl_passwd index 35980b94..9a52ffe5 100644 --- a/roles/mgrote.postfix-gmail/templates/sasl_passwd +++ b/roles/mgrote.postfix-gmail/templates/sasl_passwd @@ -1,2 +1 @@ -smtp.gmail.com {{ nutzer_gmail }}:{{ passwort_gmail }} - +{{ gmail_smtp_server }} {{ gmail_nutzer_gmail }}:{{ gmail_nutzer_passwort }}