In this post I want to give information about top file. The top file is used to identify which SLS modules will be loaded onto what minions . Basically it maps minions to modules and states.  For one environment, in our master configuration file we refer our top file like:

    - /srv/salt

But if we have also a development environment :

    - /srv/salt/base
    - /srv/salt/dev

And now our top file for a single environment :

    - nagios

I want to explain more by giving another example. Let’s say that we have a top.sls file like below:

        - nagios

        - match: grain
        - apache2

        - match: grain_pcre
        - httpd

        - match: list
        - database

    'test* or G@role:development':
        - match: compound
        - test

In this top.sls file all minions get nagios state ( assume that we have configured our state file as installing nrpe and configuration files ). Any minion which has Ubuntu operating system will get apache2 state. And for all Redhat or Centos minions will get httpd states ( again assume that we declared our states with pkg.install http server ). For our configured list we match for db1,db2,db3 and we tell them get the database state ( for example install mysql ). And finally minions which names starting with test or have grain role as development will get test state. As a summary we match our minions and tell them which states they should have.

Amazon EC2 Part 2,Configure Instance Details
Amazon EC2 Part 3, Storage, Tagging and Security Groups


IT Infrastructure Manager, PMP, AWS Certified Solutions Architect

Leave a Reply