Compare commits

...

11 Commits

Author SHA1 Message Date
CASSONNET Guillaume 6a87854b47 fix selinux is only for RHEL 9.3 2023-11-24 18:48:57 +01:00
CASSONNET Guillaume d669ce9dfe bump msmtp-1.8.25-1 + fix selinux for RHEL 8.9/9.3 2023-11-24 18:34:32 +01:00
Gitouche 8954e574bf Templatize more variables - fix 2023-08-20 10:23:39 +02:00
Gitouche 7f0ea55dc6 Templatize more variables 2023-08-20 09:21:28 +02:00
Gitouche 8844cf5a87 bump msmtp-1.8.24-1 2023-08-13 21:21:04 +02:00
Gitouche 8159ec6030 Fix build, move to fc37 2023-04-09 10:39:38 +02:00
Gitouche 59b11898e4 Fix molecule 2023-03-06 21:51:17 +01:00
Gitouche 5f8bf17901 fix group 2023-03-04 16:29:04 +01:00
Gitouche 69ec605d5a script de build rpm - moins de hardcoding 2023-03-04 14:03:52 +01:00
Gitouche 40be77d9db script de build rpm - passage de rpmbuild à mock 2023-03-04 11:59:57 +01:00
Gitouche 356ccc9847 ajout support el9 2023-03-03 20:58:41 +01:00
9 changed files with 112 additions and 84 deletions

View File

@ -1,7 +1,12 @@
---
msmtp_version: 1.8.23-1
msmtp_version: 1.8.25-1
msmtp_rpm_file: https://git.garbaye.fr/api/packages/Garbaye/generic/msmtp/{{ msmtp_version}}/msmtp-{{ msmtp_version}}.el8.{{ ansible_architecture }}.rpm
# msmtprc configuration
msmtp_auth: 'on'
msmtp_tls: 'on'
msmtp_tls_starttls: 'on'
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

47
docker_rebuild_msmtp_rpm.sh Executable file
View File

