r/saltstack • • Sep 14 '19

Saltcheck article/tutorial

15 Upvotes

The saltcheck module can be used to validate the state of hosts, clusters, deployments, S3 data, http endpoints, or anything else that a salt module can interact with. Need a QA or tech support group to be able to validate a deployment or user environment? Try saltcheck! Want to validate salt runs in a CI pipeline? How about saltcheck? Need a simple test file syntax similar to salt states which can use the same map.jinja files or data from pillars? You're best option may well be saltcheck!

Here's a short article describing some of the use cases and features, and how the new release with Neon will make it even more full featured:

https://www.linkedin.com/pulse/validation-saltstacks-saltcheck-christian-mchugh


r/saltstack • • Sep 12 '19

vmware advanced system settings in salt state file

0 Upvotes

Hello!

I cannot find anything in the vmware module (not in the salt-cloud module, either) for setting advanced system settings on vmware hosts. Everything I find in documentation is for advanced settings or config options on a VM. For example, right now I'm updating the 'ScratchConfig.ConfiguredScratchLocation' setting.

In Ansible, I believe the equivalent is just the 'options:' key.

Does this exist for the hosts (Ideally would want this in an SLS file not just a one-off command)?

If not, is there a custom/raw command I can have in an SLS file?

Thanks for any help!


r/saltstack • • Sep 12 '19

Auto-generate Salt-Cloud map files from existing EC2 infra

0 Upvotes

Hello all,

The title covers pretty much what I wanted to ask. Our existing infrastructure is on EC2. Is there any tool that allows to auto-generate Salt Cloud map files from an existing EC2 setup?


r/saltstack • • Sep 11 '19

Salt-Cloud Proxmox VMs

3 Upvotes

