8

I am new to SaltStack and following some tutorials and trying to execute state.apply but getting below error:

# salt "host2" state.apply 
host2:
----------
          ID: states
    Function: no.None
      Result: False
     Comment: No Top file or external nodes data matches found
     Started: 
    Duration: 
     Changes:   

Summary for host2
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1

I am able to test.ping successfully to host. here is directory structure:

/etc/salt/srv/salt/states
                     |-top.sls
                     |-installations
                           |-init.sls

file root entry in master config

file_roots:   
  base:
    - /srv/salt/states

top.sls ->

base:
  '*':
    - installations

init.sls->

install_apache:
  pkg.installed:
    - name: apache2
Dhiman S.
  • 101
  • 1
  • 1
  • 5

2 Answers2

6

You need to change the path to your states, or move them to the path set in file_roots.

The file_roots option is where you should place your files, you should have the following tree:

# tree /srv/salt/
/srv/salt/
|-- installations
    `-- init.sls
`-- top.sls

Or you could change your file_roots, but I wouldn't do it, since /srv/salt/ seems to be a sort of "standard".

Have a look at the tutorials, if you haven't already: https://docs.saltstack.com/en/getstarted/fundamentals/

Alberto Chiusole
  • 2,204
  • 2
  • 16
  • 26
  • I changes the file_root: base: to /etc/salt/srv/salt/state, and it works for me. looks it wasn't picking path correctly. – Dhiman S. Oct 04 '18 at 17:48
  • 1
    Because you had to move them to /srv/salt, otherwise salt cannot find your states. I should have stressed it more in my answer. – Alberto Chiusole Oct 05 '18 at 12:24
1

I changes the

file_root:    
  base:
    - /etc/salt/srv/salt/state

and it works for me. looks it wasn't picking path correctly

Dhiman S.
  • 101
  • 1
  • 1
  • 5