salt-stack

Track failure of command on a Salt minion

送分小仙女□ 提交于 2019-12-10 09:52:42
问题 I am using salt for last one month. Whenever I run a command say sudo salt '*' test.ping , then the master pings all the minions and the response being the list of all the minions which are up and running. Output looks something like: { "minion_1": true } { "minion_2": true } { "minion_3": true } In the master's conf file, return type is configured to JSON. But if I execute an incorrect command through salt master say sudo salt '*' test1.ping , then the master returns something like this {

(SaltStack) ID dog in SLS dog is not a dictionary

核能气质少年 提交于 2019-12-10 04:06:39
问题 I have been trying to find a pattern (bcm2708_wdog) in the /etc/modules file and if it isnt there add it to the bottom. Every time I try this I get the "ID dog in SLS dog is not a dictionary". I have no idea what this means. Here is the file: dog: - file.replace: - name: /etc/modules - pattern: 'bcm2708_wdog' - append_if_not_found: True 回答1: It should probably look like this: dog: file.replace: # <--------this line was your problem. - name: /etc/modules - pattern: 'bcm2708_wdog' - append_if

SaltStack: how do I repeat other states with context?

拥有回忆 提交于 2019-12-08 02:22:08
问题 I created a complex state for API service, it involves git checkouts, python venv, uwsgi, nginx, etc etc. It works fine. Now I would like to turn it into a template and execute it several times per minion, with variables supplied from pillar - i.e something like. {% for apiserver in pillar.apiservers %} include apiserver_template.sls, locals: apiserver.config {% endfor %} where apiserver_template will work with context supplied to it, with apiserver.config having all config data for each API

How to compare version strings in salt sls files

懵懂的女人 提交于 2019-12-07 16:52:15
问题 Does saltstack have an equivalent to puppets versioncmp() function? Or alternatively, is there a way to get the distutils.version or packaging.version.parse methods (as mentioned on Compare version strings in Python) available in a jinja+yaml rendered sls file? 回答1: you can use the module pkg.version_cmp : # salt-call pkg.version_cmp '1.0.2' '1.1.1' local: -1 # salt-call pkg.version_cmp '0.2.4.1-0ubuntu1' '0.2.4-0ubuntu1' local: 1 Inside jinja you can use it in a way similar to: {% if salt[

Saltstack load pillar in a for loop

谁说胖子不能爱 提交于 2019-12-07 12:19:57
问题 I am developing a automatic proftd installation whit Salt, i wont to get the ftp users from a template but I cant get work the pillar, i initialized the pillar whit the users data and call it into a for loop, but you don't get the pillar user data in the loop. When i make salt-call pillar.get ftpusers in the minion, the response is: local: This is my pillar ftpusers.sls: ftp-server.ftpusers: user: - user: user - passhash: j2k3hk134123l1234ljh!"·$ser - uuid: 1001 - guid: 1001 - home: /srv/ftp

What open ports are required on firewall to allow for salt-stack remote execution?

强颜欢笑 提交于 2019-12-07 09:05:55
问题 The documentation on saltstack appears to be unclear regarding what ports are required from the salt-master -> salt-minion (apparently none are required). It suggests that ports only need to be opened from the salt-minion -> salt-master. (See: http://docs.saltstack.com/en/latest/topics/tutorials/firewall.html) If however commands are executed remotely on the salt-master targeted to a minion, surely the master needs to be able to push this into the minion and therefore require a network

what's the differences between functions in state file and functions in command line in saltstack?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 11:36:01
问题 When I use saltstack to manage my servers. I found an interesting thing: When I run salt '*' pkg.installed httpd , I get the following message: pkg.installed is not available . But I can use pkg.installed function in my .sls files and it worked very well. So, I am confused about that. And I think this is happening because of saltstack . Who can help me? 回答1: There are two related but different concepts here. Salt Execution Modules Salt State Modules. Execution modules are where most of the

SaltStack: how do I repeat other states with context?

我怕爱的太早我们不能终老 提交于 2019-12-06 05:28:12
I created a complex state for API service, it involves git checkouts, python venv, uwsgi, nginx, etc etc. It works fine. Now I would like to turn it into a template and execute it several times per minion, with variables supplied from pillar - i.e something like. {% for apiserver in pillar.apiservers %} include apiserver_template.sls, locals: apiserver.config {% endfor %} where apiserver_template will work with context supplied to it, with apiserver.config having all config data for each API instance. I know syntax is wrong but hopefully I am communicating the idea - ideally, something like

How to communicate with salt-master

大兔子大兔子 提交于 2019-12-06 04:47:00
I am trying to access salt master from salt-minion. But, I am unable to get the keys on salt-master. On my VM, I installed salt-master and on my Windows, I installed salt-minion . I have given master IP address on my minion vi salt\conf\minion master: master ip address I tried to run the command below: c:\salt\salt-minion.exe -l debug -c c:\salt\conf I am getting a message like below: [DEBUG ] Reading configuration from c:\salt\conf\minion [INFO ] Using cached minion ID from c:\salt\conf\minion_id: HoroppaLabs [DEBUG ] Configuration file path: c:\salt\conf\minion [INFO ] Setting up the Salt

Passing variables with include in salt-stack

孤者浪人 提交于 2019-12-06 04:07:33
I have several states that are almost the same. All of them deploy project, create virtualenv and configure supervisor. Difference is only in repo, project name and some additional actions. A lot of code is duplicated. Is it possible to put the same parts into file and include it with additional variables? In Ansible it can be done this way: tasks: - include: wordpress.yml vars: wp_user: timmy ssh_keys: - keys/one.txt - keys/two.txt alexK This question looks similar to this one If I understood your question correctly - I believe the best way to achieve what you want is to use Salt Macros .