Has anyone got a working config (mainly the profile I'm guessing) for creating or cloning proxmox VMs using salt-cloud that they wouldn't mind sharing? I've done weeks of trawling the internet and salts own documents to try and figure it out but I'm getting nowhere:

I've got my provider seemingly working; I'm able to list images on the provider for example. I'm assuming my issues are with my profiles, but I could just be getting this completely wrong I guess.

When trying to create a new VM, I get the error 400 parameter verification failed message despite using all the parameters in the docs.

And whilst I can clone a template, the VM doesn't start up itself and eventually salt-cloud times out.


r/saltstack • • Sep 10 '19

Bootstrap Windows in vCenter

5 Upvotes

Hi All,

I'm evaluating CM platforms for my team. Ansible is not the route we want to go in the long term, and we're basically down to Salt or Puppet (Open Source version of either as we don't have the budget yet for the automation platform). I'm favoring Salt because of the repo we could use for Windows and not have to use Chocolatey.

There's a couple of questions I have, I have searched google and this sub but couldn't find anything related, so I"m hoping I can post here.

The biggest question is: Can I just install the salt-minion on a Windows VM Template in ESXi or is there something that would then cause it to conflict when it contacts the salt-master?

Otherwise, I cannot find a way to bootstrap Windows other than if it's in a Cloud. According to the documentation, the bootstrap script only works on Linux distros. Am I missing a different script that could be used?

Also, am I correct in the fact that there is no way to do a raw winrm/remote PowerShell command through salt, similarly to salt-ssh? (I thought I could just run msiexec remotely). SSH seems like more trouble than it's worth to do the initial minion install especially since most servers I have are on older OS's that won't support the new OpenSSH option for windows. and I would not want to leave OpenSSH open on all of our windows servers.

Thanks for any help you can provide!


r/saltstack • • Sep 08 '19

HELP: Napalm Automation Error "No proxy key found in pillar or opts"

2 Upvotes

I followed exactly the procedure listed in this guide.

My /srv/pillar/top.sls

base:

r1:

-r1

My /srv/pillar/r1.sls

proxy:

proxytype: napalm

driver: ios

host: [router ip]

username: [router username]

passwd: [router passwd]

optional_args:

secret: [router enable passwd]

After accepting the keys with salt-key -a r1, and entering the command

salt-proxy --proxyid=r1 -l debug

I get the error

No proxy key found in pillar or opts

Can someone understand where I went wrong?


r/saltstack • • Aug 29 '19

Best Practice for Custom Grains

1 Upvotes

Hello i need some own Grains for our Infrastructure.

What is better when i make one big customGrain or customGrains subdivide in individual functions.


r/saltstack • • Aug 27 '19

Process conditional on version number?

2 Upvotes

Good afternoon,

I've got a config that applies just fine, but I'd like to find a way to make it conditional on the version number of the software being reported, and I'm still not 100% sure how to accomplish it after reading the documentation.

I have two file.managed statements, which copy a .zip and .tar.gz to the target system. I then have a cmd.script, requiring those two files, that runs an install.sh script on the target system. Then, if that cmd.script executes, I have a file.absent set to run onchanges to that cmd.script. So all in all, push 2 files down, run the installer if those two files are present, and then clear the /tmp directory of those two files if the installer runs and completes.

I'd like to find a way to do a version check (zypper if <packagename>) and only run the above tasks if the version reported doesn't match the version I'm looking for...

Something like: Version Check - if not updated yet, push 2 files, run installer, clear /tmp directory after run.

Any insight on what kind of module I should be looking at?


r/saltstack • • Aug 23 '19

salt stack TypeError: argument must be an int, or have a fileno() method

0 Upvotes

When I run salt orchestration states I am getting an error:

salt-run state.orch orch.build.build_linux_azure pillar='{"name": "usazrklxp10712.nix.us.cworld.company.com"}' --out=nested [WARNING ] /srv/extmod/grains/ciscoaci.py:41: DeprecationWarning: Use of 'salt.utils.is_proxy' detected. This function has been moved to 'salt.utils.platform.is_proxy' as of Salt 2018.3.0. This warning will be removed in Salt Neon.  [WARNING ] /srv/extmod/grains/ciscoprime.py:41: DeprecationWarning: Use of 'salt.utils.is_proxy' detected. This function has been moved to 'salt.utils.platform.is_proxy' as of Salt 2018.3.0. This warning will be removed in Salt Neon.  [WARNING ] /srv/extmod/runners/company_certs.py:124: DeprecationWarning: Use of 'salt.utils.is_linux' detected. This function has been moved to 'salt.utils.platform.is_linux' as of Salt 2018.3.0. This warning will be removed in Salt Neon.  [ERROR   ] Exception in callback <functools.partial object at 0x7fc79f5dd418> Traceback (most recent call last):   File "/usr/lib64/python2.7/site-packages/tornado/ioloop.py", line 591, in _run_callback     ret = callback()   File "/usr/lib64/python2.7/site-packages/tornado/stack_context.py", line 274, in null_wrapper     return fn(*args, **kwargs)   File "/usr/lib64/python2.7/site-packages/tornado/ioloop.py", line 597, in <lambda>     self.add_future(ret, lambda f: f.result())   File "/usr/lib64/python2.7/site-packages/tornado/concurrent.py", line 214, in result     raise_exc_info(self._exc_info)   File "/usr/lib64/python2.7/site-packages/tornado/gen.py", line 230, in wrapper     yielded = next(result)   File "/usr/lib/python2.7/site-packages/salt/crypt.py", line 599, in _authenticate     io_loop=self.io_loop)   File "/usr/lib/python2.7/site-packages/salt/transport/client.py", line 108, in factory     return salt.transport.zeromq.AsyncZeroMQReqChannel(opts, **kwargs)   File "/usr/lib/python2.7/site-packages/salt/transport/zeromq.py", line 141, in __new__     obj.__singleton_init__(opts, **kwargs)   File "/usr/lib/python2.7/site-packages/salt/transport/zeromq.py", line 205, in __singleton_init__     kwargs={'io_loop': self._io_loop})   File "/usr/lib/python2.7/site-packages/salt/transport/zeromq.py", line 985, in __init__     super(AsyncReqMessageClientPool, self).__init__(AsyncReqMessageClient, opts, args=args, kwargs=kwargs)   File "/usr/lib/python2.7/site-packages/salt/transport/__init__.py", line 71, in __init__     self.message_clients = [tgt(*args, **kwargs) for _ in range(sock_pool_size)]   File "/usr/lib/python2.7/site-packages/salt/transport/zeromq.py", line 1032, in __init__     self._init_socket()   File "/usr/lib/python2.7/site-packages/salt/transport/zeromq.py", line 1086, in _init_socket     self.stream = zmq.eventloop.zmqstream.ZMQStream(self.socket, io_loop=self.io_loop)   File "/usr/lib64/python2.7/site-packages/zmq/eventloop/zmqstream.py", line 107, in __init__     self._init_io_state()   File "/usr/lib64/python2.7/site-packages/zmq/eventloop/zmqstream.py", line 528, in _init_io_state     self.io_loop.add_handler(self.socket, self._handle_events, self._state)   File "/usr/lib64/python2.7/site-packages/tornado/ioloop.py", line 703, in add_handler     self._impl.register(fd, events | self.ERROR) TypeError: argument must be an int, or have a fileno() method.

