fix Ansible warnings about apt loops, etc

This commit is contained in:
Unknown 2019-07-31 22:51:00 +08:00
parent 75149e46ab
commit 4996f19549
1 changed files with 19 additions and 9 deletions

View File

@ -2,23 +2,25 @@
# Deploy msmtp # Deploy msmtp
# TODO: # TODO:
# Fix: Check if mailserver is ready, as Test mail will only work, if msmtp is setup after the mailserver is already configured # Fix: Check if mailserver is ready, as Test mail will only work,
# if msmtp is setup after the mailserver is already configured
- name: Update apt cache. - name: Update apt cache.
apt: apt:
update_cache: yes update_cache: yes
upgrade: no upgrade: "no"
cache_valid_time: 14400 # 4 hours cache_valid_time: 14400 # 4 hours
tags: mail tags: mail
when: ansible_os_family == "Debian" when: ansible_os_family == "Debian"
- name: Remove other MTAs. - name: Remove other MTAs.
apt: apt:
pkg: "{{ item }}" name: "{{ packages }}"
state: absent state: absent
autoremove: yes autoremove: yes
purge: yes purge: yes
with_items: vars:
packages:
- exim4* - exim4*
- postfix* - postfix*
- sendmail* - sendmail*
@ -30,9 +32,10 @@
- name: Install msmtp and mailx on Debian. - name: Install msmtp and mailx on Debian.
apt: apt:
pkg: "{{item}}" name: "{{ packages }}"
state: present state: present
with_items: vars:
packages:
- msmtp-mta - msmtp-mta
- bsd-mailx - bsd-mailx
tags: mail tags: mail
@ -40,8 +43,11 @@
when: ansible_os_family == "Debian" when: ansible_os_family == "Debian"
- name: Install msmtp and s-nail on Archlinux. - name: Install msmtp and s-nail on Archlinux.
pacman: name={{item}} state=present pacman:
with_items: name: "{{ packages }}"
state: present
vars:
packages:
- msmtp - msmtp
- msmtp-mta - msmtp-mta
- s-nail - s-nail
@ -49,9 +55,13 @@
- name: Install msmtp and mailx on Alpine. - name: Install msmtp and mailx on Alpine.
apk: apk:
name: msmtp, mailx name: "{{ packages }}"
state: present state: present
update_cache: no update_cache: no
vars:
packages:
- msmtp
- mailx
when: ansible_os_family == "Alpine" when: ansible_os_family == "Alpine"
- name: Overwrite busybox sendmail link to point to mSMTP. - name: Overwrite busybox sendmail link to point to mSMTP.