assistanz
Assistanz

REACTOR FOR EVENT DRIVEN INFRASTRUCTURE SALTSTACK

REACTOR FOR EVENT DRIVEN INFRASTRUCTURE SALTSTACK

(This post is continuation of ENABLING BEACONS IN SALTSTACK.)

In this post we are going to create the reactor for event driven infrastructure saltstack, Salt’s Reactor system gives Salt the ability to trigger actions in response to an event. It is a simple interface to watching Salt’s event bus for event tags that match a given pattern and then running one or more commands in response.

Description: Ubuntu 16.04.2 LTS

Saltmaster: 192.168.232.70

host1: 192.168.232.71

host2: 192.168.232.72

Reactor config for Service(Nginx and Diskusage):

# cat /etc/salt/master.d/reactor.conf

reactor:

– ‘salt/beacon/*/service/’:

– /srv/reactor/nginx-mon.sls

reactor for event driven infrastructure saltstack

Reactor config-handler:

# cat /srv/reactor/nginx-mon.sls

{% if data[‘id’] %}

web_state_run:

local.state.apply:

– tgt: {{ data[‘id’] }}

– arg:

– webserver.nginx_up

{% endif %}

reactor for event driven infrastructure saltstack

# cat /srv/reactor/disk-cleanup.sls

{% if data[‘id’] %}

cleanup_tmp_dir:

local.state.apply:

– tgt: {{ data[‘id’] }}

– arg:

– disk-cleanup

{% endif %}

reactor for event driven infrastructure saltstack

Reactor execution state file:

# cat /srv/salt/webserver/nginx_up.sls

make_nginx_online:

service.running:

– name: nginx

reactor for event driven infrastructure saltstack

# cat /srv/salt/disk-cleanup.sls

clean_tmp_directory:

file.absent:

– name: /tmp/bigfile2

reactor for event driven infrastructure saltstack

Let us restart the salt-master service.

on salt-master:

# salt-run state.event pretty=True

(or)

We can see even more information by starting the salt-master into debug mode, lets check the below command.

# salt-master -l debug

(use killall -9 salt-master if you unable to start the salt-master in debug-mode and with error like service already listening)

On the event bus:

Reactor check Nginx service:

reactor for event driven infrastructure saltstack

reactor for event driven infrastructure saltstack

Reactor check disk usage:

reactor for event driven infrastructure saltstack

– (run the command: ‘dd if=/dev/zero of=/tmp/bigfile2 bs=1M count=2000’ on minion to increase the diskspace)

reactor for event driven infrastructure saltstack

The disk space exceeds the limit now, lets see the reactor

reactor for event driven infrastructure saltstack

reactor for event driven infrastructure saltstack

Reactor check through debug-mode:

Nginx service:

We need to stop the salt-master service,

# systemctl stop salt-master

Start the salt-master in debug-mode.

# salt-master -l debug

We can see lot of debug and info messages on the screen,

reactor for event driven infrastructure saltstack

reactor for event driven infrastructure saltstack

reactor for event driven infrastructure saltstack

Disk usage:

reactor for event driven infrastructure saltstack

– (run the command: ‘dd if=/dev/zero of=/tmp/bigfile2 bs=1M count=2000’ on minion to increase the diskspace)

reactor for event driven infrastructure saltstack

The disk space exceeds the limit now, lets see the reactor

– disk-cleanup.sls contents should be based on your circumstances, no need to use the same like /tmp/bigfile2.

reactor for event driven infrastructure saltstack

clip_image025

As we already created the file bigfile2 under the /tmp, so that we have added to remove that file to make the disk usage within the limit, you can use files based on your environment or disk usage.

Video:

Thanks!!

DirectAdmin Server Management Plans

Premium Support

24/7 End User Support from your Helpdesk
$ 99 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Emergency Phone
  • Chat Support for Admin
  • Separate Account Manager
  • NDA & SLA
  • SLA Review Meetings
  • FREE Consultancy Services
  • Simple SignUp Process
  • Instant Account Activation
  •  

Platinum Support

24/7 Proactive Support
$ 49 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Emergency Phone
  • Chat Support for Admin
  • Separate Account Manager
  • Advance Proactive Monitoring
  • Guaranteed SLA
  • SLA Review Meetings
  • 3rd Party Application Support
  • FREE Consultancy Services
  • Server Migration Support
  • Weekly Status Report
  • No End User Support
Popular

Unlimited Support

24/7 Support

$ 30 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Support
  • Basic Monitoring
  • 30 Minutes Response Time
  • 4 Hours Resolution time for the Possible Issues
  • Security and Performance Optimization
  • React to Customers queries
  • Simple SignUp Process
  • Instant Account Activation
  • No Third party application support
  • No Migration and End User Support

Cpanel Server Management Plans

Premium Support

24/7 End User Support from your Helpdesk

$ 99 Monthly / Server
  • 24/7 End User White Label Support
  • Unlimited Number of Tickets
  • Chat Support for Admin
  • Separate Account Manager
  • Guaranteed SLA
  • Weekly Status Reports
  • FREE Consultancy Services
  • Simple SignUp Process
  • Instant Account Activation

Platinum Support

24/7 Proactive Server Management
$ 49 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Emergency Phone
  • Chat Support for Admin
  • Separate Account Manager
  • Advance Proactive Monitoring
  • Guaranteed SLA
  • SLA Review Meetings
  • 3rd Party Application Support
  • FREE Consultancy Services
  • Server Migration Support
  • Weekly Status Report
  • No End User Support
Popular

Unlimited Support

24/7 Server Management

$ 29 Monthly / Server
  • Unlimited Admin Tasks
  • 24/7 Support
  • Basic Monitoring
  • 30 Minutes Response time
  • 4 hours Response time for possible issues
  • Security and Performance Optimization
  • React to Customers queries
  • No Third party application support
  • No Migration and End User Support

Cpanel Server Management Plans

Premium Support

24/7 End User Support from your Helpdesk

$ 99 Monthly / Server
  • 24/7 End User White Label Support
  • Unlimited Number of Tickets
  • Chat Support for Admin
  • Separate Account Manager
  • Guaranteed SLA
  • Weekly Status Reports
  • FREE Consultancy Services
  • Simple SignUp Process
  • Instant Account Activation

Platinum Support

24/7 Proactive Server Management
$ 49 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Emergency Phone
  • Chat Support for Admin
  • Separate Account Manager
  • Advance Proactive Monitoring
  • Guaranteed SLA
  • SLA Review Meetings
  • 3rd Party Application Support
  • FREE Consultancy Services
  • Server Migration Support
  • Weekly Status Report
  • No End User Support
Popular

Unlimited Support

24/7 Server Management

$ 29 Monthly / Server
  • Unlimited Admin Tasks
  • 24/7 Support
  • Basic Monitoring
  • 30 Minutes Response time
  • 4 hours Response time for possible issues
  • Security and Performance Optimization
  • React to Customers queries
  • No Third party application support
  • No Migration and End User Support