One place for hosting & domains

      A Beginner’s Guide to Affiliate Marketing

      There’s no shortage of ways you can make money online. However, few are as flexible and rewarding as affiliate marketing. If done right, it can be a lucrative way of earning an income by producing creative and valuable content.

      In a nutshell, affiliate marketing enables you to monetize your content by promoting other companies’ products using affiliate links. When somebody buys a product or service based on your referral, you earn a small commission on that purchase.

      In this article, we’ll introduce you to the basics of affiliate marketing and discuss how it works in practice. We’ll also show you how you could benefit from using it and give you some help getting started. Let’s begin!

      A Brief History of Affiliate Marketing (And How It Works)

      The DreamHost affiliate program.

      Monetizing your website doesn’t have to be a difficult or compromising endeavor. In fact, it can be incredibly rewarding, both from an economic and creative perspective. Plus, it doesn’t require a lot of the legwork involved in other methods of making money online.

      Affiliate marketing involves promoting products from external vendors on your own website. While definitions sometimes vary, there are generally three or four parties involved in an affiliate setup. Since these terms can be confusing, let’s take a moment to clarify the ‘who’s who’ of affiliate marketing:

      • The affiliate. Also known as ‘the marketer,’ this is the person running a site that contains affiliate links. The affiliate receives a commission on each purchase made by visitors who found a product by clicking on one of their links.
      • The consumer. This is a visitor on the affiliate site, who clicks on an affiliate link and completes a purchase (whether that’s the original item being promoted, or something else from the same company).
      • The network. This refers to the internal or third-party platform that the affiliate program is operated on. This means they’re the ones providing the links that the affiliates use and paying the affiliate their commissions.
      • The merchant. This is a company that sells products being marketed by the affiliate. In many cases, the merchant and the network are the same, as some companies run their own affiliate programs. For simplicity, we’ll be combining these last two entities throughout the rest of our discussion here.

      If that still sounds a bit confusing, let’s look at a typical real-life example of how an affiliate sale might work:

      1. An affiliate publishes a blog post on their site. The post is a review of a pair of sneakers, which are sold by the merchant.
      2. At the bottom of the post, the affiliate includes a link that leads to the sneakers’ product page.
      3. A consumer reads the blog post and, intrigued by the review, clicks on the affiliate link.
      4. Once on the merchant’s website, the consumer decides to purchase the sneakers.
      5. The merchant earns a profit off of the sale and shares a portion of that money with the affiliate.

      You might be curious about how the merchant knows which affiliate is responsible for the purchase. That’s actually the easy part since every affiliate is given a unique link that tracks each product they promote. This lets the merchant track all referrals using cookies to ensure that they know exactly how much money they’ve earned thanks to each affiliate (and what to pay them in return).

      How Affiliate Marketing Can Benefit You

      The potential to earn money by simply sharing links probably sounds tempting already. However, affiliate marketing comes with a whole host of advantages beyond the obvious one. Let’s take a look at some of the main ways being an affiliate marketer can benefit you and your site.

      First of all, it’s a low-risk and inexpensive business. The bare minimum for getting started as an affiliate is having a blog, a website, or even just a social media profile. This makes it a very cost-effective method for earning money. It also means you don’t have to commit a lot of cash up-front since you can start small and grow your marketing efforts over time.

      Another compelling aspect of affiliate marketing is that it lets you be creative, and provide something genuinely useful to your audience. Since you can use affiliate links pretty much anywhere, you can set up a review site, publish long-form articles, or even produce video content. Since you’re promoting other companies’ products, you don’t even need to worry about actually creating, shipping, and supporting the items yourself.

      Affiliate marketing also gives you the freedom to choose what you promote. In other words, it offers you the luxury of being picky. Not only do you get to decide precisely which programs to work with, but in most cases, you’ll even select the individual products and services you want to promote. As such, you always have full control over what’s featured on your site.

      The This Is Why I’m Broke affiliate website.

      Last but not least, affiliate marketing can be very lucrative (although keep in mind that it’s not a get-rich-quick scheme). Since you’re earning a percentage of every sale you refer, there’s no maximum ceiling for earnings either. This means that if your affiliate site takes off in a big way, you could potentially end up making a great passive income.

      With all of that in mind, you should have a fairly clear idea about whether affiliate marketing is something you’d like to get involved with. For many people, the benefits speak for themselves. However, before you start posting affiliate links, there are a number of things you’ll need to bear in mind.

      What to Consider Before Becoming an Affiliate Marketer

      Affiliate marketing definitely provides some impressive benefits, but that doesn’t mean you can jump in without preparation. To ensure that your work as an affiliate isn’t wasted, you’ll need to do a bit of planning and be aware of the potential drawbacks.

      We’re going to talk about some of those considerations in more detail later on. However, here is a brief overview of what you’ll need to do:

      • Find the right niche. Your niche determines your site’s subject matter, and by extension, what types of products or services you’ll promote. As such, finding a niche that’s both comfortable and potentially lucrative is vital.
      • Understand how to disclose your affiliate links. It’s imperative that you let visitors know your site contains affiliate links. Affiliate links come under the Federal Trade Commission’s guidelines of endorsements, after all. Plus, being transparent is a smart way to improve trust in your website and business (not to mention sales).
      • Avoid ‘affiliate theft’ at all costs. There are several illegitimate methods of increasing your commissions, which are collectively referred to as ‘affiliate theft’ or ‘commission theft.’ As such, you’ll need to make sure you only use proper, disclosed links at all times. Otherwise, you might end up like the scammer who used affiliate theft to steal $28 million from eBay.
      • Understand that being an affiliate is not ‘selling out.’ By promoting other companies’ products, you’re nothing but a pawn in their marketing schemes, right? While some people assume this, it really isn’t true. In fact, a key characteristic of most successful affiliates is that they provide honest and insightful content to go along with their links. Since you choose what to promote, there’s no need to bend the truth or connect your name to poor-quality products.
      • Be patient. Finally, affiliate marketing rarely leads to overnight success. Instead, it usually requires a lot of time and effort to slowly generate traffic and build an audience. This is especially true if you’re starting with a new or low-traffic site. It’s essential that you don’t expect quick results, and are ready to put in the work needed to grow your site and commissions.

      If you take some time to consider the above points carefully, you’ll start off prepared and with realistic expectations. This will give you a solid foundation upon which you can build your affiliate marketing career.

      Affiliate Marketing for Beginners (In 3 Steps)

      As we’ve already mentioned, affiliate marketing has a relatively low barrier to entry. To help you get started quickly, we’re going to walk you through the first steps for turning your site into an affiliate marketing success.

      Step 1: Choose a Suitable Affiliate Niche

      If you’re starting a new affiliate site, you’ll need to consider what niche you will work within. Your site’s niche determines what type of content you create, who your target audience is, and which kinds of products you will promote.

      Naturally, it’s crucial to choose a niche that’s financially viable. This means you need to find a subject that enough people will be interested in. That may seem tricky, but there are actually a lot of options you can choose from. Performing keyword research is also a smart idea at this stage, to find out what keywords are driving the most traffic via search engines.

      However, this step isn’t just about finding the niche that pays the most. To be successful, you should also aim for a niche that suits you personally. If you already have some knowledge and interest in your chosen area of focus, you’ll be in a position to create authoritative and engaging content to go along with your affiliate links.

      You’ll also have a better understanding of your target audience’s needs and desires. This is essential since it helps you build trust with your visitors. If they feel like they can rely on your judgment and recommendations, they’ll be more likely to click on your links and make purchases based on your suggestions. Therefore, the best niche will have plenty of potential consumers and will be something you can create knowledgeable and trustworthy content about.

      Step 2: Find and Sign Up for the Right Affiliate Programs

      Once you have a niche and site ready to go, it’s time to look for affiliate programs. As we mentioned previously, many programs are run directly by a merchant, with the goal of promoting their own company’s products.

      When deciding which programs to sign up for, you should first look at what products they want you to promote. Most importantly, they’ll need to offer products that are popular in your selected niche. Therefore, look for brands that speak to your target market, and see if they offer affiliate programs. For example, if your site is about running websites, you could look for web hosts with their own affiliate programs.

      In addition to merchant-driven programs, there are also dedicated affiliate networks, such as RakutenAwin, CJ, and Pepperjam. These programs encompass several different merchants and thousands of products. This gives you access to multiple types of products, without needing to join lots of programs. Even eCommerce giants like eBay and Amazon have their own successful affiliate programs.

      Amazon’s affiliate marketing program.

      Naturally, it’s also important to find programs that will pay you well. After all, you’re putting a lot of effort into promoting the merchants’ products, so you should see a fair share of the profits. Before you sign up, it’s also a smart move to research each program and see what experiences other affiliates have had.

      You might even find it useful to seek out an affiliate community, such as Wealthy Affiliate. There, you can get advice and help from those who have been publishing and marketing for a long time. This can be particularly helpful when you’re a novice. Then, in a few years’ time, you might be the one helping another beginner get started.

      Step 3: Add Affiliate Links to Your Site

      At this point, you’ve signed up for the best affiliate programs in your carefully chosen niche. Now it’s time to really get to work, which means sharing your affiliate links. Of course, how you actually implement these links on your site will vary, depending on what type of content you’re creating.

      For example, if you’re running a review site, it makes sense to place relevant affiliate links within your reviews. The simplest way of doing this is just to include them as text links in the content itself. However, this approach can be seen as misleading, since it’s less clear that you’re promoting the products in question.

      A better technique is to keep your links slightly separated from your main content. For instance, you can place them towards the end of each relevant post. The film site Birth.Movies.Death does this by featuring boxes with related products underneath its articles.

      An affiliate link on a post from Birth.Movies.Death.

      You can see a similar approach taken by OutdoorGearLab This site places links to each product’s page alongside the pricing information in its reviews.

      An affiliate link from OutdoorGearLab.

      Some affiliate programs will also provide you with assets, such as banners, that you can use to promote products. This might be more suitable if you want to keep your marketing and content clearly separated.

      As with your niche, your approach to implementing links will depend on your site’s purpose. Feel free to experiment with different strategies, but always remember that your focus should be on providing value to your audience. If you fail in that task, visitors won’t trust you, click on your links, or return in the future. Make sure you write quality content, therefore, and keep an eye on your conversions to see what’s working (and what’s not).

      Finally, we once again want to stress the importance of disclosing your affiliate links. This is a crucial part of complying with the endorsement guidelines provided by the FTC. Violating these guidelines could lead to legal action, which is naturally something you’ll want to avoid at all costs.

      As such, you should provide information about your links’ nature and purpose, which you can do by creating an ‘affiliate disclosure’ statement. The notice should be unambiguous, and clearly visible anywhere affiliate links are used. This will keep your site out of trouble, and help to promote trust with your audience.[a][b][d][e][f]


      The trouble with trying to make money online is that you’re rarely given the opportunity to be creative or to work with something you feel passionate about. In that sense, affiliate marketing is unique. This marketing technique enables you to monetize your own site, choosing exactly what products to promote and how.

      Do you have any questions about getting started with affiliate marketing? Join the DreamHost Community today and let’s discuss!

      Source link

      The Ultimate Guide to Website Localization

      It probably won’t surprise you to learn that English is the most common language on the web. However, it’s far from the only one. In fact, nearly half of all internet users have another native language aside from English. This means many websites are needlessly excluding a significant portion of their audiences.

      To avoid losing out on potential conversions and revenue, make the smart move to localize your site by translating it into one or more other languages. While this might seem difficult, or even impossible if you aren’t multilingual, you don’t need to worry. Today, it’s easier than ever to translate and localize a website.

      In this article, we’ll discuss the benefits of website localization and what it entails. We’ll also show you some methods you can use to create a multilingual site — even if you don’t speak a second language. Let’s go!

      A Quick Look at Language on the Web

      According to W3Techs, over half of all websites use the English language. This is hardly unexpected, considering that it’s the most commonly spoken language among internet users. In fact, more than a billion internet users speak English.

      However, while English may be the most common language, that’s not by a wide margin. It turns out that almost a fifth of internet users speak Chinese, for example, while over 8 percent speak Spanish. That’s hardly surprising, considering how common those languages are.

      What is somewhat shocking is how few sites cater to those same users.

      Returning to the first study we cited, it turns out that not even 5 percent of sites provide Spanish as a language option, while Chinese is available on less than 2 percent of sites. This means that literally billions of internet users are forced to use websites in a non-native language or are left out of a large portion of the web altogether.

      An Introduction to Website Localization

      Considering the facts above, it’s no wonder many people are attempting to make the internet less English-centric. This is usually done through a process known as localization, which is often shortened to ‘l10n.’ That term may sound strange, but it was coined because there are 10 letters between the “l” and “n” in “localization.”

      We should also mention that this strategy is sometimes confused with a process called internationalization, or ‘i18n’ (for the same reason as above). Where localization aims to adapt an existing product to suit another culture, internationalization is the process of making that product easy to localize in the first place.

      The WordPress Polyglots team is an example of how both l10n and i18n can be implemented in a single platform. This team works on making all aspects of WordPress easier to localize across regions, including providing help for theme and plugin developers.

      It’s also important to note that localization is not only about translating your site’s text. Although that is a key part of the process (and we’ll discuss it more in a moment), localization also involves adapting your site to another culture. For instance, it means making sure that currency, measurement units, and general terminology are updated accordingly.

      Localization can also mean altering other aspects of your site to suit different cultures. It turns out that what’s considered strong web design can vary based on your region. For example, some design elements like testimonials are much more highly valued in the US than they are in parts of Europe.

      Ultimately, this means that if you want to localize your site, you’ll need to do some research. For an idea of what can happen when a brand fails to do this, you can read about the time KFC told its Chinese customers to “eat their fingers off” or when Apple released a keyboard in Europe that wasn’t actually usable with many European languages.

      By now, you might be thinking that localization sounds like a hassle. While it will take some work, it turns out that it’s a crucial task for most sites.

      The Benefits of Localizing Your Site

      The fact is that proper localization benefits everyone. Not only does it help make the internet a more open and welcoming place, but it offers advantages to you and your site as well. Before we get into the practical details, therefore, let’s look at why you should bother localizing your site in the first place.

      For example, localizing your site helps you to:

      • Target a larger audience. Localization opens your site up to people who would otherwise not be able to use it.
      • Improve SEO and create localized SEO campaigns. You can create a unique URL for each localized version of your site, for instance, which can boost their rankings.
      • Increase your conversions. Users are more likely to convert if your site is in a language they’re fluent in.
      • Make your site more accessible. You’ll make it much easier for those who have a limited-to-no understanding of your site’s primary language to read and absorb your content.

      As you can see, localization is mutually beneficial to all parties involved. However, while this is something most website owners should consider, that doesn’t make it a task you should jump into without some careful planning.

      What You Need to Consider Before Localizing Your Site

      As you’ve likely gathered already, localization is a process that requires time, effort, and investment to get it right. For this reason, there are several questions you’ll need to answer before you even think about looking up the Japanese word for “website.”

      Naturally, the first thing you’ll need to do is consider which languages and regions to focus on. To narrow down your options, you can take a close look at your site’s analytics, as this will tell you which countries you have the most visitors from already. For instance, if you have plenty of traffic from Spain, you might want to consider creating a Spanish version of your site.

      It’s also a smart move to perform keyword research for specific locations. This will help you determine the demand (or lack thereof) for your services or products in a particular region. By doing this, you could end up finding an untapped market that you can appeal to by creating a localized site, especially for that audience.

      Once you’ve nailed down the major languages and regions for your audience, it’s time to consider the practical realities of localizing your site. We mentioned previously that this will require some market research, to find out how your site will need to change in terms of layout, images, messaging, and so forth.

      If you have the funds for it, you might even want to hire a team to help you with this project. Hiring translators is usually the most effective way of localizing a website, especially since you’ll need to maintain the new version of the site over time. Whenever you update or add content to your main site, it’s important that you are able to do the same on the localized versions.

      Finally, you’ll also need to think about implementation and compatibility. Fortunately, if you’re a WordPress user, you have much less to worry about. There are actually multiple plugins that can help you localize your site, including tools that perform automatic machine translation.

      How Automatic Translation Can Help You Localize Your Site

      Translating an entire website is typically the most time-consuming and costly aspect of localization. Depending on how much content your site contains and how often you update, this can require a significant investment and plenty of manpower.

      However, there is a way to make the process considerably easier, by letting a machine do the bulk of the work for you. This is known as automatic translation or sometimes machine translation. Chances are you’ve seen this in action on a smaller scale if you’ve ever used a tool like Google Translate.

      The Google Translate website.

      Without getting too technical, solutions like these automatically translate large volumes of content automatically from one language to another. The best part is that you can implement such a system on your site, automatically translating all text content as soon as it’s added.

      As you can imagine, this is much faster and cheaper than hiring one or more dedicated translators. Since there’s no waiting period between creating the original content and the translated version, you can ensure that every version of your site is up-to-date at all times.

      The main drawback of machine translation is that no solution is perfect, even though the technology has progressed rapidly since the days of Babel Fish. As such, you will most likely need to edit the translated versions at least, to make sure the content is still correct. However, even this task is far less time-consuming than translating everything from scratch.

      Another important consideration is which tool to use. We’ll look at some of the best options in a moment, but it’s critical you pick one that is compatible with all aspects of your site. For example, if your WordPress site contains a WooCommerce store, your translation plugin must be able to translate the e-commerce aspects as well.

      3 WordPress Plugins That Can Help You Translate Your Site

      Automatic translation is a great way to save time when localizing your site, but you’ll need the right tool for the job. Fortunately, as is usually the case, several WordPress plugins can help you out. We’re going to look at a handful of the best translation plugins right now, one by one.

      1. Weglot

      The Weglot plugin.

      Weglot makes it easy to create a multilingual site, even if you don’t speak any additional languages. This plugin uses machine translation to generate a fully-translated version of your entire site, which includes all page elements. It’s also compatible with just about any plugin or theme, including WooCommerce.

      Key Features:

      • Generates translated versions of your site in 60+ languages
      • Translates all text on your site, including navigational elements, comments, and more
      • Is compatible with all WordPress themes and plugins

      Pricing: Weglot offers a free plugin and a series of premium plans, which start at €9.99 (roughly $12) per month.

      2. Polylang

      The Polylang plugin.

      Polylang makes it easy to configure your site for localization. With this plugin, you can set the language for each post, and then create translated versions right in the standard WordPress editor. By default, Polylang offers the tools needed to create manual translations. However, you can also use it in conjunction with its sister plugin, Lingotek Translation, to perform automatic translations.

      Key Features:

      • Lets you easily translate your content in the standard WordPress interface
      • Enables you to use an unlimited number of languages
      • Provides WooCommerce support as a premium add-on

      Pricing: Polylang is available as a free plugin, as well as a Pro version that costs €99 (roughly $114) for a single site.

      3. WPML

      The WPML plugin.

      WPML is one of the most popular translation plugins, and it’s not hard to see why. This tool provides an intuitive interface that makes it easy to create and edit your translations. However, in contrast to the other plugins we’ve mentioned so far, WPML is mostly focused on manual translation. It works by assigning specific users the role of Translator, which makes it simple to track and manage your translation tasks within WordPress.

      Key Features:

      • Enables you to create manual translations within WordPress by assigning Translator users
      • Provides support for 40+ languages
      • Lets you generate language variants, such as Canadian French, using a language editor

      Pricing: WPML offers a number of paid tiers, which start at $29.

      How to Translate Your WordPress Site Using Weglot

      Now that we’ve looked at a few tools, let’s walk through how you can get started with localization by translating your site. For this example, we’ll be using the Weglot plugin that we covered earlier, as it’s free and includes automatic translation by default. This makes it an ideal choice if you want to test the waters before committing to a solution.

      To start off, you’ll want to install and activate Weglot. Once you’ve done that, you’ll be prompted to configure the plugin.

      Configuring the settings for Weglot.

      You’ll need an API key here, which is used to connect your site to Weglot’s cloud translation API. To get your own key, simply register for a free Weglot account.

      The registration form on the Weglot website.

      Once you’ve set up your account, you’ll be shown your API key. Copy this, and return to WordPress and the plugin’s settings. Paste your API key into the corresponding field, and then specify your site’s standard language and which language(s) you want to use for your translations.

      Then, click on Save Changes when you’ve finished. As soon as you’ve done that, you’ll see a message informing you that your site is now multilingual.

      A message informing you that your website is now multilingual.

      If you take a look at your site, you’ll see a new ‘language picker’ feature in the bottom-right corner.

      The Weglot language picker in the bottom-right corner of a WordPress site.When you click on this, you’ll see both your site’s default language and the one(s) you specified for translation.

      The Weglot language picker showing Norwegian and English options.

      If you select one of those alternative options, the site will reload and display in the specified language.

      An example of a WordPress site translated into Norwegian.

      You can also see that the URL for the site has changed, to include a code for the translated version. In our case, since we chose Norwegian, the plugin has appended /no/ to the end of the URL. As such, if the site’s address were, you could access the Norwegian version by using

      Now, this is just scratching the surface of what you can do with automatic translation. For one, you can return to the plugin’s settings to customize your language picker, both in appearance and position.

      The Weglot plugin settings.

      On this screen, you’ll also see a link to your Weglot dashboard, where you can manage and edit your translations.

      The Weglot dashboard.

      This dashboard gives you total control over all versions of your site and even shows you when and who edited individual text strings. This means that you can generate a translated version of your site in seconds, while also hiring a professional to edit the end result (if you like).

      As we mentioned earlier, translation is only one aspect of localizing your site. However, saving time when it comes to translating your site’s content will help you immeasurably, as it frees up resources to perform the necessary research and localization work on the rest of your site.

      The Language of Business

      Assuming all of your site’s potential visitors are fluent in your native language is not just arrogant, it can even be harmful to your business. By shutting the door on a significant portion of your audience, you could lose out on both traffic and conversions. As such, it’s well worth creating localized versions of your site.

      Do you have any questions about localizing your WordPress website? Join the DreamHost Community and let’s start the discussion!

      Source link

      A Beginner's Guide to Salt

      Updated by Linode Written by Linode

      Use promo code DOCS10 for $10 credit on a new account.

      Salt (also referred to as SaltStack) is a Python-based configuration management and orchestration system. Salt uses a master/client model in which a dedicated Salt master server manages one or more Salt minion servers. Two of Salt’s primary jobs are:

      This guide will introduce the core concepts that Salt employs to fulfill these jobs.

      Masters and Minions

      The Salt master is a server that acts as a command-and-control center for its minions, and it is where Salt’s remote execution commands are run from. For example, this command reports the current disk usage for each of the minions that the master controls:

      salt '*' disk.usage

      Many other commands are available. This installs NGINX on the minion named webserver1:

      salt 'webserver1' pkg.install nginx

      Salt minions are your servers that actually run your applications and services. Each minion has an ID assigned to it (which can be automatically generated from the minion’s hostname), and the Salt master can refer to this ID to target commands to specific minions.


      When using Salt, you should configure and manage your minion servers from the master as much as possible, instead of logging into them directly via SSH or another protocol.

      To enable all of these functions, the Salt master server runs a daemon named salt-master, and the Salt minion servers run a daemon named salt-minion.


      Communication between the master and minions is performed over the ZeroMQ transport protocol, and all communication is encrypted with public/private keypairs. A keypair is generated by a minion when Salt is first installed on it, after which the minion will send its public key to the master. You will need to accept the minion’s key from the master; communication can then proceed between the two.

      Remote Execution

      Salt offers a very wide array of remote execution modules. An execution module is a collection of related functions that you can run on your minions from the master. For example:

      salt 'webserver1' npm.install gulp

      In this command npm is the module and install is the function. This command installs the Gulp Node.js package via the Node Package Manager (NPM). Other functions in the npm module handle uninstalling NPM packages, listing installed NPM packages, and related tasks.

      The execution modules that Salt makes available represent system administration tasks that you would otherwise perform in a shell, including but not limited to:


      The function is used to run arbitrary commands on your minions from the master:

      salt '*' 'ls -l /etc'

      This would return the contents of /etc on each minion.


      Where possible, it’s better to use execution modules than to “shell out” with

      States, Formulas, and the Top File

      The previous section described how to use remote execution to perform specific actions on a minion. With remote execution, you could administer a minion by entering a series of such commands.

      Salt offers another way to configure a minion in which you declare the state that a minion should be in. This kind of configuration is called a Salt state, and the methodology is referred to generally as configuration management.

      The distinction between the two styles is subtle; to illustrate, here’s how installing NGINX is interpreted in each methodology:

      Salt states are defined in state files. Once you have recorded your states, you then apply them to a minion. Salt analyzes the state file and determines what it needs to do to make sure that the minion satisfies the state’s declarations.


      This sometimes results in the same command that would be run via remote execution, but sometimes it doesn’t. In the NGINX example, if Salt sees that NGINX was already installed previously, it won’t invoke the package manager again when the state is applied.

      Anatomy of a State

      Here’s an example state file which ensures that: rsync and curl are installed; NGINX is installed; and NGINX is run and enabled to run at boot:

          - pkgs:
            - rsync
            - curl
          - name: nginx
          - name: nginx
          - enable: True
          - require:
            - pkg: nginx_pkg

      State files end with the extension .sls (SaLt State). State files can have one or more state declarations, which are the top-level sections of the file (network_utilities, nginx_pkg, and nginx_service in the above example). State declarations IDs are arbitrary, so you can name them however you prefer.


      If you were to name the ID to be the same as the relevant installed package, then you do not need to specify the - name option, as it will be inferred from the ID. For example, this snippet also installs NGINX:

      The same name/ID inference convention is true for other Salt modules.

      State declarations contain state modules. State modules are distinct from execution modules but often perform similar jobs. For example, a pkg state module exists with functions analogous to the pkg execution module, as with the pkg.installed state function and the pkg.install execution function. As with execution modules, Salt provides a wide array of state modules for you to use.


      State declarations are not necessarily applied in the order they appear in a state file, but you can specify that a declaration depends on another one using the require option. This is the case in the above example; Salt will not attempt to run and enable NGINX until it is installed.

      State files are really just collections of dictionaries, lists, strings, and numbers that are then interpreted by Salt. By default, Salt uses the YAML syntax for representing states.

      State files are often kept on the Salt master’s filesystem, but they can also be stored in other fileserver locations, like a Git repository (in particular, GitHub).

      Applying a State to a Minion

      To apply a state to a minion, use the state.apply function from the master:

      salt `webserver1` state.apply webserver_setup

      This command applies the example webserver_setup.sls state to a minion named webserver1. When applying the state, the .sls suffix is not mentioned. All of the state declarations in the state file are applied.

      Salt Formulas

      Formulas are just collections of states that together configure an application or system component on a minion. Formulas are usually organized across several different .sls files. Splitting a formula’s states up across different files can make it easier to organize your work. State declarations can include and reference declarations across other files.

      Formulas that are sufficiently generic are often shared on GitHub to be used by others. The SaltStack organization maintains a collection of popular formulas. Salt’s documentation has a guide on using a formula hosted on GitHub.

      The definition of what constitutes a formula is somewhat loose, and the specific structure of a formula is not mandated by Salt.

      The Top File

      In addition to manually applying states to minions, Salt provides a way for you to automatically map which states should be applied to different minions. This map is called the top file.

      Here’s a simple top file:

          - universal_setup
          - webserver_setup

      base refers to the Salt environment. You can specify more than one environment corresponding to different phases of your work; for example: development, QA, production, etc. base is the default.

      Groups of minions are specified under the environment, and states are listed for each set of minions. The above example top file says that a universal_setup state should be applied to all minions ('*'), and the webserver_setup state should be applied to the webserver1 minion.

      If you run the state.apply function with no arguments, then Salt will inspect the top file and apply all states within it according to the mapping you’ve created:

      salt '*' state.apply


      This action is colloquially known as a highstate.

      Benefits of States and Configuration Management

      Defining your configurations in states eases system administration:

      • Setting up states minimizes human error, as you will not need to enter commands manually one-by-one.

      • Applying a state to minion multiple times generally does not result in any changes beyond the first application. Salt understands when a state has already been implemented on a minion and will not perform unnecessary actions.

      • If you update a state file and apply it to a minion, Salt will detect and only apply the changes, which makes updating your systems more efficient.

      • A state can be reused and applied to more than one minion, which will result in identical configurations across different servers.

      • State files can be entered into a version control system, which helps you track changes to your systems over time.

      Targeting Minions

      You can match against your minions’ IDs using shell style globbing. This works at either the command line or in the top file.

      These examples would apply the webserver_setup state to all minions whose ID begins with webserver (e.g. webserver1, webserver2, etc):

      Regular Expressions and lists can also be used to match against minion IDs.


      Salt’s grains system provides access to information that is generated by and stored on a minion. Examples include a minion’s operating system, domain name, IP address, and so on. You can also specify custom grain data on a minion, as outlined in Salt’s documentation.

      You can use grain data to target minions from the command line. This command installs httpd on all minions running CentOS:

      salt -G 'os:CentOS' pkg.install httpd

      You can also use grains in a top file:

          - match: grain
          - centos_setup

      Grain information generally isn’t very dynamic, but it can change occasionally, and Salt will refresh its grain data when it does. To view your minions’ grain data:

      salt '*' grains.items

      Storing Data and Secrets in Pillar

      Salt’s pillar feature takes data defined on the Salt master and distributes it to minions. A primary use for pillar is to store secrets, such as account credentials. Pillar is also a useful place to store non-secret data that you wouldn’t want to record directly in your state files.


      Let’s say that you want to create system users on a minion and assign different shells to each of them. If you were to code this information into a state file, you would need a new declaration for each user. If you store the data in pillar instead, you can then just create one state declaration and inject the pillar data into it using Salt’s Jinja templating feature.


      Salt Pillar is sometimes confused with Salt Grains, as they both keep data that is used in states and remote execution. The data that grains maintains originates from the minions, while the data in pillar originates on the master (or another backend) and is delivered to the minions.

      Anatomy of Pillar Data

      Pillar data is kept in .sls files which are written in the same YAML syntax as states:

          shell: /bin/zsh
          shell: /bin/bash
          shell: /bin/fish

      As with state files, a top file (separate from your states’ top file) maps pillar data to minions:

          - user_info

      Jinja Templates

      To inject pillar data into your states, use Jinja’s template syntax. While Salt uses the YAML syntax for state and pillar files, the files are first interpreted as Jinja templates (by default).

      This example state file uses the pillar data from the previous section to create system users and set the shell for each:

      {% for user_name, user_info in pillar['users'].iteritems() %}
      {{ user_name }}:
          - shell: {{ user_info['shell'] }}
      {% endfor %}

      Salt will compile the state file into something that looks like this before it is applied to the minion:

          - shell: /bin/zsh
          - shell: /bin/bash
          - shell: /bin/fish

      You can also use Jinja to interact with grain data in your states. This example state will install Apache and adjust the name for the package according to the operating system:

          {% if grains['os'] == 'CentOS' %}
          - name: httpd
          {% else %}
          - name: apache
          {% endif %}



      The beacon system is a way of monitoring a variety of system processes on Salt minions. There are a number of beacon modules available.

      Beacons can trigger reactors which can then help implement a change or troubleshoot an issue. For example, if a service’s response times out, the reactor system can restart the service.

      Getting Started with Salt

      Now that you’re familiar with some of Salt’s basic terminology and components, move on to our guide Getting Started with Salt – Basic Installation and Setup to set up a configuration to start running commands and provisioning minion servers.

      The SaltStack documentation also contains a page of best practices to be mindful of when working with Salt. You should review this page and implement those practices into your own workflow whenever possible.

      More Information

      You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.

      Join our Community

      Find answers, ask questions, and help others.

      This guide is published under a CC BY-ND 4.0 license.

      Source link