New to SaltStack, Do not understand this error? <name>.sls is not available?

379 views
Skip to first unread message

Jibun no Kage

unread,
Oct 18, 2022, 5:11:43 PM10/18/22
to Salt-users
New to SaltStack, Do not understand this error?  <name>.sls is not available?

I have salt master installed, and minions on several linux based systems.  Everything is talking, keys are accepted for all minions.  I can run commands directly.  But when I created my first sls file, and try to run it on any minion or even the master (which has minion installed), I get a error that makes no sense to me.

Path for Salt:
/srv/salt

Path and content of Salt sls file:
# cat /sev/salt/nano-install.sls
nano:
  pkg.installed

Command run:
# salt -v 'infrastructure.dd.org' nano.sls nano
Executing job with jid 20221018210832592186
-------------------------------------------
infrastructure.dd.org:
    'nano-install.sls' is not available.

Clearly I have something wrong somewhere but the error message is not, at least, to me, all that helpful.  I have read several examples that are identical to this and seem to work.  I have not defined any file-roots or base path, the examples don't require or illustrate it.  They all rely on /srv/salt as the default base path.  So what the heck is missing?

Jibun no Kage

unread,
Oct 18, 2022, 5:15:16 PM10/18/22
to Salt-users
Correction above... typo, the sls file name is nano-install.sls, so the command execution (where the typo is) should be:

# salt -v 'infrastructure.dd.org' nano-install.sls nano

But I still get the same error.  The typo was in my question above post, no the actual testing.  In case any one notices I typed the command wrong in the post above.

Jibun no Kage

unread,
Oct 18, 2022, 5:36:58 PM10/18/22
to Salt-users
A bit more... I setup the top.sls file:
# cat top.sls
base:
  '*':
    - nano
    - apt-file

The sls files:
# ls -l /srv/salt/
total 12
-rw-r--r-- 1 root root 34 Oct 18 21:22 apt-file.sls
-rw-r--r-- 1 root root 30 Oct 18 21:24 nano.sls
-rw-r--r-- 1 root root 40 Oct 18 21:21 top.sls

For the two sls files I created to test with.  And if i run the minion in direct logging debug mode, and on the master I run 'salt '*' state.apply -t 60', the two sls files are executed as expected and correctly.  Which is really confusing because why can't I run a given sls file on demand?  Say "salt -v 'infrastructure.dd.org' nano-install.sls nano" for example.

The logging clearly shows the sls files where applied and successful:

infrastructure.dd.org:
----------
          ID: nano
    Function: pkg.installed
      Result: True
     Comment: All specified packages are already installed
     Started: 21:27:38.502188
    Duration: 249.121 ms
     Changes:
----------
          ID: apt-file
    Function: pkg.installed
      Result: True
     Comment: All specified packages are already installed
     Started: 21:27:38.753209
    Duration: 87.256 ms
     Changes:

Dafydd Jones (techneg.it)

unread,
Oct 19, 2022, 5:19:17 AM10/19/22
to salt-...@googlegroups.com
Hello,

the correct command would be "salt -v 'infrastructure.dd.org' state.apply nano" 

Dafydd

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/salt-users/d3ba5fab-2c81-4fd3-84a7-78f1e71712ban%40googlegroups.com.

Jibun no Kage

unread,
Oct 19, 2022, 1:26:23 PM10/19/22
to Salt-users
@Dafydd, I tripped over that method, in due course yesterday, but thank you for the confirmation.

Aaron Greengrass

unread,
Oct 20, 2022, 11:02:56 AM10/20/22
to salt-...@googlegroups.com
with your given example there, I'd expect to be able to do:

salt 'targethost' state.apply nano

or 

salt-call state.apply nano (run from a minion).

Either of which should target the top level nano.sls file you have shown.

Similarly, to run *just* apt-file.sls, you'd use the example syntax above, removing .sls from the name of the state you wish to apply.

I do not see a nano-install.sls example in your folder above.


------ Original Message ------
From "Jibun no Kage" <jibun...@gmail.com>
To "Salt-users" <salt-...@googlegroups.com>
Date 10/18/2022 2:36:58 PM
Subject [salt-users] Re: New to SaltStack, Do not understand this error? <name>.sls is not available?

--

Subbarao a

unread,
Oct 20, 2022, 11:02:57 AM10/20/22
to salt-...@googlegroups.com
You should not use .SLS as extension in your command.

Here is the example 

salt <target> state.apply <statefile without file extension> 

Thanks,
Subbu

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.

Aaron Greengrass

unread,
Oct 20, 2022, 11:02:57 AM10/20/22
to salt-...@googlegroups.com
Do you not mean 

salt -v 'infrastructure.dd.org' state.apply nano-install ?

or via salt-call 

salt-call state.apply nano-install

a.


------ Original Message ------
From "Jibun no Kage" <jibun...@gmail.com>
To "Salt-users" <salt-...@googlegroups.com>
Date 10/18/2022 2:15:15 PM
Subject [salt-users] Re: New to SaltStack, Do not understand this error? <name>.sls is not available?

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.

Reed Dier

unread,
Oct 20, 2022, 11:02:57 AM10/20/22
to salt-...@googlegroups.com, jibun...@gmail.com
I think it might be helpful to better organize your states, if for no better reason than to simplify referencing them.

srv
└── salt
    ├── apt
    │   ├── file.sls
    │   ├── init.sls
    │   └── repo.sls
    ├── nano
    │   ├── config.sls
    │   ├── init.sls
    │   └── install.sls
    └── top.sls

In this tree, I created directories for apt and nano under your /srv/salt file root.

This does two things, one that you can then reference states by name, and you can also break things into smaller pieces.
So in this example, I could call `salt ‘minion’ state.apply nano.install` to run the nano/install.sls state.

I can also call `salt ‘minion’ state.apply nano` and it will call the nano/init.sls, which could look like:
include:
  - nano.install
  - nano.config

That would then run both of those states.

Then with the top file, you can do the same thing, 
# cat top.sls
base:
  '*':
    - nano
    - apt.repo

Slightly modifying your example, you can reference nano directly, which will run the init state, or you can use the dir.state notation and call specific states.

Also, calling `salt ‘minion’ state.apply` without a state, will apply the high state as laid out in the top file.

Hopefully this helps some.

Reed

Mega Man

unread,
Oct 20, 2022, 11:03:13 AM10/20/22
to Salt-users
Have you tried this?

salt minion.example.com state.apply nano

Sid Young

unread,
Oct 27, 2022, 8:49:38 PM10/27/22
to Salt-users

If you want to run an SLS file from the master and apply it to a minion is as follows:

salt your.mininio.com state.sls nano-install

This means the nano-install is located in /srv/salt.

This article might be a good read for you (and anyone setting up a group of minions) https://z900collector.wordpress.com/2022/09/28/managing-top-sls-and-sls-files-in-saltstack/

Sid

Reply all
Reply to author
Forward
0 new messages