1

A very similar version of this question is asked here , but it's completely different since the person had their top file in the wrong directory.

I have 3 projects, that I'll call project1, project2, and project3. My goal was to create a master/minion setup where my srv/salt directory looked like this:

/srv/salt
        |top.sls
        |/project1
                 |__/postgresql
                         |__init.sls
                         |__config.sql
                 |__/iptables
                         |__init.sls
                         |__config.sh
        |/project2
                 |__/tomcat
                         |__init.sls
                         |__config.sh
                 |__/java
                         |__init.sls
                         |__config.sh
        |/project3
                  |__/serverconfig
                         |__init.sls
                         |__config.sql
                 |__/conky
                         |__init.sls
                         |__config.sh

To accomplish this I edited /etc/salt/master to read

#/etc/salt/master
file_roots:
  base:
    - /srv/salt
  project1:
    - /srv/salt/project1
  project2:
    - /srv/salt/project2
  project3:
    - /srv/salt/project3

I also wanted to have nodes set up since I have static servers that will be involved in each project, and that's a very intuitive way for me to organize them.

I started by editing /etc/salt/master to show my nodegroups

#/etc/salt/master
nodegroups:
  project1: 'L@project1_server1,project1_server2,project1_server3'
  project2: 'L@project2_server1,project2_server2,project2_server3'
  project3: 'L@project3_server1,project3_server2,project3_server3'

When running the once this was set up, I tried applying the project1 state to its servers by using the following command:

salt -N project1 state.highstate

This completes correctly for project1_server2, project1_server3, but fails on project1_server1.

The error for project1_server1 is "No Top file or external nodes data matches found"

I'm open to suggestions for how this setup could be more easily implemented, but I'd like to know the reason behind this not working. Thanks for any help.

EDIT1

adding my top.sls file

#/srv/salt/top.sls
project1:
  project1:
    - match: nodegroup
    - postgresql
    - iptables
project2:
  project2:
    - match: nodegroup
    - tomcat
    - java
project3:
  project3:
    - match: nodegroup
    - serverconfig
    - conky

EDIT2

Output from salt -N project1 grains.item id

project1_server1:
    ----------
    id:
        project1_server1
project1_server2:
    ----------
    id:
        project1_server2:
project1_server3:
    ----------
    id:
        project1_server3:

EDIT3

The correct answer was provided by ChrisV

The syntax errors for the node in /etc/salt/master were the problem. I needed to change that, and then restart salt-master

pkill salt-master
salt-master -d
  • It would seem that project1_server1 is not matching it's nodegroup definition. I would start there (by verifying minion ID's). Also, it seems the nodegroup definition should be project1: 'L@project1_server1,project1_server2,project1_server3' per docs.saltstack.com/en/latest/topics/targeting/compound.html – user87664 Dec 5 '14 at 23:00
  • Changed my nodegroup and same problem, but thanks for linking to the docs. Fixed that incorrect syntax – trueCamelType Dec 5 '14 at 23:07
  • Can you append output from salt -N project1 grains.item id and salt 'project1_server1' grains.item id – user87664 Dec 5 '14 at 23:19
  • edit2 is the output from the desired command – trueCamelType Dec 5 '14 at 23:24
  • Did you restart master after making change to nodegroup in /etc/salt/master? Gotta ask ;) – user87664 Dec 5 '14 at 23:36
2

nodegroup definitions should be as follows:

project1: 'L@project1_server1,project1_server2,project1_server3'

Per Salt documentation: Node Groups and Compound Matchers

Also note that a restart of the salt master daemon is required.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.