Skip to content

Commit

Permalink
alert updated
Browse files Browse the repository at this point in the history
  • Loading branch information
AmitGujar committed Oct 31, 2023
1 parent d8d59c0 commit 79a8dd8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
6 changes: 3 additions & 3 deletions alert.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

set_alert() {

curl -d "$1" http://20.219.177.208/home
curl -d "$1" ntfy.sh/cust0m_4nsible_9layb00k_Aler7
}

check_server() {
echo "Checking if the remote server is UP"
ping 52.191.26.64 -c 3

if [ $? -ne 0 ]; then
set_alert "Server is UP 🤩" >>/dev/null
set_alert "Server is UP 🤩"
else
echo "Server is not running 😭"
fi
Expand All @@ -25,4 +25,4 @@ send_ping() {
fi
done
}
# send_ping
send_ping
1 change: 1 addition & 0 deletions roles/kernel_upgrade/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
ascs_service: 11
db_service: 10
alert_url: https://ntfy.sh/cust0m_4nsible_9layb00k_Aler7
11 changes: 9 additions & 2 deletions roles/kernel_upgrade/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
register: stop_sap_service_10
changed_when: false

- name: Service Status \"{{ ascs_service }}\"
- name: Service Status "{{ ascs_service }}"
ansible.builtin.debug:
msg: "{{ stop_sap_service_10.stdout }}"

Expand Down Expand Up @@ -107,6 +107,13 @@
file: services.yaml
register: services_start

- name: Sending Alert
ansible.builtin.uri:
url: "{{ alert_url }}"
method: POST
body: "kernel upgrade is finished."
register: alert_sent

- name: Procedding with next task
ansible.builtin.meta: end_play
when: services_start.rc == 0
when: alert_sent.status == 200
4 changes: 2 additions & 2 deletions roles/kernel_upgrade/tasks/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
ansible.builtin.debug:
msg: "{{ kernel_version_output_new.stdout }}"

- name: Status is completed
ansible.builtin.meta: end_play
# - name: Status is completed
# ansible.builtin.meta: end_play
5 changes: 1 addition & 4 deletions upgrade.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/bash

source $HOME/kernelPlaybooks/alert.sh

start_upgrade() {
ansible-playbook -i config/inventory playbooks/main.yaml
if [ $? -ne 0 ]; then
Expand All @@ -23,6 +21,5 @@ start_upgrade() {
# fi
fi
echo "Kernel is upgraded on target machine"
set_alert "Kernel upgrade is successful ✅"
}
start_upgrade
start_upgrade

0 comments on commit 79a8dd8

Please sign in to comment.