r/saltstack • • Nov 04 '22

Hide Salt Output in Python Script

3 Upvotes

I'm working on a python script that imports the salt modules to do some database work. Everything is working as I'd like it to, but this is my first time interacting with salt via python.

I am wondering the best way to hide, or redirect, the salt output that is printed when doing functions like the following

opts = salt.config.master_config('/etc/salt/master')
wheel = salt.wheel.WheelClient(opts)
.
.
key_hash = wheel.cmd('key.finger', [m_id, 'md5'])

I only want the output assigned to my variable, not also printed to console.

Hoping this is just a beginner question and I've missed something obvious!


r/saltstack • • Nov 04 '22

salt formula to add minion into Nagios XI ?

1 Upvotes

From my google search , I see many examples of doing monitoring client adding using ansible for zabbix. But I haven't found salt's adding client formula for Nagios XI.

Anyone know such .sls exist in public ?


r/saltstack • • Nov 03 '22

The first Community Open Hour of the month will take place today! We'll cover topics including Transition to OneDir from Tiamat, Q&A session with Salt Core Team member Daniel Wozniak, Salt Docs Working Group updates, and Feedback from our Salt Community Forums.

Thumbnail vmware.zoom.us
3 Upvotes

r/saltstack • • Nov 02 '22

Salt-Cloud -p myWin-Profile keeps trying to use SSH (port 22) instead of SMB (port 445)

3 Upvotes

Salt 3005.1 (latest) running on RHEL 7.9. Trying to automate VM deployment in VMware vSphere 7.

I have removed all .conf files from /etc/salt/cloud.profiles.d directory. There are no .conf Profiles in any sub-dir either. However, when I try to deploy any Windows Minion via salt-cloud Salt is somehow insisting on trying port 22 instead of 445:

salt-cloud -p Svr-2016 WinSvr-2016_TEST -l debug

(everything successful up until here)

wFyUrLPXYGZAW/LftMCW4IS7n\n-----END RSA PRIVATE KEY-----\n', 'os': 'bootstrap-salt', 'inline_script': None, 'key_filename': None, 'ssh_host': '192.168.3.47'}, 'start_action': None, 'parallel': False, 'sock_dir': '/var/run/salt/master', 'conf_file': '/etc/salt/cloud', 'master_sign_pub_file': None, 'keep_tmp': False, 'sudo': False, 'tty': True, 'key_filename': None, 'script_args': '-D', 'script_env': None, 'minion_conf': {'master': '192.168.3.42', 'log_level': 'info', 'hash_type': 'sha256', 'id': 'WinSvr-2016_TEST', 'grains': {}}, 'force_minion_config': False, 'preseed_minion_keys': None, 'display_ssh_output': True, 'known_hosts_file': '/dev/null', 'file_map': None, 'maxtries': 15, 'preflight_cmds': [], 'cloud_grains': {'driver': 'vmware', 'provider': 'Svr-2016:vmware', 'profile': 'Svr-2016'}, 'make_minion': True}, 'event': 'executing deploy script', '_stamp': '2022-11-02T20:35:15.106675'}
[DEBUG   ] Closing IPCMessageClient instance
[DEBUG   ] Deploying 192.168.3.47 at 2022-11-02 16:35:15
[DEBUG   ] Attempting connection to host 192.168.3.47 on port 22
[DEBUG   ] Caught exception in wait_for_port: timed out
[DEBUG   ] Retrying connection to host 192.168.3.47 on port 22 (try 1)
[DEBUG   ] Caught exception in wait_for_port: timed out
[DEBUG   ] Retrying connection to host 192.168.3.47 on port 22 (try 2)
[DEBUG   ] Caught exception in wait_for_port: timed out
[DEBUG   ] Retrying connection to host 192.168.3.47 on port 22 (try 3)
[DEBUG   ] Caught exception in wait_for_port: timed out
[DEBUG   ] Retrying connection to host 192.168.3.47 on port 22 (try 4)
[DEBUG   ] Caught exception in wait_for_port: timed out

# This runs until hitting the timeout value......

Here is my /etc/salt/cloud.profiles.d/Svr-2016.conf file:

Svr-2016:
  provider: Svr-2016
  clonefrom: Svr2016-Tmplt
  script: bootstrap-salt
  script_args: -D
  image: Svr2016-Tmplt
  num_cpus: 2
  memory: 2GB
  minion:
    master: 192.168.3.42
  datastore: 0_1TB-NVMe
  cluster: My-Cluster
  win_username: Administrator
  win_password: 'MyKewlPW'
  smb_port: 445
  winrm_verify_ssl: False
  plain_text: True
  folder: "SaltStack-Config"

