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: debian9
- distro: debian8 - distro: debian8
- distro: alpine - distro: alpine
#- distro: archlinux # - distro: archlinux
script: script:
# Configure test script so we can run extra tests after playbook is run # Configure test script so we can run extra tests after playbook is run

View file

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

View file

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

View file

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