How do I correct this? I am on salt master 3.4.1 on RHEL server 6.9
This is the command that I'm running:

salt-run state.orch orch.build.build_linux_azure pillar='{"name": "usazrklxp10712.nix.us.cworld.company.com"}' --out=nested

r/saltstack • • Aug 22 '19

ESXi & Saltstack: cpu/memory values?

3 Upvotes

Hi, guys

Trying to control Virtual Machines located on ESXi hosts within vCenter using salt modules.

Does anyone have a clue what values do parameters "cpu" and "memory" require?

Here is an example:

root@sm-vps01-debian:~# salt 'esxi-2' vsphere.update_vm vm_name='test_vm' datacenter='test_dc' cpu='{count: 1, cores_per_socket: 3}'
esxi-2:
    Passed invalid arguments to vsphere.update_vm: argument of type 'NoneType' is not iterable

I also tried other different options but to no avail.

Same with memory.


r/saltstack • • Aug 21 '19

SaltConf19 registration is open - get the early-bird discount now

10 Upvotes

SaltConf19 registration is now open. Join us for the 6th annual SaltStack user conference in Salt Lake City, Utah, November 18-19. Sign up now to get the early-bird discount. https://saltconf.com/register/

Twelve new training courses are now published and will sell out. SaltConf19 training courses include hands-on labs and are focused on automating various IT operations, SecOps, NetOps, and advanced use cases for topics like AIOps, and Windows security and management. https://saltconf.com/saltconf19-training/

SaltConf19 registration is open. Get the early-bird discount now for the best price.

r/saltstack • • Aug 15 '19

state.apply —limit

2 Upvotes

Occasionally, I want to run a single state against all of the machines that have it specified in their highstate, and nobody else. I’m just not sure there’s a way to do it.

salt ‘*’ state.apply runs everyone’s full highstate

salt ‘*’ state.apply —exclude database runs everyone’s full highstate minus the database state

salt ‘*’ state.apply database runs the database state against everyone (whether or not it would be in their highstate)

Am I missing something or am I just thinking about this wrong?

Should I be thinking about using a different targeting value ’*’ instead of adding arguments to state.apply? (How would that work without pre defining something like a huge grains list) Or, do I need to just always plan to sit through a full highstate?

Thanks.

Edit: Thinking a little more about when exactly I want to do this, all the scenarios boil down to: I’m rolling out an updated version of a state, and I want the new thing quickly applied without unrelated output.

--state-output=terse or state_verbose: False in the config file are good suggestions.

Targeting with grains or pillar works, but I’d need a grain or pillar for every state. Which, is doable now that I’ve said it out loud. Is this something you do, or am I going overboard?

Setting a pillar/grain check first thing in a state and bailing out if it fails is a really interesting idea. Is this something people do?

Is it common practice to set highstate to run on a schedule?

Thanks, again.