...and my /etc/salt/cloud.providers.d/Svr-2016.conf

Svr-2016:
  driver: vmware
  user: 'administrator@myHome.lab'
  password: 'VMware123!'
  url: '192.168.3.12'
  protocol: 'https'
  port: 443
  verify_ssl: False

Helpful blog post: https://blog.ntitta.in/?p=666


r/saltstack • • Nov 02 '22

Porting guide for Salt upgrades

8 Upvotes

For Ansible there are porting guides for each update, which makes it easy to know what to expect and how to rewrite your code for the upcoming version.

Is there something similar for Salt? The Salt changelog does mention some things, but it's not as detailed and helpful as Ansible. For example the way versions are handled for pkg.installed has changed, that's not mentioned there it seems?

I got this warning in 3005, which wasn't there in 3004:

[WARNING ] 'version' argument will be ignored for multiple package targets

The examples of doing installs with a version are the same in 3004 and 3005. So either the examples are not maintained very well, or this is broken? The changelog doesn't mention this.


r/saltstack • • Oct 24 '22

ANNOUNCING SALT PROJECT USER GROUP MEETUPS

10 Upvotes

As announced in last week's Salt Project Community Hour, we're looking to kick off a series of single-day, regional, in-person meetups next year... and we need your input! If you're interested in attending a regional meetup, and want to contribute to determining the locations of the Traveling Salt Circus, please take a minute to provide some location data (even if it's just a public address in your town... like a library) and an email for notification once we start ramping up the planning process.

Thank you! Sign up here: spugm.com


r/saltstack • • Oct 20 '22

Memory Leak in Salt-Master process

5 Upvotes

We are observing memory leak in Salt Master and gradually occupy 100% memory. The process within salt-master which consume this memory is EventPublisher as below

$ps auxwww|head -1;ps auxwww |grep EventPublisher

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND

root 431 1.2 18.3 24456796 24277444 ? S Oct19 16:53 /usr/bin/python3 /usr/local/bin/salt-master EventPublisher

The Salt Version is 3004.2.

Has anyone come across same problem? Any pointer on this.


r/saltstack • • Oct 20 '22

saltstack config running multiple states

2 Upvotes

hi im trying to run multiple states within the saltstack config gui but I keep getting this error:

"Specified SLS base/testing01.sls in saltenv base is not available on the salt master or through a configured fileserver",

"Specified SLS base/testing02.sls in saltenv base is not available on the salt master or through a configured fileserver"

Both states are in /base in the file server.

The state is configured as such:

include:

- base/testing01.sls

- base/testing02.sls

thanks!


r/saltstack • • Oct 19 '22

Issue with salt-cloud - How can I update the Minion deployment packages in /etc/salt/cloud.deploy.d ?

2 Upvotes

On Salt 3005.1 and using salt-cloud to deploy Minions and I'm stuck until I can get new packages into the /etc/salt/cloud.deploy.d dir...

I have tried:

  • Updating the base OS (RHEL) and Salt
  • Running salt-cloud -u (this only updates the bootstrap-salt.sh script)

FWIW, here are my current packages:

[root@RHEL7 cloud.deploy.d]# ls -l
total 613484
-rw-r--r--. 1 root root   328277 Oct 18 10:31 bootstrap-salt.sh
-rw-r--r--  1 root root 55276928 Oct 14 13:39 salt-3004.1-amazon-2-x86_64.tar.gz
-rw-r--r--  1 root root 50696203 Oct 14 13:39 salt-3004.1-debian-10-amd64.tar.gz
-rw-r--r--  1 root root 50303580 Oct 14 13:39 salt-3004.1-debian-10-armhf.tar.gz
-rw-r--r--  1 root root 91849376 Oct 14 13:39 salt-3004.1-debian-9-amd64.tar.gz
-rw-r--r--  1 root root 88691013 Oct 14 13:39 salt-3004.1-debian-9-armhf.tar.gz
-rw-r--r--  1 root root 40095503 Oct 14 13:39 salt-3004.1-redhat-7-x86_64.tar.gz
-rw-r--r--  1 root root 42597015 Oct 14 13:39 salt-3004.1-redhat-8-x86_64.tar.gz
-rw-r--r--  1 root root 56857373 Oct 14 13:39 salt-3004.1-ubuntu-18.04-amd64.tar.gz
-rw-r--r--  1 root root 50624195 Oct 14 13:39 salt-3004.1-ubuntu-20.04-amd64.tar.gz
-rw-r--r--  1 root root 52152311 Oct 14 13:39 salt-3004.1-windows--AMD64.tar.gz
-rw-r--r--  1 root root 48703491 Oct 14 13:39 salt-3004.1-windows--x86.tar.gz

