Getting Started with Salt Stack-the Other Configuration Management System Built with Python
Configuration Management
If you haven't used any type of configuration management system before, here is a simple example. Say you have a set of configurations and packages that you generally install for every Web server. You can keep these configuration directives in small text files and then instruct your servers to install these packages and configure them to your liking, every time you create a new server. You also can use configuration management to keep all of your servers updated once they have been created and respond to changes in packaging or new configurations.
Let's install the libpam-cracklib package, so you can add additional requirements for user passwords. I chose this package because it is useful for almost any server connected to the Internet. It allows you to set additional password requirements regarding length, and it requires that your users' passwords contain special characters or numerals. You easily could substitute any particular package you want. These examples do require that the package be available in your system's package manager though.
Storage of the Configuration Directives
Salt's configuration management directives and files are, by default, kept within the /srv/salt directory. This is where all your configuration files and any files you want to copy to any of your minions reside. Salt also includes a file server system as part of the configuration management features. Salt doesn't touch your master's system files though, so don't worry; all configuration management takes place within the /srv/salt directory.
Salt, by default, uses PyYAML (http://pyyaml.org) syntax for its template files, but numerous other templating languages are available as well. Be sure to follow the proper formatting techniques for YAML, which involves two spaces instead of tabs. I have found the on-line YAML parser (http://yaml-online-parser.appspot.com) to be invaluable when troubleshooting syntax issues with YAML files.
Enable Configuration Management
To enable the configuration management functionality within Salt, you need to
edit your master configuration file once again.
In /etc/salt, open your master file and locate the lines that refer to
file_roots. In the default configuration, this was around line 156. Now,
uncomment this directive by removing the # from the following lines:
file_roots:
base:
- /srv/salt
This tells Salt where to locate your configuration management files. Depending on how you installed Salt, you may need to create the /srv/salt directory.
Create a Top File or "Roadmap"
The base configuration file is known as a Top File, and it resides within the /srv/salt directory. Let's create one now. This file provides mappings for other files and can be used to set a base configuration for all servers. Again, with your favorite text editor, create a top.sls file within the /srv/salt directory. You can think of this file as a roadmap for different directions for each minion. Within your top.sls file, add the following lines:
base:
'*'
- servers
The base directive lets Salt know that this configuration is a base configuration
and can be applied to all machines. The wild-card '*'
targets every machine. The -
servers directive is an arbitrary name that allows you to recognize what the
directive pertains to. Feel free to choose something that makes sense to you.
This entry also refers to a particular configuration file that you will now create
to install the libpam-cracklib.
Create a Server-Specific Configuration File
After you save your top.sls file, create a new file called servers.sls within the /srv/salt directory. This file will hold your specific configuration, including the name of the package to be installed and also a reference to a configuration file. In the new servers.sls file, add the following:
libpam-cracklib:
pkg:
- installed
The first line is the name of the package specifically how your package manager refers to it. For example, the Apache HTTP server is called apache2 in aptitude-based package manager distributions, but httpd in yum-based package management systems. Make sure you use the proper name for the package depending on which package manager you are using. You can target specific package names using what Salt refers to as grains. Refer to the documentation for more information and advanced examples of using grains in SLS files to target distribution-specific systems (http://salt.readthedocs.org/en/latest/topics/tutorials/states_pt3.html#using-grains-in-sls-modules).
Lines 2 and 3 tell Salt what to do with this package. For this example, you want it
installed. To remove a package, you simply would change -
installed to - removed.
Remember, spacing is very important! On line two, there are two spaces before
pkg:, and on the third line, there are four spaces before
- installed. If you
receive any errors, check your syntax via an on-line YAML parser.
Ben Hosmer is a DEVOP with RadiantBlue Technologies where he develops and maintains Drupal sites and administers various servers. He is an open-source advocate and helps spread the use of Linux and other open-source software within the US government.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.
Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.
Sponsored by ActiveState
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?
| Non-Linux FOSS: libnotify, OS X Style | Jun 18, 2013 |
| Containers—Not Virtual Machines—Are the Future Cloud | Jun 17, 2013 |
| Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer | Jun 12, 2013 |
| Weechat, Irssi's Little Brother | Jun 11, 2013 |
| One Tail Just Isn't Enough | Jun 07, 2013 |
| Introduction to MapReduce with Hadoop on Linux | Jun 05, 2013 |
- Containers—Not Virtual Machines—Are the Future Cloud
- Non-Linux FOSS: libnotify, OS X Style
- Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer
- RSS Feeds
- Introduction to MapReduce with Hadoop on Linux
- Validate an E-Mail Address with PHP, the Right Way
- Tech Tip: Really Simple HTTP Server with Python
- Weechat, Irssi's Little Brother
- Linux Systems Administrator
- Help with Designing or Debugging CORBA Applications
- Reply to comment | Linux Journal
5 min 49 sec ago - Welcome to 1998
54 min 19 sec ago - notifier shortcomings
1 hour 18 min ago - heroku?
2 hours 54 min ago - Android User
2 hours 56 min ago - Reply to comment | Linux Journal
4 hours 49 min ago - compiling
7 hours 39 min ago - This is a good post. This
12 hours 52 min ago - Great, This is really amazing
12 hours 53 min ago - These posts are really good
12 hours 55 min ago



Comments
Phyton or Java?
Phyton is a good language for development.And Java? Is better? cheats
Reply to comment | Linux Journal
Itѕ liκе уou rеаd my mіnd!
You aрpеar to know ѕo much about this, lіke you ωrоte the boοk
in іt oг somethіng. I thіnκ that you
сould do ωіth a few pics to ԁrіve
the message hοmе a littlе bit, but οthег than that, thiѕ is еxcеllеnt blog.
A greаt reаd. I'll certainly be back.
How would you deploy multiple
How would you deploy multiple folders, say your application files. can we use something http://www.hairwigs.de/ like RSYNC ? I know Puppet has such a module. Salt also has a CI module in Github. Would anyone know more ?
Perücken
Perücken
Ok, but...
Phyton is a good language for development. cheats
I have read this marvelous
I have read this marvelous post. Thanks for sharing information about it. Thank you for giving me another point of view on this topic. Now I can easily complete my article
Archeage Gold | ffxiv gil
It sounds perfect for my
It sounds perfect for my goals,
Thanks & Regards
James
Reply to comment | Linux Journal
Do you mind if I quote a few of your posts as long as I provide credit
and sources back to your webpage? My website is in the exact same niche as yours and my
visitors would certainly benefit from a lot of the information you present
here. Please let me know if this alright with you.
Cheers!
Very useful
I am a beginner and this was a great intro to Salt.
I found the article via this article on deploying Django with Salt:
http://www.barrymorrison.com/2013/Mar/11/deploying-django-with-salt-stack/
Watching a Project Folder
How would you deploy multiple folders, say your application files. can we use something like RSYNC ? I know Puppet has such a module. Salt also has a CI module in Github. Would anyone know more ?
Critical typo
Hi. I fairly certain that I found a typo in the top.sls example. The second line should end with a colon.
base:
'*':
- servers
Thanks,
Joshua
Founder, Wrale Ltd
agreed.
Yup Joshua,
I see that too... but it seems a bit blatant..
A minor error in your first page...
I don't believe you meant to say: "Note: I use the terms Salt and Salt interchangeably throughout this article"
A dive into Salt Stack
http://opencredo.com/blog/a-dive-into-salt-stack
Doubts related to remote server configuration using Salt
Hello,
You've mentioned that system package manager should be available with the package that we are trying to install. Is there any way to perform tasks like source compiling as we do while accessing the machine remotely via SSH. And thank you very much for the fantastic Blog.
Thanks,
Karthik