yamllint + ansible-lint

This commit is contained in:
Gitouche 2021-07-01 20:52:55 +02:00
parent 325804daa5
commit 38e50cf95d
5 changed files with 112 additions and 114 deletions

View file

@ -8,7 +8,7 @@ env:
- distro: debian9
- distro: debian8
- distro: alpine
#- distro: archlinux
# - distro: archlinux
script:
# Configure test script so we can run extra tests after playbook is run

View file

@ -2,44 +2,44 @@
msmtp_accounts:
# Account 1 - it was a real account for testing (but yandex now blocks it)
# Uses Yandex app password limited to POP3, SMTP and IMAP
- account: yandex
host: smtp.yandex.com
port: 587
auth: "on"
from: emailer-tests@yandex.com
user: emailer-tests@yandex.com
password: jhlrizltgkmnkkgm
#Account 2
- account: mysmtp
host: smtp.example
port: 587
auth: "on"
from: admin@example.org
user: myuser@example.org
password: plain-text-password2
#Account 3
- account: gmail
host: smtp.gmail.com
port: 587
auth: "on"
from: example@gmail.example
user: example@gmail.example
password: "some password"
- account: yandex
host: smtp.yandex.com
port: 587
auth: "on"
from: emailer-tests@yandex.com
user: emailer-tests@yandex.com
password: jhlrizltgkmnkkgm
# Account 2
- account: mysmtp
host: smtp.example
port: 587
auth: "on"
from: admin@example.org
user: myuser@example.org
password: plain-text-password2
# Account 3
- account: gmail
host: smtp.gmail.com
port: 587
auth: "on"
from: example@gmail.example
user: example@gmail.example
password: "some password"
msmtp_default_account: yandex
msmtp_domain: yandex.com
msmtp_domain: yandex.com
## Enable or disable automatic envelope-from addresses
msmtp_auto_from: 'off'
## Logging (Select A) "syslog" or B) "file" logging or C) "no" log
msmtp_log: file
msmtp_logfile: ~/.msmtp.log
msmtp_log: file
msmtp_logfile: ~/.msmtp.log
## Aliases mail account ( only msmtp_alias_default is required the rest is optional )
msmtp_alias_default: emailer.tests@yandex.com
msmtp_alias_root: emailer.tests@yandex.com
msmtp_alias_cron: emailer.tests@yandex.com
msmtp_alias_root: emailer.tests@yandex.com
msmtp_alias_cron: emailer.tests@yandex.com
## Enable, after the the default smtp account is working
msmtp_send_test_mail: no

View file

@ -1,13 +1,14 @@
---
galaxy_info:
author: Adham Helal, Christian Wagner, gitouche
description: "Deploy msmtp mailer on RHEL8"
min_ansible_version: 2.4
license: Apache
platforms:
- name: EL
versions:
- 8
- name: EL
versions:
- 8
tags:
- mail
- system
- networking
- mail
- system
- networking

View file

@ -1,77 +1,74 @@
---
# Deploy msmtp
# TODO:
# Fix: Check if mailserver is ready, as Test mail will only work,
# if msmtp is setup after the mailserver is already configured
- name: Copy RPM file to server
copy:
src: msmtp-1.8.15-1.el8.x86_64.rpm
dest: /tmp/msmtp-1.8.15-1.el8.x86_64.rpm
when: ansible_os_family == "RedHat"
- name: Copy systemd unit file to server
copy:
src: msmtpd.service
dest: /etc/systemd/system/msmtpd.service
when: ansible_os_family == "RedHat"
- name: enable daemon
ansible.builtin.systemd:
name: msmtpd
enabled: yes
masked: no
daemon_reload: yes
when: ansible_os_family == "RedHat"
- name: Install msmtp
yum:
name:
- /tmp/msmtp-1.8.15-1.el8.x86_64.rpm
- mailx
state: present
disable_gpg_check: yes
notify:
- restart msmtpd
when: ansible_os_family == "RedHat"
- name: Ensure group "msmtp" exists
group:
name: msmtp
state: present
when: ansible_os_family == "RedHat"
- name: Copy mstprc conf file.
template:
src: msmtprc.j2
dest: /etc/msmtprc
owner: root
group: msmtp
mode: 0640
tags: mail
notify:
- test mail
- restart msmtpd
- name: Copy aliases conf file.
template:
src: aliases-rhel.j2
dest: /etc/aliases
owner: root
group: root
mode: 0644
tags: mail
notify:
- test mail
- restart msmtpd
when: ansible_os_family == "RedHat"
- name: Copy sysconfig file.
template:
src: sysconfig.j2
dest: /etc/sysconfig/msmtpd
notify:
- test mail
- restart msmtpd
when: ansible_os_family == "RedHat"
---
- name: Copy RPM file to server
copy:
src: msmtp-1.8.15-1.el8.x86_64.rpm
dest: /tmp/msmtp-1.8.15-1.el8.x86_64.rpm
mode: 0400
when: ansible_os_family == "RedHat"
- name: Copy systemd unit file to server
copy:
src: msmtpd.service
dest: /etc/systemd/system/msmtpd.service
mode: 0400
when: ansible_os_family == "RedHat"
- name: enable daemon
ansible.builtin.systemd:
name: msmtpd
enabled: yes
masked: no
daemon_reload: yes
when: ansible_os_family == "RedHat"
- name: Install msmtp
yum:
name:
- /tmp/msmtp-1.8.15-1.el8.x86_64.rpm
- mailx
state: present
disable_gpg_check: yes
notify:
- restart msmtpd
when: ansible_os_family == "RedHat"
- name: Ensure group "msmtp" exists
group:
name: msmtp
state: present
when: ansible_os_family == "RedHat"
- name: Copy mstprc conf file.
template:
src: msmtprc.j2
dest: /etc/msmtprc
owner: root
group: msmtp
mode: 0640
tags: mail
notify:
- test mail
- restart msmtpd
- name: Copy aliases conf file.
template:
src: aliases-rhel.j2
dest: /etc/aliases
owner: root
group: root
mode: 0644
tags: mail
notify:
- test mail
- restart msmtpd
when: ansible_os_family == "RedHat"
- name: Copy sysconfig file.
template:
src: sysconfig.j2
dest: /etc/sysconfig/msmtpd
mode: 0444
notify:
- test mail
- restart msmtpd
when: ansible_os_family == "RedHat"

View file

@ -1,2 +1,2 @@
---
# You can override default vars defined in defaults/main.yml here
---
# You can override default vars defined in defaults/main.yml here