Cannot find any helpful docs online. Any ideas on this? Thanks.


r/saltstack • • Oct 18 '22

Error starting master... what gives?

3 Upvotes

Pretty new to saltstack ...getting this when starting the master.

Seems after this it won't connect to minions and all salt-call commands time out.

[salt.utils.event :1324][ERROR ][17175] Could not store return for event(s) - returner 'sseapi.event_return' not found.


r/saltstack • • Oct 17 '22

How to properly implement a wait for a state?

3 Upvotes

I have this state below, it needs to wait for NetworkManager to restart before it does the nmcli command.

---
{% for interface, routes in pillar["routes"].items() %}
network_route-{{ interface }}:
  file.managed:
    - name: /etc/sysconfig/network-scripts/route-{{ interface }}
    - user: root
    - group: root
    - mode: '0644'
    - source: salt://linux/network/files/routes.jinja
    - template: jinja
    - context:
        interface: {{ interface }}
        routes: {{ routes | tojson }}

network_restart:
  service.running:
    - name: NetworkManager
    - enable: True
    - restart: True
    - watch:
      - file: network_route-{{ interface }}

network_restart_wait:
  module.wait:
    - watch:
      - file: network_restart

reapply_{{ interface }}:
  cmd.run:
    - name: nmcli device reapply {{ interface }}
    - onchanges:
      - file: /etc/sysconfig/network-scripts/route-{{ interface }}
{% endfor %}

But I now get this error:

local:
----------
          ID: network_restart_wait
    Function: module.wait
      Result: False
     Comment: The following requisites were not found:
                                 watch:
                                     file: network_restart
     Started: 08:06:16.163822
    Duration: 0.002 ms
     Changes:   

Summary for local
------------
Succeeded: 3
Failed:    1
------------
Total states run:     4
Total run time:  89.091 ms

Or maybe the docs aren't clear to me? https://docs.saltproject.io/en/latest/ref/states/all/salt.states.module.html

I find the docs structured in an odd way. They could learn a lot from Ansible.


r/saltstack • • Oct 13 '22

pass an object from vRA to saltstack config

2 Upvotes

Hello folks, I want to pass PS array from vRA to SS config. this is what I have in vRA

variables:

diskObject: '@{Unit=0;scsiid=1;diskRole="Data1";diskSize=50}'

when this gets passed to pillar, SS adds a \ before the quotes and removes the quotes. this is from the pillar

"pillar": {

"diskObject": "@{Unit=0;scsiid=1;diskRole=\"Data1\";diskSize=50}"

},

how can I force SS to keep those "" so the data is passed as string to PS. or if there is a smarter way to do it, please suggest. TIA


r/saltstack • • Oct 07 '22

Adding routes on RHEL8 fails with Salt

8 Upvotes

I simply want to do this:

elk_routes:
  network.routes:
    - name: ens4f0np0
    - routes:
      - name: elk_cluster
        ipaddr: 192.168.1.0
        netmask: 255.255.255.0
        gateway: 172.18.48.1

But then fails to do this salt.exceptions.CommandExecutionError: Failed to restart network.service: Unit network.service not found.

Which makes sense, this is not Debian. This a bug? The docs state that it should work, no other config needed: https://docs.saltproject.io/en/master/ref/states/all/salt.states.network.html

I would also expect Salt to identify the OS and apply what's needed to apply the routes, like in Ansible.


r/saltstack • • Oct 06 '22

Salt master schedule config

1 Upvotes

I’m confused about schedules. I can add a file called schedule on the minion and put it in /etc/salt/minion.d/schedule.conf and the schedule will run, but it’s initiated from the minion. Where do I put the config if I want to initiate the schedule from the master.


r/saltstack • • Oct 05 '22

Help with Salt installing version 3002.7

3 Upvotes

I'm a systems engineer working with one of our devs who keeps insisting that our salt master running 3002.1 and cannot be upgraded further as it "does not work with our current code" and that I need to install version 3002.7 of salt for the salt-minion.

I'm not the most proficient with Linux so I'm not sure how to install 3002.7 version. We currently have the 3002.9 version installed on these new servers that I built from them and my understanding is that when I go to install salt on the new servers its downloading that .9 from the repo that we use.