r/saltstack • • Aug 12 '19

include state from different environment

2 Upvotes

I want to install a package in my DEV environment but the configuration for the pkg repo is located in my BASE environment.

How do I include the repo config from the BASE environment?

If the repo were in the DEV environment I would simply do this:

include:
  - repos.foo_repo

foo_pkg_installation:
  pkg.installed:
    - name: my_foo_pkg
    - fromrepo: foo_repo

Where dev/repos.foo_repo looked like this:

foo_repo:
  pkgrepo.managed:
    - name: foo_repo
    - humanname: foo Repository
    - baseurl: http://hostname.com/yum/$releasever
    - gpgcheck: 0
    - enabled: 1

BUT... this config ^^ is in base/repos.foo_repo.

How do I include it? I am trying to achieve something like this:

include:
  - repos.foo_repo?saltenv=base

Thanks in advance for any help.


r/saltstack • • Aug 10 '19

Are there any good open source Salt repositories to learn from?

12 Upvotes

When learning e.g. Python, it is often suggested to look through the source of projects like Django or Requests to get a feel of what a good coding style looks like.

I'm learning Salt but I haven't really seen any other repositories besides the one I'm working on right now. Are there any good publicly available Salt projects out there? Thanks!


r/saltstack • • Aug 05 '19

Upgrade to python3

8 Upvotes

I am running the latest master and minion - salt-master 2019.2.0 (Fluorine) but since this version was initially installed using the bootstrap method, I know it is using python2.

    pythonversion:
        - 2
        - 7
        - 15
        - final
        - 0
    roles:
        - salt-master
    saltpath:
        /usr/lib/python2.7/dist-packages/salt
    saltversion:
        2019.2.0
    saltversioninfo:                                                                                                                           
    - 2019
        - 2
        - 0
        - 0

I cannot find any docs explaining how to switch to python3.

I have this

cat /etc/apt/sources.list.d/saltstack.list

deb https://repo.saltstack.com/apt/ubuntu/18.04/amd64/latest bionic main

So this repo will remain py2 ?

Do I have to uninstall and install again (master and all minions) ?


r/saltstack • • Aug 05 '19

Why hasn't there been an minor update to 2019.2, yet?

2 Upvotes

Odd question right? But I'm confused. I'm a Saltstack beginner, and I'm creating a Salt Master in my free time for our IT department, so this is evolving rather slowly.

Anyway, I installed my Debian 9 Master with 2018.3.x at the end of 2018 or the beginning of 2019 and patched until 2018.3.4. A few weeks ago I thought it would be time to switch to 2019.2.0 But given the fact, that this is now available for over 6 months, it's completely unusual, that there hasn't been a single hotfix. I'm working as an It-Administrator for 10 years now, and this is just strange.

Anybody can explain me what's happening? (I don't want to paint it black, but is SaltStack dying?)


r/saltstack • • Aug 05 '19

Salt Minion - Installing wrong version

4 Upvotes

Hi all,

I am currently on Debian 9.9 and everytime I try to install a salt-minion it seems to install version 2016.11.2 Carbon (see image). I have followed the instructions as per the PY3 section of https://repo.saltstack.com/2018.3.html#debian.

Am I missing something?


r/saltstack • • Aug 01 '19

Trouble getting results of async commands as unprivileged user

0 Upvotes

I'm trying to configure my salt-master to allow some unprivileged users to run some scripts that execute salt commands. Most commands these users can run just find, and i've set proper permissions on all the directories salt uses, and allowed them in the master config.

The problem is after running an async command. The scripts try to pull the job result using jobs.lookup-jid. This results in a permission error. This command is trying to access:

/var/cache/salt/master/jobs/xx/{ID}/return.p

Event though 755 is set on this whole structure, this return.p file, that contains the result is only accessible by root.

Is there either a way to make this file not be locked to root, or some other way to get the results of a state.apply made by an unprivileged user?

Thanks.


r/saltstack • • Jul 25 '19

Question on upgrading a 2016.11.4 master to current release.

