diff --git a/defaults/main.yml b/defaults/main.yml index 2971031e9acbb552cdaefe11f7fc865fbb55ed8b..8c49cfad49530aac36dc788d39d33e2e437e1844 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -36,6 +36,15 @@ ynh_users: null # lastname: Doe # mail_domain: domain.tld +# SMTP custom settings ( Only override if you need a SMTP relay) +ynh_smtp_get_cli: yunohost settings get smtp.relay +ynh_smtp_set_cli: yunohost settings set smtp.relay +ynh_new_smtp_relay: null + # host: smtp.domain.tld + # port: 25 + # user: user1 + # password: Pa$$w0rd + # The list of Yunohost apps. ynh_apps: null # - label: Tiny Tiny RSS diff --git a/tasks/main.yml b/tasks/main.yml index e0f8b73252fcbfd9ea571700081a93e3e69b58d4..9cb201e4125372bab0530c914d10c7c601c05522 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -60,6 +60,10 @@ ansible.builtin.command: yunohost domain cert-install changed_when: False +- name: Configure SMTP relay + ansible.builtin.include_tasks: smtp_relay.yml + when: ynh_new_smtp_relay + - name: Add Yunohost users ansible.builtin.include_tasks: users.yml when: ynh_users diff --git a/tasks/smtp_relay.yml b/tasks/smtp_relay.yml new file mode 100644 index 0000000000000000000000000000000000000000..4259de69a4e4140e5e2425597fdc97bf033717d1 --- /dev/null +++ b/tasks/smtp_relay.yml @@ -0,0 +1,72 @@ +--- +#-----------------------------------------------------------------------------# +# ansible-yunohost allows to deploy Yunohost using Ansible # +# Copyright 2021-2021 Lydra https://www.lydra.fr/ # +# # +# this program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# this program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see <http://www.gnu.org/licenses/>. # +# # +#-----------------------------------------------------------------------------# + +# - name: Get current SMTP relay host +# ansible.builtin.command: "{{ ynh_smtp_get_cli }}.host" +# register: ynh_old_smtp_relay_host +# changed_when: False + +# - name: Set new SMTP relay host +# ansible.builtin.command: "{{ ynh_smtp_set_cli }}.host -v {{ ynh_new_smtp_relay.host }}" +# when: ynh_old_smtp_relay_host.stdout != ynh_new_smtp_relay.host + +# - name: Get current SMTP relay port +# ansible.builtin.command: "{{ ynh_smtp_get_cli }}.port" +# register: ynh_old_smtp_port +# changed_when: False + +# - name: Set new SMTP relay port +# ansible.builtin.command: "{{ ynh_smtp_set_cli }}.host -v {{ ynh_new_smtp_relay.port }}" +# when: ynh_old_smtp_port.stdout != ynh_new_smtp_relay.port + +# - name: Get current SMTP relay username +# ansible.builtin.command: "{{ ynh_smtp_get_cli }}.user" +# register: ynh_old_smtp_user +# changed_when: False + +# - name: Set new SMTP relay username +# ansible.builtin.command: "{{ ynh_smtp_set_cli }}.user -v {{ ynh_new_smtp_relay.user }}" +# when: ynh_old_smtp_user.stdout != ynh_new_smtp_relay.user + +# - name: Get current SMTP relay password +# ansible.builtin.command: "{{ ynh_smtp_get_cli }}.password" +# register: ynh_old_smtp_password +# changed_when: False + +# - name: Set new SMTP relay password +# ansible.builtin.command: "{{ ynh_smtp_set_cli }}.host -v {{ ynh_new_smtp_relay.password }}" +# when: ynh_old_smtp_password.stdout != ynh_new_smtp_relay.password + +# - name: Set new SMTP relay port +# ansible.builtin.command: "{{ ynh_smtp_set_cli }}.host -v {{ ynh_smtp_relay.host }}" +# when: ynh_smtp_host_config.stdout != ynh_smtp_relay.host + +- name: Get current SMTP settings + ansible.builtin.command: + "{{ ynh_smtp_get_cli }}.{{ item }}" + register: _ynh_smtp_current_values + with_items: "{{ ynh_new_smtp_relay }}" + changed_when: False + +- name: Set new SMTP settings + ansible.builtin.command: + "{{ ynh_smtp_set_cli }}.{{ item.key }} -v {{ item.value }}" + with_items: "{{ ynh_new_smtp_relay | dict2items }}" + changed_when: False