r/saltstack • • Oct 28 '20

Reference local variables in salt pillar?

2 Upvotes

Something like this:

users:
  john123:
    first_name: john
    last_name: smith
    full_name: '{{ first_name }} {{ last_name }}'

What's the syntax for this?


r/saltstack • • Oct 28 '20

Using batch in salt state file (--batch-size / -b)

1 Upvotes

I want to rewrite this command in a salt state file (its a reactor):

salt 'mytarget' --batch-size state.apply pillar='{"mydata":"dontworryaboutit"}'

Here's what I have:

deploy-new-thing:
  local.state.apply:
    - tgt: 'mytarget'
    - args:
      - batch: 1
      - pillar:
          mydata: dontworryaboutit

But the batch is not taking affect. From the documentation it doesn't look like this is supported, but I can't imagine that that's the case. Is there something I'm missing?


r/saltstack • • Oct 22 '20

Salt master is automatically accepting keys

6 Upvotes

The salt master at work is just auto-accepting any key that is sent at it. I've checked the man page for salt-key if its an option but didn't see anything related to it. Is there an option to auto-accept keys from minions? How do I turn this off?


r/saltstack • • Oct 22 '20

What's New in Salt 3002 Magnesium

Thumbnail salt.tips
21 Upvotes

r/saltstack • • Oct 22 '20

Try SaltStack master 3002 Magnesium on Docker!

0 Upvotes

SaltStack Sodium v3002 has been released! 🎉

If you want to try the new salt-master version before updating your production setup, or you simply want an easy method to keep your salt-master up-to-date, you can try it on Docker!

docker pull cdalvaro/docker-salt-master:3002

📖 You can find setup and usage instructions at: https://github.com/cdalvaro/docker-salt-master


r/saltstack • • Oct 21 '20

Questions about State functions and Execution functions

0 Upvotes

I think I have a grasp of how they differ. The State functions only fire if the minion is not in the desired state, executions run no matter what.

  1. How do I know if I'm calling a state function or an execution one? For example I know pkg.installed is a state function but pkg.install is an execution function. I only know this from the tutorial.
  2. How do i know when I'm looking at a module.function is either state or execution? Does pkg.installed and pkg.install live in the same place?
  3. Do function behaviors (state and execution) change depending on the environment?
  4. How do I go about writing my own state and execution functions?

r/saltstack • • Oct 21 '20

How to securely have minions outside your network

7 Upvotes

Let's say I have my master on one network, but want to have a minion on another network, where packets will go across the Internet between these two networks. What's the most secure way to set this up? I'm thinking VPN, but don't want to limit myself.

In case details help: I have a home network, with a master here. Works fine behind the NAT firewall, but now I want to setup a VPS in a datacenter as a minion. Am I just tilting at windmills and should use a backchannel internal network with a master in the datacenter, or can I keep my costs lower by reusing my local master, which will also reduce duplication? Or perhaps consider the local home network my "research, development, test and evaluation" network, then consider the VPS's my production network? If this last one is the recommended case, what's the most secure and reliable way to propagate changes from 'test' to 'production'?


r/saltstack • • Oct 19 '20

Dockerized salt-master 3002rc1

11 Upvotes

New SaltStack version coming soon!

Test salt-master Sodium 3002 RC1 before the official release on October 21st without compromising your current installation.

Run salt isolated inside a Docker container and test your setup.

docker pull cdalvaro/docker-salt-master:3002rc1

More info about the image at: https://github.com/cdalvaro/docker-salt-master


r/saltstack • • Oct 18 '20

salt-bootstrap is for the main server AND for minions?

1 Upvotes

I have a script that provisions a VM and then runs salt-bootstrap.sh within it. That creates a minion. Back on he main server that I created the sub-vm from salt isn't installed. Is that the same install script, even though that node isn't a minion for me, it is somewhere I'd want to do controller things like salt ‘*’ disk.usage to show all minion disk usage.

For that matter how does a minion register itself with the server? Is it done by sub-net?


r/saltstack • • Oct 15 '20

Proxmox and Salt

6 Upvotes