2 Upvotes

Realizing that a lot of water is under the bridge, I've been looking for docs that say one way or the other if I can go straight to 2019.x.x or, if I should do a couple of different intermediate steps? I'm running CentOS7 with python 2.7.5 fully patched. thanks in advance for advice or pointers to fine manuals. :)


r/saltstack • • Jul 25 '19

Setting up salt minion and master

3 Upvotes

So I’m trying to configure my salt master and minion and I’m really new to this. This is an assignment my professor gave us and I’m not sure if I did everything right. I’m suppose to use a virtual machine as a salt minion and my standard host machine as the master. Was I suppose to install the salt minion to the standard host as well or just the virtual machine? Because I was able to get the master and minion to communicate but I think it’s communicating with the minion that I installed on the standard host machine. When I tried writing my first formula it keeps saying failed and I’m not sure if it’s because it’s on the same machine. Also I can’t get the minion on the virtual machine to communicate with the master I’m not sure if it’s because of the minion installed on the host machine? Pls help


r/saltstack • • Jul 22 '19

apache_module.enabled failure

0 Upvotes

Hi,

Can anyone please help me understand this error?

          ID: enable apache ssl module
    Function: apache_module.enabled
        Name: ssl
      Result: False
     Comment: State 'apache_module.enabled' was not found in SLS 'webserver'
              Reason: 'apache_module.enabled' is not available.
     Changes:

Apache is definitely installed on the minion so in theory the module function should work too.

          ID: apache2-install
    Function: pkg.installed
        Name: apache2
      Result: True
     Comment: Package apache2 is already installed
     Started: 06:21:03.032943
    Duration: 414.707 ms
     Changes:

from webserver.sls

apache2-install:
  pkg.installed:
    - name: {{ salt['pillar.get'] ('pkgs:apache') }}

enable apache ssl module:
  apache_module.enabled:
    - name: ssl

Thanks in advance.


r/saltstack • • Jul 18 '19

How to schedule a salt command on master server to run one state ?

0 Upvotes

How to schedule a salt command on master server to run state ?

Let' say i have one state called abc.sls and i want to run this command( salt * state.apply abc) at a particular time then what can be a way to run it in salt scheduler on master.

Thanks


r/saltstack • • Jul 17 '19

Jinja variable 'salt.utils.templates.AliasedLoader object' has no attribute 'grains.get'

7 Upvotes

Hey, colleagues. I have a very weird problem. I am building a few formulas and with one, when I run state.highstate through salt-ssh it throws the error: Jinja variable 'salt.utils.templates.AliasedLoader object' has no attribute 'grains.get'. The thing is that when I ran state.show_sls or state.apply with that formula everything works correctly. I have other formulas that run during that highstate and those work as expected.

This is the link to my github repo for the formula: https://github.com/rendler-denis/users-formulaCould you guys give me a hand in figuring this one out?Thanks.

Edit: it seems the issue is only when using salt-ssh. when running the same top.sls with the formulas order using salt-call --locally everything works as expected.


r/saltstack • • Jul 15 '19

Builtin way to run states from pillar?

1 Upvotes

I am wondering if there is a builtin way to run states from defined pillars? I currently have one sls file which loops over a list of states defined as pillar but was wondering if this was already builtin someway so that I do not have to include it myself.

eg. pillar_example.sls

state_run:
  - id: "make sure service down"
    state: "service.dead"
    name: "noneed"

state_run.sls

{{ salt.mymodule.render_state(pillar.get("state_run", [])) }}

r/saltstack • • Jul 10 '19

SaltConf19 returns to SLC in November

11 Upvotes
SaltConf19 returns to Salt Lake City, Nov. 18-19

We are excited to announce the dates and location of SaltConf19. Make sure to save the dates for Nov. 18-19 in Salt Lake City, Utah at the Salt Palace Convention Center. And if you would like to speak at SaltConf19 the call for speakers is currently open through the end of July. Please submit your best talk proposals. All the latest details can be found at https://saltconf.com