Imperative versus Declarative in Configuration Management Systems SaltStack :

Imperative versus Declarative in Configuration Management Systems SaltStack

Configuration Management System:

In this post we will discuss about the Imperative versus Declarative in Configuration Management Systems, Contention between various configuration management systems is the concept of declarative versus imperative configurations.

imperative:

It may be easiest to think of imperative programming like a script:

perform Task 1

and, when it is finished, perform Task 2; once that has finished, perform Task 3. This is what many administrators are used to, especially as it more closely resembles the shell scripts that have been their lifelines for so many decades.

Chef is an example of a configuration management suite that is imperative in nature.

Declarative:

It is a newer concept and more representative of object oriented programming.

The basic idea is, the user declares which tasks need to be performed and the software performs them in whichever order it sees fit.

Generally, dependencies can also be declared that dictate that some tasks are not to be completed until others are.

Puppet is a well-known example of a configuration management platform that is declarative in nature.

Imperative versus Declarative in Configuration Management Systems SaltStack

Imperative versus Declarative in SaltStack:

In our case – SALTSTACK:

Salt is unique in that it supports both imperative ordering and declarative execution.If no dependencies are defined then, by default Salt will attempt to execute States in the order in which they appear in the SLS files.

If dependencies are defined, States will be handled differently. They will still be evaluated in the order in which they appear, but dependencies can cause them to be executed in a different order. Consider the following Salt

State:

apache_service:

service.running:

  – name: httpd

apche_pkg:

pkg.installed:

  – name: httpd

apache_file:

file.managed:

  – name: /etc/httpd/conf/httpd.conf

  – source: salt://httpd.conf

In the first several versions of Salt that supported States, this would have been evaluated lexicographically: the file would have been copied into place first, then the package installed, then the service started, because in the English alphabet, F comes before P, and P comes before S. Happily, this is also the order that is probably desired.

Diving into Salt Internals

However, the default ordering system now in Salt is imperative, meaning States will be evaluated in the order in which they appear. Salt will attempt to start the apache service, which will fail because the package is not installed. It will then attempt to install the apache package, which will succeed. If this is a Debian-based system, installation of the package will also cause the service to start, in this case without the correct configuration file.

Lastly, Salt will copy the configuratoin file into place, but will make no attempt to restart the service to apply the correct changes. A second State run will report success for all three States (the service is running, the package is installed, and the file is managed as requested), but a manual restart of the apache service will still be.

Requisites:

To overcome the ordering issues Salt uses requisites,

Requisites(https://docs.saltstack.com/en/latest/ref/states/requisites.html)

will affect the order in which States are evaluated and executed.

apache_service:

service.running:

  – name: httpd

  – require:

  – pkg: apache_service

  – watch:

  – file: apache_service

pkg.installed:

  – name: httpd

  – require:

  – file: apache_service

file.managed:

  – source: salt://httpd1.conf

  – name: /etc/httpd/conf/httpd.conf

The order that will be defined in the state file is like,

service, pkg and file manage order. But the service require the apache pkg to execute first, so before executing the apache service, it will look ahead and evaluate the apache package. But, since it requires the apache config file to be executed first, it will jump ahead and evaluate the apache config file.

Once the service state completed successfully then it will check the next state and see if it has already been executed. It will continue in this fashion until all States have been evaluated and executed.

Share on facebook
Facebook
Share on twitter
Twitter
Share on pinterest
Pinterest
Share on linkedin
LinkedIn
More Interested Related Posts
zfs pool usage

ZFS Pool and Dataset Usage

ZFS Pool and Dataset Usage   I am back with another blog to provide the useful script to the Freebsd users to determine the zpool

Assistanz Networks

Installing Zabbix Agent in FreeBSD 12.0

Zabbix Agent Installation and Configuration Guide on FreeBSD 12.0   Zabbix is an open-source monitoring software tool for diverse IT components, including networks, servers, virtual

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