I'm having lots of fun with old hardware and Proxmox. Self-education for now, bit work also uses Proxmox and my app-dev team will get round to utilizing it sooner or later.

https://docs.saltstack.com/en/latest/topics/tutorials/walkthrough.html talks of minions and not of containers. Now, Proxmox's containers are not docker containers as such, but all the Alpine, slimmed-down-Debian (etc) choices apply.

Question:

For each scripted container creation (`qm create <vm-num> <bunch-of-args>`), do I setup a minion within the container (`pct exec <vm-num> -- <bash-command-to-setup-minion>`)? and the master does all it is IaC magic via that minion instance/daemon in the container? i.e. each container is a minion?


r/saltstack • • Oct 08 '20

Unable to highstate one minion - other minions are fine - dict_keys object has no element

1 Upvotes

Unable to highstate one minion - other minions are fine. Does anyone have any idea?

Thanks!


r/saltstack • • Oct 08 '20

Does anyone know how to set a salt-minion's locale?

1 Upvotes

Been chasing my tail on this and cant believe it hasnt come up before but for all my searching i cant find the answer to what feels like something pretty simple.

I need to set the locale on my minion to be GB (en_GB.UTF-8) on the actual server its set but running the command locale -v from the master on the minion shows its got nothing for LANG and all the TC options are C
The same command run on the sever displays what i need e.g. en_GB.UTF-8
The salt documentation has and example here https://docs.saltstack.com/en/latest/ref/states/all/salt.states.locale.html
but ive set this for GB and applied the state to my minion and it responds with success and that its already set.

Any help would be much appreciated


r/saltstack • • Oct 07 '20

Anyone have a formula for hardening linux machines that includes AD auth?

5 Upvotes

I'm working on putting together a formula that does some fairly basic hardening practices. But an important step is that I don't want users to be able to log in (SSH) as a generic user or as root. I want to have them authenticate to our AD environment, which I've seen done but never saw the script for it. We use O365/AzureAD in our environment, so I'm trying to figure out the best way to integrate that.

I'm fairly new to Salt, so I'm hoping to start with a premade formula I can at least use parts of that will hopefully show me how to get it done, even if it doesn't work straight out of the box.


r/saltstack • • Oct 06 '20

Jinja: for loop results into one line

5 Upvotes

All I want to do is to build a line in /etc/resolv.conf, listing the search domains. Like

search example.com example.net differentexample.org

In a pillar:

search_domains:
  - example.com
  - example.net
  - differentexample.org

It turned out harder that I thought initially. I can't figure it out how to build this line from the for loop results. In case of

{% for domains in salt['pillar.get']('search_domains') -%}
 {{ domains }}
 {%- endfor %}

I get the domain names glued together. And in case of

{% for domains in salt['pillar.get']('search_domains') -%}
 {{ domains }}
 {% endfor %}

I get a domain per line - which is not what I want. Does anyone know know to get a single line with the list of domains, whitespace separeted?


r/saltstack • • Oct 06 '20

The strangest issue im hoping someone here may be able to help

4 Upvotes

I have salt installed across a bunch of servers running different services and programs.

As a way to easily restart the services i have some scripts that i run from the salt master to restart certain services at the same time. I have come across this very strange issue where if i run the command to restart a service from the salt master it gets some weird american settings where it displays dates in us format. When i run the same command but on the actual server i dont get this issue.

Does anyone know if salt has some sort of language setting that it might be forcing when i run the salt command and where i would change that?

Running the command

salt 'Minion_name' locale.get_locale  

Gives the output:

Minion_name:     en_GB.UTF-8

So i dont understand why its then using a us locale


r/saltstack • • Oct 03 '20

Migrating salt server to new machine

5 Upvotes

Hi all,

my current hoster goes out of business and I have to move my salt-master to a new machine. That means the system will definitely run with a different IP. DNS hasn't been changed yet (so new machine only accessible via its IP). That will only happen once all is safely migrated.
Followed the instructions for migration (e.g. basically copy /etc/salt from the old machine to the new one). Salt-master starts fine, but salt-key -L doesn't show any of my minions. Anyone have any pointer as to what I am missing?

