From c8b0d9fb1cfe7253eed2e629462d7f07b248f4aa Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Tue, 24 Sep 2024 12:27:24 +0200 Subject: [PATCH] refs #8025 send-mail made generic --- inventories/group_vars/all.yml | 1 + playbooks/debian-upgrade.yml | 6 ++-- playbooks/freeradius.yml | 6 ++-- playbooks/nsupdate.yml | 6 ++-- playbooks/ping.yml | 2 +- playbooks/send-mail.yml | 7 ++--- playbooks/test.yml | 6 ++-- playbooks/windows-ping.yml | 4 +-- playbooks/windows-update.yml | 50 +++++++++++++++++----------------- roles/send-mail/tasks/main.yml | 10 +++---- 10 files changed, 49 insertions(+), 49 deletions(-) diff --git a/inventories/group_vars/all.yml b/inventories/group_vars/all.yml index 796f56d..9578df8 100644 --- a/inventories/group_vars/all.yml +++ b/inventories/group_vars/all.yml @@ -7,6 +7,7 @@ resolv: resolvers: - '10.0.0.4' - '10.0.0.5' +awx_email: awx@verdnatura.es awx_pub_key: > ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDjeIZVyppFK/dqOUa1PxgSeRVWk7MFmANYvSs+VHHn D4/BE//K8AxlxnyLl4e6jAcBFoIu1JLxbRKdOhx+Zgkq5OmEzp/XKzfEvnEU5CP+W2+5MwfkUQ3TetJs diff --git a/playbooks/debian-upgrade.yml b/playbooks/debian-upgrade.yml index 8215cb2..76ef424 100644 --- a/playbooks/debian-upgrade.yml +++ b/playbooks/debian-upgrade.yml @@ -1,5 +1,5 @@ - hosts: all tasks: - - name: Upgrade system - import_role: - name: debian-upgrade + - name: Upgrade system + import_role: + name: debian-upgrade diff --git a/playbooks/freeradius.yml b/playbooks/freeradius.yml index 2783ef1..086923b 100644 --- a/playbooks/freeradius.yml +++ b/playbooks/freeradius.yml @@ -1,5 +1,5 @@ - hosts: all tasks: - - name: Install and configure Freeradius with TOTP - import_role: - name: freeradius \ No newline at end of file + - name: Install and configure Freeradius with TOTP + import_role: + name: freeradius \ No newline at end of file diff --git a/playbooks/nsupdate.yml b/playbooks/nsupdate.yml index 454bb43..0b575f7 100644 --- a/playbooks/nsupdate.yml +++ b/playbooks/nsupdate.yml @@ -1,5 +1,5 @@ - hosts: ns1 tasks: - - name: Configure zone with nsupdate - import_role: - name: nsupdate \ No newline at end of file + - name: Configure zone with nsupdate + import_role: + name: nsupdate \ No newline at end of file diff --git a/playbooks/ping.yml b/playbooks/ping.yml index 55c6a68..8661c51 100644 --- a/playbooks/ping.yml +++ b/playbooks/ping.yml @@ -1,3 +1,3 @@ - hosts: all tasks: - - ping: \ No newline at end of file + - ping: \ No newline at end of file diff --git a/playbooks/send-mail.yml b/playbooks/send-mail.yml index 64aad1e..201fece 100644 --- a/playbooks/send-mail.yml +++ b/playbooks/send-mail.yml @@ -1,7 +1,6 @@ - hosts: localhost become: no - become_method: sudo tasks: - - name: Send mail - import_role: - name: config-send-mail + - name: Send mail + import_role: + name: send-mail diff --git a/playbooks/test.yml b/playbooks/test.yml index 65fd033..a056033 100644 --- a/playbooks/test.yml +++ b/playbooks/test.yml @@ -1,5 +1,5 @@ - hosts: all tasks: - - name: Test role - import_role: - name: debian-base + - name: Test role + import_role: + name: debian-base diff --git a/playbooks/windows-ping.yml b/playbooks/windows-ping.yml index 4fef2f5..0dd8dea 100644 --- a/playbooks/windows-ping.yml +++ b/playbooks/windows-ping.yml @@ -1,5 +1,5 @@ - name: Ping Windows hosts hosts: all tasks: - - name: Ping Windows hosts - ansible.windows.win_ping: \ No newline at end of file + - name: Ping Windows hosts + ansible.windows.win_ping: \ No newline at end of file diff --git a/playbooks/windows-update.yml b/playbooks/windows-update.yml index b3181a1..4a6cc78 100644 --- a/playbooks/windows-update.yml +++ b/playbooks/windows-update.yml @@ -1,28 +1,28 @@ - hosts: all serial: 1 tasks: - - block: - - name: Check if there are missing updates - win_updates: state=searched - register: update_count - - block: - - name: Install missing updates only if at least one is missing - win_updates: - category_names: '*' - #- Application - #- Connectors - #- DefinitionUpdates - #- DeveloperKits - #- FeaturePacks - #- Guidance - #- ServicePacks - #- Tools - #- UpdateRollups - #- CriticalUpdates - #- SecurityUpdates - log_path: C:\Win_Template_Patch.log - register: update_result - - name: Reboot, if needed. - win_reboot: - when: update_result.reboot_required - when: update_count.found_update_count|int >= 1 \ No newline at end of file + - block: + - name: Check if there are missing updates + win_updates: state=searched + register: update_count + - block: + - name: Install missing updates only if at least one is missing + win_updates: + category_names: '*' + #- Application + #- Connectors + #- DefinitionUpdates + #- DeveloperKits + #- FeaturePacks + #- Guidance + #- ServicePacks + #- Tools + #- UpdateRollups + #- CriticalUpdates + #- SecurityUpdates + log_path: C:\Win_Template_Patch.log + register: update_result + - name: Reboot, if needed. + win_reboot: + when: update_result.reboot_required + when: update_count.found_update_count|int >= 1 \ No newline at end of file diff --git a/roles/send-mail/tasks/main.yml b/roles/send-mail/tasks/main.yml index f7dbc94..071e12f 100644 --- a/roles/send-mail/tasks/main.yml +++ b/roles/send-mail/tasks/main.yml @@ -1,10 +1,10 @@ -- name: Send mail using Verdnatura SMTP servers +- name: Send mail using own SMTP server community.general.mail: - host: smtp.verdnatura.es + host: "{{ smtp_server }}" port: 465 - username: awx@verdnatura.es + username: "{{ awx_email }}" password: "{{ awx_smtp_password }}" to: "{{ sysadmin_mail }}" - subject: Ansible-test - body: System {{ ansible_hostname }} has been send successfully mail. + subject: Ansible test + body: System {{ ansible_fqdn }} has sent the email successfully. delegate_to: localhost