0

I have salt-stack maser and minion servers which running on centos7. I want to install vim package in minion server. For that I have created srv directory and vim.sls file under etc.

My vim.sls file looks like this.

vim:
  pkg:
    - installed

When I run using salt '*' state.sls vim getting an error.

192.168.94.155:
    Data failed to compile:
----------
    No matching sls found for 'vim' in env 'base'
ERROR: Minions returned with non-zero exit code

How to resolve this error?

0

The structure of the srv directory should be:

/srv/
 - salt
 - pillar

Your vim.sls should be in the salt directory and not in the /srv directory.

In addition, and beware that for vim, depending on the OS familly (Redhat and others) the package name is not always the same. and for this, using pillars could be very helpful:

{% if grains['os_family'] == 'RedHat' %}
apache: httpd
git: git
gvim: vim-X11
vim: vim-enhanced
{% elif grains['os_family'] == 'Debian' %}
apache: apache2
{% else %}
apache: apache2
git: git
gvim: gvim
vim: vim
{% endif %}

By doing so, you cann do the following thing

deploy editors:
  pkg.installed:
    - pkgs:
      - {{ pillar['vim'] }}
      - {{ pillar['gvim'] }}

And no matter on which OS family your minion is located, the correct package will be deployed.

Edit: Here is the way I'm using my pillars: in /srv/pillars I've got a top.sls file with this in it

base:
  '*':
    - packages

Then at the same level as the top.sls I've got a packages.sls file with the content I've posted before in it. That its possible to use {{ pillar['vim'] }} in my salt recipes for instance. But in your case it's not needed. It's just an easy way to handle various Linux flavor (RHEL, Debian & co) And If I want to add more variable data I can still add another sls at the same level

  • I don't have an idea about pillars. I have created directry called pillars in /srv location. Can you tell me how to add these scripts? – Janith Dec 27 '18 at 3:27
  • I've added to my answer the way I'm using the pillars. If you need more info let me know – agm650 Dec 28 '18 at 19:50
  • Is it working for you? any issue? – agm650 Jan 9 at 20:07
  • Hey I got an error Data failed to compile: ---------- Too many functions declared in state '192' in SLS 'top'. – Janith Feb 5 at 8:31
  • Can you post the sls file you are using? To see if we can pinpoint the reason for this error? – agm650 Feb 6 at 16:28

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.