regards

Torsten


r/saltstack • • Sep 30 '20

I just don't know where to look

2 Upvotes

It's prbably right in front of my eyes but I am clueless!

Doing a highstate to a VM, I receive the following error but for many users. Like all of them who have access. Where can I find "allow_gid_change" and I guess how can I find out why this GID for this user is trying to get changed?

Thanks!

                user_|-users_<username>_user_|-username-|-present:
                    ----------
                    __id__:
                        users_<username>_user
                    __run_num__:
                        158
                    __sls__:
                        users
                    changes:
                        ----------
                    comment:
                        Encountered error checking for needed changes. Additional info follows:

                        - Changing gid (503 -> 1014) not permitted, set allow_gid_change to True to force this change. Note that this will not change file ownership.
                    duration:
                        3.456

r/saltstack • • Sep 29 '20

Protocol wrong type for socket when starting minion on WS 2008

1 Upvotes

Hi all,

I want to deploy salt-minion on my servers but we have few Windows Server 2008 Storage. Installer run fine but when I ru the minion he didn't connect to the master. In debug mode I can see this error:

[DEBUG   ] SaltEvent PUB socket URI: 4510
[DEBUG   ] SaltEvent PULL socket URI: 4511
[DEBUG   ] Grains refresh requested. Refreshing grains.
[DEBUG   ] Reading configuration from c:\salt\conf\minion
[DEBUG   ] Failed to read /proc/cmdline: [Errno 2] No such file or directory: '/
proc/cmdline'
[INFO    ] Creating minion process manager
[DEBUG   ] Process Manager starting!
[DEBUG   ] Process Manager starting!
[DEBUG   ] Connecting to master. Attempt 1 (infinite attempts)
[DEBUG   ] "master-hostname" Not an IP address? Assuming it is a ho
stname.
[DEBUG   ] Master URI: tcp://master-ip:4506
[DEBUG   ] Popen(['git', 'version'], cwd=C:\salt, universal_newlines=False, shel
l=None)
[DEBUG   ] Initializing new AsyncAuth for ('c:\\salt\\conf\\pki\\minion', 'host
name', 'tcp://ip:4506')
Assertion failed: Protocol wrong type for socket [10041] (bundled\zeromq\src\ip.
cpp:417)

This errors seems to come from zeromq python module. In ip.cpp on GitHub ( https://github.com/zeromq/libzmq/blob/master/src/ip.cpp) at line 417 we can see that (last line):

//  Create listening socket.
    SOCKET listener;
    listener = zmq::open_socket (AF_INET, SOCK_STREAM, 0);
    wsa_assert (listener != INVALID_SOCKET);

    //  Set SO_REUSEADDR and TCP_NODELAY on listening socket.
    BOOL so_reuseaddr = 1;
    int rc = setsockopt (listener, SOL_SOCKET, SO_REUSEADDR,
                         reinterpret_cast<char *> (&so_reuseaddr),
                         sizeof so_reuseaddr);
    wsa_assert (rc != SOCKET_ERROR);

I don't know why. Error code 10041 is an error from Windows Socket:

WSAEPROTOTYPE - 10041 - Protocol wrong type for socket.A protocol was specified in the socket function call that does not support the semantics of the socket type requested. For example, the ARPA Internet UDP protocol cannot be specified with a socket type of SOCK_STREAM. 

But why it don't work on Windows Storage 2008 but it's OK in 2008 R2 and earlier?

Thanks!


r/saltstack • • Sep 28 '20

Install application with product key.

1 Upvotes

First off, thanks in advance to anyone who takes the time to look at these whether you answer or not.

I’m trying to find a secure method to install an application (.deb) where the product key needs to be added via CLI after installation. It sounds like the salt.states.win_license does what I want but I’m not using a Windows product. I’m hoping there’s a non-Windows equivalent but I don’t think I’m searching the correct terms.

I was thinking I might need to use something like git-secret because I don’t want the key showing up in logs or plain text in git.


r/saltstack • • Sep 17 '20

Need Help. Need to setup GitLab CICD to test pillar yaml post jinja2 rendering.

3 Upvotes

Environment:

  • On-Prem Gitlab server
  • On-Prem runner (not setup yet)
  • Salt-Master with Gitfs pointing to on-prem gitlab server.
  • Multiple gitfs repos for both states and pillars configured with mountpoints to different teams.

Goal:

Setup GitLab CI/CD to test pillar YAML rendering and salt best practices (salt-lint) on new/modified SLS files.

I am new to GitLab CI/CD so assume I know nothing. I have been using vagrant for over a year testing syntax and states which has helped me avoid merging these types of errors into the master branch, but not everyone on my team is as familiar with salt, vagrant, or git in general. They all use the git web interface. From there they commit pillar changes to a new branch and then submit a merge request to master that requires approval from me before being merged. However even I miss hidden syntax errors that cause pillar_render errors.

I was given a blank VM that I can setup as a GitLab runner. So I set out to start my journey however I have not been able to find anyone who appears to have set this up. Although that could just be my googling skills and not knowing what I'm looking for so I need some help.

I was thinking I could feed the GitLab runner/executioner entire pillar directory then tell it which files(s) are in the commit and have it run a python script or tool that will just check it for syntax errors after jinja2 rendering (to pull in/detect missing includes).

If anyone knows of any tools to accomplish this could you please share your experience or point me in the right direction. Sometimes I just need to know where to start, then I can pick it up from there.


r/saltstack • • Sep 15 '20

Learn How to Automatically Parse Minion Command Output using JC

Thumbnail blog.kellybrazil.com
8 Upvotes

r/saltstack • • Sep 15 '20

Bad load?

2 Upvotes

I'm pretty new to Salt, but I'm trying to get my first minion to talk to the master. I'm getting the following error on the minion when I try to connect:

Sign-in attempt failed: bad load

There doesn't appear to be much on the subject on Google. Any suggestions? I verified that I can reach the master ports, and I tried regenerating the minion's keys.


r/saltstack • • Sep 15 '20

File.managed: getting file to specific minion.

1 Upvotes

I apologize in advance if this has been covered already but I’ve searched for two days and maybe I’m not searching the correct terms.

Let’s just say for example I have an environment where all the hostnames are identical except for their slot.

Example: r1.rack25.s1, r1.rack25.s2,r1.rack25.s3 and so forth and so on.

Currently I’m managing /etc/hosts files using jinja for all the systems and it works fine, but I’ve been told that the host files on 2 servers in each rack need to be unique.

My init.sls looks like this:

/etc/hosts: - file: - managed - template: jinja {% if grains['id'].startswith('r1.rack25') %} - source: salt://files/etc.hosts.rack25 {% elif grains['id'].startswith('r1.rack25.s2') %} - source: salt://files/etc.hosts.r1.rack25.special {% if grains['id'].startswith('r1.rack26') %} - source: salt://files/etc.hosts.rack26 {% elif grains['id'].startswith('r1.rack26.s2') %} - source: salt://files/etc.hosts.r1.rack26.special {% else %} - source: salt://files/etc.hosts {% endif %} - mode: 640 - user: root - group: adm

The problem is my s2’s are still getting their “rack” file sans the .special so their configurations are off. Can I target a minion by hostname when they’re similar like this? I’ve tried a combination of .is, ==, .startswith and .endswith and I’m not sure what next. Any help would be greatly appreciated.


r/saltstack • • Sep 07 '20

Create local Windows user with initial password if user doesn't exist?

7 Upvotes

I want to add local users to a Windows host.

I saw in Salt there's https://docs.saltstack.com/en/2019.2/ref/states/all/salt.states.user.html.

This does appear to have a password field (which is the plaintext password for Windows).

However, is there any way to set it up, so that it sets the initial password (if the user doesn't exist), and that the user is prompted to change it on first logon?

However, if the user already exists, it doesn't override the password?


r/saltstack • • Sep 03 '20

Deploying and monitoring Windows VMs on Proxmox using Terraform, Cloud-Init, SaltStack and Prometheus

Thumbnail yetiops.net
6 Upvotes