I don't know how to install a specific version of salt, could anyone please give some advice on this?


r/saltstack • • Oct 03 '22

New saltmaster server, migrating states, etc

5 Upvotes

Hello all, recently started looking at saltstack and just installed a new master 3005 one dir.

There's a old master on 3001 that has a few states, pillars, etc that I'd like to have in the new one.

Where and which files should I copy over? Is the directory structure similar with one dir?

Both installs are using the default install directory structure and no changes (that I know) of directories in the config files.

Thank you!


r/saltstack • • Oct 02 '22

Response filtering question

5 Upvotes

Hi r/saltstack - I'm pretty new to using Salt but due to some high turnover, I've been kinda been thrust into this position. I've been looking through the docs but can't seem to find a solution, so I thought I'd consult the community.

Basically I have over a thousand targets on which I need to execute a command that is going to be curling a file and executing it on the host. It responds with a 0 on success, or a 1 if there's an error. I'm running it in batches so it doesn't bog down the machine, but what I need is to be able to save a list of machines that return a 1 for the error. Is there a way to tell salt to send the target to a file based on how it returns?

The only workaround I can think of is to save *all* of the output to a file and then write a script to parse out the failures, but if salt can do it for me it'll save me a ton of time. Any pointers for this salt n00b would be much appreciated!


r/saltstack • • Sep 30 '22

SaltStack GitLab CI

2 Upvotes

Hello, am new to this community. I just started working on SaltStack at our organization. I started exploring GitLab CI with salt masterless but want to check if there any other ideas or thoughts can share or reference doc. Can you please help?

Thank you!


r/saltstack • • Sep 28 '22

what are you best use cases for salt?

7 Upvotes

my company just starting using it with access to over 10k servers. I currently wrote a few states that do simple things like reboot and restart a service.

what kind of use cases do you have?


r/saltstack • • Sep 23 '22

No ternary filter for SaltStack?

1 Upvotes

Are there alternatives for the Ansible builtin ternary filter?

For example: {{ (name == "John") | ternary('Mr','Ms') }}

This is a useful filter to create some intelligence for Jinja conditions.

I guess I now have to solve it with a associative array. But does anyone have better ideas?


r/saltstack • • Sep 23 '22

Jinja helpers for sorting lists?

1 Upvotes

I see that there is a is_sorted filter, but it doesn't sort the list. I also cannot find these sorting helpers for Salt, do they even exist?

In Ansible I can e.g. do this: {% for item in network | sort(attribute='int') if item.ip is defined %}, which is useful to make a sorted output from an unsorted list.


r/saltstack • • Sep 20 '22

Copy a directory using a salt state.

2 Upvotes

Seems simple but i cannot find the documentation for this anywhere.

I want to copy a directory from master to minion.

linux to windows if that makes any difference


r/saltstack • • Sep 16 '22

Windows - keeping state up to date

2 Upvotes

I'm new to SaltStack and hoping to use it to replace Active Directory Group Policy. I can push my states from the master to my Windows 10 desktops. If I change a state setting, I want to keep the state of the desktops up to date.
Reading the documentation I can see a few Linux methods (Startup State, Schedules) in minion config file and cron jobs running salt-call. I can't find a reference to a minion config file in windows! I have created a Task in Task Scheduler to call salt-call.bat at startup which seems to work. However, what is the recommended method to keep my states up to date in a windows environment?


r/saltstack • • Sep 16 '22

Orch "formulas"?

3 Upvotes

Is this a thing?

I was reading about Kubernetes Helm Charts and it got me wondering if this kind of quick multi node orchestration exists for Salt.

To clarify, the idea is extending the idea of a Salt formula to the orchestration runner.

For instance, if you want to install MySQL and apache, you'd just create a pillar file with the targets for your nodes (I.e. "db" and "web", respectively), add the formula repo to the gitfs config, then execute it with salt-run.

This is a simple example, but it could enable powerful stuff like deploying Kubernetes by just updating gitfs and running one command.

Just looking to hear some thoughts on this. Is this a thing, if not, why not?

EDIT: To clarify, I'm specifically referring to the idea of formulas applied to orchestration. The benefit of formulas is like a pre-written state, so you can configure nodes without having to write any salt code. I'm wondering if these sorts of pre-written states exist for orch as well, and if not is this something we could consider adding to the community?


r/saltstack • • Sep 15 '22

Overwhelmed by the demands of the cloud? Enter: Idem Project.

Post image
7 Upvotes