@ -0,0 +1,47 @@
#!/usr/bin/env bash
FROMFEDORA='37'
PACKAGE='msmtp'
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
cd ${ABSDIR}
type -P docker >/dev/null && DOCKER=$(which docker)
type -P podman >/dev/null && DOCKER=$(which podman)
get_src_rpm_url() {
local __package=${1}
local __resultvar=${2}
if ! local __jsonline=$(curl -s https://src.fedoraproject.org/_dg/bodhi_updates/rpms/${1} | grep -e "fc${FROMFEDORA}\","); then
echo "ERROR : No ${1} release available for Fedora ${FROMFEDORA}"
echo "Please check https://src.fedoraproject.org/rpms/${PACKAGE} to choose the right release."
exit 1
fi
local __version=$(echo "${__jsonline}" | sed -e "s/^\s*\"stable\": \"${1}-\(.*\)\.fc${FROMFEDORA}\",\s*$/\1/")
for repo in releases updates; do
local __url=https://dl.fedoraproject.org/pub/fedora/linux/${repo}/${FROMFEDORA}/Everything/source/tree/Packages/${__package::1}/${__package}-${__version}.fc${FROMFEDORA}.src.rpm
if curl -sSLfI ${__url} 1>/dev/null 2>/dev/null; then
eval $__resultvar="'${__url}'"
return 0
fi
done
exit 1
}
get_src_rpm_url ${PACKAGE} PACKAGE_SRC_RPM_URL
get_src_rpm_url gettext GETTEXT_SRC_RPM_URL
ARCH=$(${DOCKER} run --rm docker.io/library/rockylinux:8 uname -i)
mkdir /tmp/dockerrpmbuild-$$
${DOCKER} run -i --rm -v /tmp/dockerrpmbuild-$$:/out:Z --privileged docker.io/library/rockylinux:8 <<EOF
dnf install -qy epel-release
dnf install -qy mock
useradd mockbuilder
usermod -a -G mock mockbuilder
runuser -l mockbuilder -c 'mock --localrepo=/tmp/ --chain -r rocky+epel-8-${ARCH} ${GETTEXT_SRC_RPM_URL} ${PACKAGE_SRC_RPM_URL}'
mv -f /tmp/results/*/${PACKAGE}-*/*.rpm /out/
EOF
[[ $? == 0 ]] && mv -i /tmp/dockerrpmbuild-$$/*.rpm ${ABSDIR}/files/ && rm -rf /tmp/dockerrpmbuild-$$

View File

@ -1,54 +0,0 @@
#!/usr/bin/env bash
FROMFEDORA='36'
PACKAGE='msmtp'
GETTEXT_FC='34'
GETTEXT_VERSION='0.21-4'
ABSDIR="$( dirname "$(readlink -f -- "$0")" )"
cd ${ABSDIR}
type -P docker >/dev/null && DOCKER=$(which docker)
type -P podman >/dev/null && DOCKER=$(which podman)
if ! JSONLINE=$(curl -s https://src.fedoraproject.org/_dg/bodhi_updates/rpms/${PACKAGE} | grep -e "fc${FROMFEDORA}\","); then
echo "ERROR : No ${PACKAGE} release available for Fedora ${FROMFEDORA}"
echo "Please check https://src.fedoraproject.org/rpms/${PACKAGE} to choose the right release."
exit 1
fi
VERSION=$(echo "${JSONLINE}" | sed -e "s/^\s*\"stable\": \"${PACKAGE}-\(.*\)\.fc${FROMFEDORA}\",\s*$/\1/")
ARCH=$(${DOCKER} run --rm docker.io/library/rockylinux:8 uname -i)
${DOCKER} build -t localhost/docker-${PACKAGE}-build -f- . <<EOF
FROM docker.io/library/rockylinux:8
RUN dnf install -y epel-release dnf-plugins-core && \
dnf config-manager --set-enabled powertools && \
dnf install -y rpm-build gcc make gettext gnutls-devel libgsasl-devel libidn-devel libsecret-devel autoconf automake emacs gcc-c++ glibc-langpack-de glibc-langpack-fa glibc-langpack-fr glibc-langpack-ja glibc-langpack-tr glibc-langpack-zh libacl-devel libunistring-devel libxml2-devel ncurses-devel teckit texinfo-tex texlive-dvipdfmx texlive-dvips texlive-xetex git && \
useradd -m dontbuildasroot -s /bin/bash
USER dontbuildasroot
RUN rpmbuild --rebuild https://dl.fedoraproject.org/pub/archive/fedora/linux/releases/${GETTEXT_FC}/Everything/source/tree/Packages/g/gettext-${GETTEXT_VERSION}.fc${GETTEXT_FC}.src.rpm
USER root
RUN rpm -Uvh /home/dontbuildasroot/rpmbuild/RPMS/x86_64/gettext-devel-${GETTEXT_VERSION}.el8.x86_64.rpm \
/home/dontbuildasroot/rpmbuild/RPMS/x86_64/gettext-libs-${GETTEXT_VERSION}.el8.x86_64.rpm \
/home/dontbuildasroot/rpmbuild/RPMS/x86_64/gettext-${GETTEXT_VERSION}.el8.x86_64.rpm \
/home/dontbuildasroot/rpmbuild/RPMS/noarch/gettext-common-devel-${GETTEXT_VERSION}.el8.noarch.rpm \
/home/dontbuildasroot/rpmbuild/RPMS/x86_64/libtextstyle-${GETTEXT_VERSION}.el8.x86_64.rpm
USER dontbuildasroot
RUN rpmbuild --rebuild https://download-ib01.fedoraproject.org/pub/fedora/linux/updates/${FROMFEDORA}/Everything/source/tree/Packages/m/${PACKAGE}-${VERSION}.fc${FROMFEDORA}.src.rpm
EOF
[[ $? = 0 ]] && mkdir /tmp/dockerrpmbuild-$$
${DOCKER} build --no-cache -v /tmp/dockerrpmbuild-$$:/out:Z -t docker-${PACKAGE}-xfer -f- . <<EOF
FROM localhost/docker-${PACKAGE}-build
USER root
RUN mv -f /home/dontbuildasroot/rpmbuild/RPMS/*/*.rpm /out/
EOF
[[ $? == 0 ]] && mv -i /tmp/dockerrpmbuild-$$/*.rpm ${ABSDIR}/files/ &&
rm -rf /tmp/dockerrpmbuild-$$ &&
${DOCKER} rmi -f docker-${PACKAGE}-build &&
${DOCKER} rmi -f docker-${PACKAGE}-xfer

View File

@ -4,4 +4,4 @@
tasks:
- name: "Include ansible_msmtp_mailer"
include_role:
name: "ansible_msmtp_mailer"
name: "ansible-msmtp-mailer"

View File

@ -8,14 +8,6 @@ lint: |
yamllint .
ansible-lint
platforms:
- name: centos8
image: geerlingguy/docker-centos8-ansible:latest
command: ""
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
capabilities:
- SYS_ADMIN
pre_build_image: true
- name: rockylinux8
image: geerlingguy/docker-rockylinux8-ansible:latest
command: ""
@ -24,7 +16,15 @@ platforms:
capabilities:
- SYS_ADMIN
pre_build_image: true
- name: rockylinux9
image: geerlingguy/docker-rockylinux9-ansible:latest
command: ""
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
capabilities:
- SYS_ADMIN
pre_build_image: true
provisioner:
name: ansible
vefifier:
verifier:
name: ansible

View File

@ -1,10 +1,16 @@
---
- 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: Include tasks depending on OS
ansible.builtin.include_tasks:
file: "{{ item }}"
apply:
tags:
- wg-install
with_first_found:
- "setup-{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version }}.yml"
- "setup-{{ ansible_distribution | lower }}-{{ ansible_distribution_version }}.yml"
- "setup-{{ ansible_distribution | lower }}-{{ ansible_distribution_release }}.yml"
- "setup-{{ ansible_distribution | lower }}.yml"
- "setup-{{ ansible_os_family | lower }}.yml"
- name: Ensure group "msmtp" exists
group:
@ -12,16 +18,11 @@
state: present
when: ansible_os_family == "RedHat"
- name: Install msmtp
yum:
name:
- "{{ msmtp_rpm_file }}"
- mailx
state: present
disable_gpg_check: yes
notify:
- test mail
- restart msmtpd
- name: Copy systemd unit file to server
copy:
src: msmtpd.service
dest: /usr/lib/systemd/system/msmtpd.service
mode: 0444
when: ansible_os_family == "RedHat"
- name: Copy mstprc conf file.

12
tasks/setup-rocky-8.yml Normal file
View File

@ -0,0 +1,12 @@
---
- name: Install msmtp
yum:
name:
- "{{ msmtp_rpm_file }}"
- mailx
state: present
disable_gpg_check: yes
notify:
- test mail
- restart msmtpd
when: ansible_os_family == "RedHat"

17
tasks/setup-rocky-9.yml Normal file
View File

@ -0,0 +1,17 @@
---
- name: Fix msmtpd SELinux type context for msmtpd as a service
community.general.sefcontext:
target: '/usr/bin/msmtpd'
setype: bin_t
state: present
- name: Install msmtp
yum:
name:
- msmtp
- s-nail
state: present
notify:
- test mail
- restart msmtpd
when: ansible_os_family == "RedHat"

View File

@ -2,9 +2,9 @@
# Default settings that all others accounts inherit
defaults
auth on
tls on
tls_starttls on
auth {{msmtp_auth}}
tls {{msmtp_tls}}
tls_starttls {{msmtp_tls_starttls}}
{% if msmtp_tls_trust_file is defined %}
tls_trust_file {{msmtp_tls_trust_file}}
{% else %}