Using formulas with saltstack

我与影子孤独终老i 提交于 2019-12-11 03:44:21

问题


I'm new on saltstack and I want to install postgres or apache or anyting else by using saltstack formulas.

I downloaded repo from git with

git clone https://github.com/saltstack-formulas/apache-formula.git

and

git clone https://github.com/saltstack-formulas/postgres.git

to my /srv/salt directory.

After that I added the lines

file_roots:
base:
      - /srv/salt
      - /srv/formulas/apache-formula
      - /srv/formulas/postgres

in /etc/salt/master file.

Then i created a file top.sls in the folder /srv/salt with the content:

include:
   - apache

To run this im using

salt '*' state.highstate

and all i get is the error message:

xxx.yyyyyyy.com:
----------
      ID: states
Function: no.None
  Result: False
 Comment: No Top file or external nodes data matches found
 Changes:   

Summary
------------
Succeeded: 0
Failed:    1
------------
Total:     1

What did i wrong? I read the manual on http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html but this manual doesn't help at all!


回答1:


You have to tell salt to whom the state applies in your top.sls file:

include:
  - apache

base:
   '*':
       - apache

Update: As Utah_Dave points out, I overlooked that you had the formula added to file_roots, you don't need the include directive. Just do this:

base:
   '*':
       - apache



回答2:


This might not be useful for your specific case, but I found that the problem I had was that I'd defined my gitfs_root to be a subfolder. This allowed us to structure an internal repo to have different subfolders for states and pillars.

When I setup my first formula, the gitfs_root meant none of the formulas worked because it was looking in the subfolder for each one.

I instead moved the config to the specific repo.

Before:

gitfs_root: salt

gitfs_remotes:
    - https://github.com/this-is/saltstack-formula
    - https://github.com/internal/salt-repo

After:

# gitfs_root:

gitfs_remotes:
    - https://github.com/this-is/saltstack-formula
    - https://github.com/internal/salt-repo
        - root: salt


来源:https://stackoverflow.com/questions/25405425/using-formulas-with-saltstack

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!