Questions tagged [salt-stack]

The Salt Project, previously known as SaltStack, is a Python-based open-source configuration management software and remote execution engine.

Salt is an open source tool to manage your infrastructure. Easy enough to get running in minutes and fast enough to manage tens of thousands of servers and still get a response back in seconds.

Execute arbitrary shell commands or choose from dozens of pre-built modules of common (or complex) commands. Target individual servers or groups of servers based on name, defined roles, or a variety of system information such as hardware, software, operating system, current version, current environment, and many more.

Bring your servers up to a known configured state by writing simple lists of items and defining attributes on those lists.

Links

See also the saltstack tag on Server Fault.

1444 questions
71
votes
4 answers

Calling one Bash script from another Script passing it arguments with quotes and spaces

I made two test bash scripts on Linux to make the problem clear. TestScript1 looks like: echo "TestScript1 Arguments:" echo "$1" echo "$2" echo "$#" ./testscript2 $1 $2 TestScript2 looks like: echo "TestScript2 Arguments…
nmadhok
  • 1,704
  • 3
  • 16
  • 20
52
votes
6 answers

Is there a way to display only changes and errors

I have quite extensive salt config and I want to be able to see what has changed. If I just run salt '*' state.highstate I got the whole list with things that were present and not changed - like 3 to 4 screens of log. But I'd really like to see only…
Tomáš Fejfar
  • 11,129
  • 8
  • 54
  • 82
43
votes
1 answer

Remove the empty lines left by Jinja2 variable definitions

When writing template files using Jinja2 for Saltstack, I often define some variables at the beginning of the file. For example: {% set ip = grains['ip4_interfaces']['eth1'][0] %} {% set domain = pillar['company_domain'] %} {% set version =…
ITChap
  • 4,057
  • 1
  • 21
  • 46
41
votes
1 answer

Why is this commit that sets the RSA public exponent to 1 problematic?

I saw this commit in SaltStack on Hacker News, but I don't understand exactly what it does or why the original version was a cryptography error. (I also don't know a lot about how the specifics of cryptography work, either.) - gen =…
James Faulcon
  • 733
  • 2
  • 6
  • 8
34
votes
4 answers

salt stack: grains vs pillars

In the Salt system there are grains and pillars. I understand how I can assign custom grains, but when would it be better to consider using pillars?
Jeff Bauer
  • 13,890
  • 9
  • 51
  • 73
29
votes
1 answer

How to use logic operators in jinja template on salt-stack (AND, OR)

I am using a jinja template to generate a state file for salt. I added some conditionals and would like to express: if A or B. However, it seems I cannot get any logical operator working. It doesn't like ||, |, &&(which I understand doesn't apply…
hotfire42
  • 555
  • 1
  • 5
  • 10
28
votes
1 answer

Salt Stack: using execution modules in SLS

So far as I can see in the Salt documentation (e.g. here) there are two main types of modules supported: state modules and execution modules (I know there are also renderers, returners, and so on). Most of examples of SLS files contain statements…
vania-pooh
  • 2,933
  • 4
  • 24
  • 42
22
votes
3 answers

SaltStack : is it possible to apply states on the master and if so, how?

I am a total beginner with SaltStack but I have managed to setup some states on a machine and run them on a minion. What I have right now is a Debian machine setup with salt-master as well as another Debian setup as salt-minion. Since I am using the…
austrum
  • 223
  • 1
  • 2
  • 6
21
votes
2 answers

SaltStack: In a watch statement, how do I specify a directory where all files should be watched?

I would like the nginx service to restart whenever any file in the /etc/nginx/conf.d directory is created or modified. There are a number of files in that directory, and rather than specifying particular files, I would like to watch for all…
coffee-grinder
  • 26,940
  • 19
  • 56
  • 82
20
votes
7 answers

How to raise an exception in a Jinja2 macro?

I have a macro that is used to build a local repository using debmirror. Here's the snippet of code: {%- set gnupghome = kwargs.pop('gnupghome', '/root/.gnupg') %} {%- set env = { 'GNUPGHOME': gnupghome } %} keyring_import: cmd: - run {%- if…
quanta
  • 3,960
  • 4
  • 40
  • 75
19
votes
4 answers

How can I execute multiple commands using Salt Stack?

I tried to add: mypack: pkg: - installed - pkgs: - mercurial - git cmd.run: - name: 'mkdir -p /opt/mypack' cmd.run: 'hg pull -u -R /opt/mypack || hg clone -R /opt https://...' cmd.run: 'ln -s…
sorin
  • 161,544
  • 178
  • 535
  • 806
16
votes
3 answers

How to get a list of all salt minions in a template?

Basically I am creating a Salt state describing Munin server configuration and I need to get a list of all minions known to the master, something like this: {% for host in pillar['munin_clients'] %} [{{ host.fqdn }}] address {{ host.ip }} …
Alex
  • 907
  • 2
  • 8
  • 22
15
votes
2 answers

Salt-stack list all available states

I already searched the doc and was not able to find an satisfying answer. Is it possible to get something like salt 'machine' state.list. To get all states that could be potentially applied? I know there is the high state / top / lowstate, but if i…
PlagTag
  • 6,107
  • 6
  • 36
  • 48
15
votes
5 answers

Should I always use pillar.get instead of pillar['foo']?

I see in the pillar documentation that there are two ways to reference pillar data in an SLS. {{ pillar['foo'] }} and {{ salt['pillar.get']('foo') }} The pillar.get method handles nested pillar data better and allows to specify a default if the…
NimbusScale
  • 428
  • 1
  • 5
  • 14
15
votes
2 answers

how to reboot in the middle of a salt state?

(this is a copy of a question I asked on the salt-users group, FWIW) I need to write a state that installs some Windows server features, reboots the minion, and then installs some more software. It seems like all the pieces are there (cmd.wait,…
Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
1
2 3
96 97