Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3769411
D2003.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D2003.id.diff
View Options
diff --git a/pillar/viperserv/bots.sls b/pillar/viperserv/bots.sls
--- a/pillar/viperserv/bots.sls
+++ b/pillar/viperserv/bots.sls
@@ -31,6 +31,7 @@
- filesys
- seen
nickserv: on
+ ensure_is_live: on
Wearg:
realname: RabbitMQ broker client
@@ -43,6 +44,7 @@
# dependencies
- Wearg/Time.tcl
nickserv: on
+ ensure_is_live: on
TC2:
realname: Tau Ceti Central
@@ -50,8 +52,10 @@
scripts:
- TC2/Time.tcl
- TC2/Server.tcl
+ ensure_is_live: off
# For tests and QA
Aeschere:
realname: Æschere
scripts: {}
+ ensure_is_live: off
diff --git a/roles/viperserv/eggdrop/cron.sls b/roles/viperserv/eggdrop/cron.sls
new file mode 100644
--- /dev/null
+++ b/roles/viperserv/eggdrop/cron.sls
@@ -0,0 +1,65 @@
+#!py
+
+# -------------------------------------------------------------
+# Salt — Deploy eggdrop park
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# Created: 2018-11-10
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+# -------------------------------------------------------------
+# Data helper methods
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+
+def get_etc_dir():
+ if __grains__['os'] == 'FreeBSD':
+ return "/usr/local/etc"
+
+ return "/etc"
+
+
+def get_bin_dir():
+ if __grains__['os'] == 'FreeBSD':
+ return "/usr/local/bin"
+
+ return "/bin"
+
+
+def get_eggdrops():
+ '''Filter eggdrops to select the ones with ensure_is_live: True'''
+ return [botname
+ for botname, bot
+ in __pillar__['viperserv_bots'].items()
+ if 'ensure_is_live' in bot and bot['ensure_is_live']]
+
+
+# -------------------------------------------------------------
+# Configuration provider
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+
+def run():
+ script = get_bin_dir() + '/ensure-eggdrops-are-live'
+
+ return {
+ get_etc_dir() + '/eggdrops-live.conf': {'file.managed': [
+ {'source': 'salt://roles/viperserv/eggdrop/files/eggdrops-live.conf'},
+ {'template': 'jinja'},
+ {'context': {
+ 'eggdrops': get_eggdrops()
+ }},
+ ]},
+
+ script: {'file.managed': [
+ {'source': 'salt://roles/viperserv/eggdrop/files/ensure-eggdrops-are-live.sh'},
+ {'mode': 755},
+ ]},
+
+ 'eggdrop_crontab': {'cron.present': [
+ {'name': script},
+ {'minute': '*/5'},
+ {'identifier': 'viperserv.eggdrop'},
+ ]}
+ }
diff --git a/roles/viperserv/eggdrop/files/eggdrops-live.conf b/roles/viperserv/eggdrop/files/eggdrops-live.conf
new file mode 100644
--- /dev/null
+++ b/roles/viperserv/eggdrop/files/eggdrops-live.conf
@@ -0,0 +1,19 @@
+# -------------------------------------------------------------
+# ViperServ — Deploy eggdrop park
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# Source file: roles/viperserv/eggdrop/files/eggdrops-live.conf
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is managed by our rOPS SaltStack repository.
+#
+# Changes to this file may cause incorrect behavior
+# and will be lost if the state is redeployed.
+# </auto-generated>
+
+# Eggdrops to respawn on failure
+{% for eggdrop in eggdrops %}
+{{ eggdrop }}
+{%- endfor %}
diff --git a/roles/viperserv/eggdrop/files/ensure-eggdrops-are-live.sh b/roles/viperserv/eggdrop/files/ensure-eggdrops-are-live.sh
new file mode 100755
--- /dev/null
+++ b/roles/viperserv/eggdrop/files/ensure-eggdrops-are-live.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+while IFS=' ' read -r eggdrop; do
+ # Skip blank lines and comment lines
+ take_first_character="?"
+ first_character=${eggdrop%"${eggdrop#${take_first_character}}"}
+ if [ "$first_character" = "#" ]; then
+ continue
+ elif [ "$eggdrop" = "" ]; then
+ continue
+ fi
+
+ service eggdrop status "$eggdrop" > /dev/null
+ status=$?
+
+ if [ $status -ne 0 ]; then
+ service eggdrop restart "$eggdrop"
+ fi
+done < /usr/local/etc/eggdrops-live.conf
diff --git a/roles/viperserv/eggdrop/init.sls b/roles/viperserv/eggdrop/init.sls
--- a/roles/viperserv/eggdrop/init.sls
+++ b/roles/viperserv/eggdrop/init.sls
@@ -10,3 +10,4 @@
- .software
- .config
- .service
+ - .cron
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 24, 14:31 (5 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2260385
Default Alt Text
D2003.id.diff (4 KB)
Attached To
Mode
D2003: Ensure eggdrops are live
Attached
Detach File
Event Timeline
Log In to Comment