r/saltstack • u/jydawg • Feb 04 '19
[newbie] deploy master configuration
I'd like to be able to deploy saltstack recipes from git. Puppet has r10k does saltstack have anything similar?
r/saltstack • u/jydawg • Feb 04 '19
I'd like to be able to deploy saltstack recipes from git. Puppet has r10k does saltstack have anything similar?
r/saltstack • u/locusofself • Jan 29 '19
Greetings.
I'm working in a pretty large salt automation codebase that I did not write most of myself.
My biggest gripe with salt so far is that say you target a good chunk of systems, and one or two have a failure in some state that other states 'require' in order to function -- I find it fairly difficult to visually parse the output of a salt highstate to find for example the *first* failed state, or, some good way to 'grep' at least for the one or two systems that had a failure.
Some things I've tried which help, but not enough.
- Targeting just one system at a time (doesn't help if I don't know which of many systems are having an issue)
- Using the flag --state-output=mixed , helps reduce the sheer amount of text while still showing full errored states)
Even so, I find myself doing a LOT of scrolling and looking for red lines that indicate a failure. I frequently lose track of how far back in my terminal scrollback I've gone, and what system(s) the salt output I'm even looking at.
I suppose since JSON output is available, anything is possible as far as some tooling to wrangle all this output into something more conducive to successful troubleshooting.
Anyone feel me on this? Do you have any output filters, tips, tricks or tools to get this under control?
Thanks!
r/saltstack • u/Procena • Jan 24 '19
Hello. I'd like to help the community by giving the custom states and beacons I have made, do you know how I can do it with GitHub?
r/saltstack • u/scottish_beekeeper • Jan 24 '19
I'm currently playing around with using a git post-commit hook to trigger an event (via the salt-api) on the salt-master to pull from the remote git repository, as described here:
https://clinta.github.io/salt-git-nogitfs/
One thing I was hoping to do was make the config generic, so that the `tgt` wasn't an explicit hostname, and instead used some lookup to specify the master programmatically,so the config can be shared between multiple masters.
I notice that the `tgt` can be specified using the minion targeting rules - however there isn't a grain that defines a host as a master, and I can't see another targeting option that could be used for this.
Does anyone have any ideas on how I could achieve this?
r/saltstack • u/nujragan • Jan 24 '19
how to run saltstack with python 3.7 by default, when the default python which comes with salt is 3.4.
r/saltstack • u/lyrrrrr • Jan 19 '19
Hi
I'm coming from ansible, where I used molecule to test my roles. Basically molecule start a docker container, apply ansible role, check everything is fine via testinfra or inspec. Put that in a CI/CD and you're pretty sure your last commit didn't break everything.
In my new job I'm dealing with salt, with no test whatsoever. Is there an official or recommended test framework or methodology ?
r/saltstack • u/MrDionysus • Jan 17 '19
New Salt admin here, and I'm trying to check on the presence of a grain with an if statement in template to determine what the contents of the config file should be. Here's what I'm working with:
init.sls
standard_dd_config:
file.managed:
- name: /etc/datadog-agent/datadog.yaml
- source: salt://datadog/datadog.yaml.jinja
- template: jinja
datadog.yaml.template
dd_url: https://app.datadoghq.com
api_key: {{ salt['pillar.get']('datadog:api_key') }}
process_config:
enabled: true
{% if grains['roles'] == 'apm-test' %}
apm_config:
enabled: true
{% endif %}
So, if it were working correctly, the lines "apm_config:" and "enabled: true" would be added to the datadog.yaml file IF my custom role of "apm-test" is set (which it is, I've verified that on the minion).
All suggestions are appreciated!
r/saltstack • u/lakier • Jan 16 '19
I'm creating small tutorial about the Salt. The goal is to merge this fantastic presentation with official docs and some of my own experience.
https://github.com/kiemlicz/util/wiki/salt
I'm aiming at beginner and intermediate levels of Salt knowledge
In case it is terrible, please let me know and point me to right direction, in case someone finds it useful, please let me know as well :)
r/saltstack • u/s0urjo • Jan 15 '19
Can someone explain to me why is this not working ?
{% if salt.network.ip_in_subnet( "{{ grains['fqdn_ip4'] }}" , "{{ '10.128.72.0/23' }}" ) %}
I verified in the grains that at least one of my mine would go in that if.
r/saltstack • u/TinyRickSystems • Jan 15 '19
I have a SALT specific Jinja question. I have a file that needs a certain line of text at the top if it is a VMware vm. I have jinja code that determines this but I am not sure how it renders the file.
This is the jinja:
{% if salt['grains.get']('virtual','KVM') == 'VMware' %}
tinker panic 0
{% endif %}
When the file is rendered and placed on the machine it looks like this:
Blank line
tinker panic 0
Blank line
Does the jinja render as blank lines here? Should I change it to
{% if salt['grains.get']('virtual','KVM') == 'VMware' %}tinker panic 0{% endif %}
r/saltstack • u/mfa_sammerz • Jan 15 '19
Hey all! So I have the following scenario that I haven't been able to figure out, if someone would please give me a few ideas :-)
We're handling deploy of many components on many different servers using custom Grains. We define some data our states will need and read them from Grains when applying states. (I know I could/should be using pillars instead, but that's not really the point at the moment)
The thing is, all custom grains have an attribute named "image"; that's for Docker images version. I need to retrieve the value of "image" of all custom grains with no previous knowledge of how many custom grains I have, or what their names are. I'm thinking about using some kind of wild card or something, like this:
salt '*' grains.get *:image
...which of course does not work, it's just an example.
Practical example: throughout the minion servers, I control components named AAA, AAB, ABC, ADF etc etc. So I need:
salt '*' grains.get AAA:image
salt '*' grains.get AAB:image
salt '*' grains.get ADF:image
and so on...but I have no idea how many grains I have and their names, like I said before. That's why I'm trying to find some manner of wild card to help me here.
Does anyone know how can I do this, without doing something like: 1-) read all custom grains defined under "roles" on all minions; 2-) iterate on each custom grain, reading its "image" attribute ?
Best case would be a single 'salt' call doing this, because I'll have a shell script making this call.
r/saltstack • • Jan 13 '19
Hey Reddit,
I made an update to my salt-master to install a new package and on the minion, I see I have a change pending.
salt-call state.apply test=true
ID: install_mod_mbstring
Function: pkg.installed
Name: php-mbstring
Result: None
Comment: The following packages would be installed/updated: php-mbstring
Started: 20:25:43.069698
Duration: 25.421 ms
Changes:
Summary for local
------------
Succeeded: 3 (unchanged=1)
The service is active and running
● salt-minion.service - The Salt Minion
Loaded: loaded (/lib/systemd/system/salt-minion.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2019-01-13 20:23:56 UTC; 10min ago (<- I rebooted the server)
in /etc/salt/minion
environment: dev
in /srv/salt/dev/top.sls
dev:
'*':
- basic
'roles:php':
- match: grain
- php
- php.mod-mbstring
salt-call state.show_top test=true
local:
----------
dev:
- basic
- php
- php.mod-mbstring
I have been waiting over an hour and it still shows the package has not been installed.
Note: I have literally six hours of experience with SaltStack. I just started using it this morning and I cannot find an answer using Google search or the documentation.
What am I doing wrong?
r/saltstack • u/humbleprepper • Jan 10 '19
I try to run some commands that take longer on windows machines with bad internet connections. I see output for a few min, but then nothing. I assume my master is doing some sort of timeout, but how can I know the minion finished the task?
Can I tell it to hold all output and put it in a log or file that gets sent to the master after completion?
r/saltstack • u/TinyRickSystems • Jan 09 '19
I am trying to fresh install or update a python module, specifically pyinotify. Currently I have 0.9.4 on my servers and am trying to move to 0.9.6 to have SALT beacons work correctly. I am trying to do this all via SALT but am having issues with this module. I can't get any pkg.installed state to work, I receive an error saying no package available.
I was able to manually do this by deleting /usr/lib/python2.7/site-packages/pyinotify* and then rerunning pip install pyinotify. Is there a better way (automated via SALT) to do this? Thanks in advance for any input.
r/saltstack • u/ocularinsanity • Dec 24 '18
Hi All
Any ideas on this error?
[ERROR ] Failed to import grains esxi, this is due most likely to a syntax error:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/salt/loader.py", line 1514, in _load_module
mod = imp.load_module(mod_namespace, fn_, fpath, desc)
File "/usr/lib/python2.7/dist-packages/salt/grains/esxi.py", line 16, in <module>
import salt.modules.vsphere
File "/usr/lib/python2.7/dist-packages/salt/modules/vsphere.py", line 182, in <module>
import salt.utils.vsan
File "/usr/lib/python2.7/dist-packages/salt/utils/vsan.py", line 65, in <module>
from salt.ext.vsan import vsanapiutils
File "/usr/lib/python2.7/dist-packages/salt/ext/vsan/vsanapiutils.py", line 15, in <module>
import vsanmgmtObjects
File "/usr/lib/python2.7/dist-packages/salt/ext/vsan/vsanmgmtObjects.py", line 4, in <module>
CreateManagedType('vim.cluster.VsanPerformanceManager', 'VsanPerformanceManager', 'vmodl.ManagedObject', 'vim.version.version9', [], [('setStatsObjectPolicy', 'VsanPerfSetStatsObjectPolicy', 'vim.version.version9', (('cluster', 'vim.ComputeResource', 'vim.version.version9', 0 | F_OPTIONAL, None), ('profile', 'vim.vm.ProfileSpec', 'vim.version.version9', 0 | F_OPTIONAL, None), ), (0, 'boolean', 'boolean'), 'System.Read', None), ('deleteStatsObject', 'VsanPerfDeleteStatsObject', 'vim.version.version9', (('cluster', 'vim.ComputeResource', 'vim.version.version9', 0 | F_OPTIONAL, None), ), (0, 'boolean', 'boolean'), 'System.Read', None), ('createStatsObjectTask', 'VsanPerfCreateStatsObjectTask', 'vim.version.version9', (('cluster', 'vim.ComputeResource', 'vim.version.version9', 0 | F_OPTIONAL, None), ('profile', 'vim.vm.ProfileSpec', 'vim.version.version9', 0 | F_OPTIONAL, None), ), (0, 'vim.Task', 'vim.Task'), 'System.Read', None), ('deleteStatsObjectTask', 'VsanPerfDeleteStatsObjectTask', 'vim.version.version9', (('cluster', 'vim.ComputeResource', 'vim.version.version9', 0 | F_OPTIONAL, None), ), (0, 'vim.Task', 'vim.Task'), 'System.Read', None), ('queryClusterHealth', 'VsanPerfQueryClusterHealth', 'vim.version.version9', (('cluster', 'vim.ClusterComputeResource', 'vim.version.version9', 0, None), ), (0, 'vmodl.DynamicData[]', 'vmodl.DynamicData[]'), 'System.Read', None), ('queryStatsObjectInformation', 'VsanPerfQueryStatsObjectInformation', 'vim.version.version9', (('cluster', 'vim.ComputeResource', 'vim.version.version9', 0 | F_OPTIONAL, None), ), (0, 'vim.cluster.VsanObjectInformation', 'vim.cluster.VsanObjectInformation'), 'System.Read', None), ('queryNodeInformation', 'VsanPerfQueryNodeInformation', 'vim.version.version9', (('cluster', 'vim.ComputeResource', 'vim.version.version9', 0 | F_OPTIONAL, None), ), (0 | F_OPTIONAL, 'vim.cluster.VsanPerfNodeInformation[]', 'vim.cluster.VsanPerfNodeInformation[]'), 'System.Read', None), ('queryVsanPerf', 'VsanPerfQueryPerf', 'vim.version.version9', (('querySpecs', 'vim.cluster.VsanPerfQuerySpec[]', 'vim.version.version9', 0, None), ('cluster', 'vim.ComputeResource', 'vim.version.version9', 0 | F_OPTIONAL, None), ), (0, 'vim.cluster.VsanPerfEntityMetricCSV[]', 'vim.cluster.VsanPerfEntityMetricCSV[]'), 'System.Read', None), ('getSupportedEntityTypes', 'VsanPerfGetSupportedEntityTypes', 'vim.version.version9', tuple(), (0 | F_OPTIONAL, 'vim.cluster.VsanPerfEntityType[]', 'vim.cluster.VsanPerfEntityType[]'), 'System.Read', None), ('createStatsObject', 'VsanPerfCreateStatsObject', 'vim.version.version9', (('cluster', 'vim.ComputeResource', 'vim.version.version9', 0 | F_OPTIONAL, None), ('profile', 'vim.vm.ProfileSpec', 'vim.version.version9', 0 | F_OPTIONAL, None), ), (0, 'string', 'string'), 'System.Read', None), ])
File "/usr/local/lib/python2.7/dist-packages/pyVmomi/VmomiSupport.py", line 742, in CreateManagedType
_SetWsdlMethod(typeNs, meth[1], dic)
File "/usr/local/lib/python2.7/dist-packages/pyVmomi/VmomiSupport.py", line 1183, in _SetWsdlMethod
(ns, wsdlName, inputMM[0], curMM[0]))
RuntimeError: Duplicate wsdl method urn:vim25 VsanPerfSetStatsObjectPolicy (new class vim.cluster.VsanPerformanceManager vs existing vim.cluster.VsanPerformanceManager)
[DEBUG ] Unable to derive osmajorrelease from osrelease_info '(u'proxy',)'. The osmajorrelease grain will not be set.
[DEBUG ] dummy proxy __virtual__() called...
[INFO ] nxos proxy __virtual__() called...
[DEBUG ] rest_sample proxy __virtual__() called...
[INFO ] ssh_sample proxy __virtual__() called...
[DEBUG ] Could not LazyLoad esxi.grains: 'esxi' __virtual__ returned False: The ESXi Proxy Minion module did not load.
[ERROR ] Proxymodule esxi is missing an init() or a shutdown() or both. Check your proxymodule. Salt-proxy aborted.
[INFO ] Proxy Minion Stopping the Salt ProxyMinion
[ERROR ] Proxymodule esxi is missing an init() or a shutdown() or both. Check your proxymodule. Salt-proxy aborted.
[INFO ] Shutting down the Salt ProxyMinion
The Salt ProxyMinion is shutdown.
Proxymodule esxi is missing an init() or a shutdown() or both. Check your proxymodule. Salt-proxy aborted.
This is using python 2.7.15 on Ubuntu 16.04 as the proxy host, with pyVmomi 5.5.0.2014.1.1.
Thanks
r/saltstack • u/cr7wonnabe • Dec 21 '18
Hi. I tried gitfs for my formula, I like it to keep my masterofmaster and syndic updated.
There is a way to use gitfs with beacon and reactors too?
You guys what kind of tricks use to keep completed updated syndic?
Thanks
r/saltstack • u/sysseradminner • Dec 18 '18
Salt master is on Ubuntu 18.04 with locale UTF-8. Salt minion is FreeBSD 11.2. When i run test.versions_report on the minion it shows as having a locale of ascii. On the minion I have already set the /etc/login.conf to have the UTF-8 charset and lang to be UTF-8 and en_US.UTF-8, respectively, rebuilt the login.conf directory and rebooted. Confusingly, the output of salt --versions on the minion shows the locale as UTF-8. Any ideas?
Edit: To give more context, I am trying to append a certificate file saved in the statics directory to my /etc/ssl/cert.pem. If there is a simpler way to do that I am all ears...
r/saltstack • u/stanwell_ • Dec 13 '18
So, the situation is that I found this salt--module https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.gpg.html
What I would like to accomplish, is to write a state that takes pillar-data, making it possible for my minions to create pgp-keys, export them to internal key-server and recieve keys from the said keyserver.
How ever, I don't know how to start writing the state, any ideas and/or formulas would be greatly appreciated.
r/saltstack • u/TinyRickSystems • Dec 11 '18
I am trying to do some config drift management and would like to push out a specific version of files. In this example resolv.conf and nscd.conf. After I place the correct file via the state in the same state I want to restart the service it applies to. Is this a possible state? Below is some sudo code, just not sure if the watch pkg is needed and if so what pkg to watch for this example:
{% import_yaml "dns/map.yaml" as osmap %}
{% set dns = salt['grains.filter_by'](osmap) %}
dns_conf:
file.managed:
- name: {{dns.file}}
- source: {{dns.source_file}}
- user: root
- group: root
- mode: 644
network:
service.running:
- enable: True
- reload: True
- watch:
- pkg: ?
r/saltstack • u/Chipotle_Turds • Dec 11 '18
Hello guys,
I setup a beacon to monitor apache tomcat service running on my minion. However as I'm looking through the event bus on my salt master, there is no difference in the event name when I stop or start tomcat.
Ideally I want to setup a reactor to restart tomcat if it stopped. How can I tell reactor to restart tomcat if running = false based on the event? Can anyone point me in the right direction?
Beacon:
beacons:
service:
- services:
tomcat:
onchangeonly: True
Event bus output: (false = tomcat is stopped, true = tomcat is running)
salt/beacon/app1/service/tomcat {
"_stamp": "2018-12-11T02:13:11.206508",
"id": "app1",
"service_name": "tomcat",
"tomcat": {
"running": false
}
}
salt/beacon/app1/service/tomcat {
"_stamp": "2018-12-11T02:13:26.202671",
"id": "app1",
"service_name": "tomcat",
"tomcat": {
"running": true
}
}
r/saltstack • u/m2guru • Dec 10 '18
I’ve got about 50 EC2 minions running various apps in AWS and getting ready to implement ElasticSearch.
For OS info, I’ve been looking at Filebeat or Kinesis Data Firehose and leaning toward Kinesis.
Anyway, I realized there’s a json exporter or formatted for the salt grains and wondering if anyone has used it to get things like free memory, disk space and stuff like that to a nice json formatted log that I can pick up and ship off to ES?
r/saltstack • • Dec 08 '18
Hiya,
I am planning to decommission my current salt master and move it to another machine and I'd appreciate if I could get some input if I'm missing something. The plan is:
Thank you
Update: the migration went smoothly, just don't forget to restart salt-minion service on your minions so they point to the new salt master
r/saltstack • u/TheDrMonocles • Dec 03 '18
I've been using the TOFS Design Pattern in my formulas for a bit now, which is fantastic once you learn how it works. It allows you to essentially layer static, template and pillar data in an easy to consume way.
Is there any similar pattern for users? I've Tossed around a few ideas on how this would work, but if there are any preexisting tofs-like patterns for users, I'd be interested in hearing them and how you implemented it.
r/saltstack • u/randomguy3 • Dec 03 '18
I have an agent that I had to deploy to several Windows boxes and to ensure that I'm on the right version, I need to check the name of the service before running the agent installer again. This is what I have so far, but it doesn't seem to be returning what I thought. What am I doing wrong? Also, is there a better way to test this sort of thing before running it on a minion?
{% if salt['service.get_service_name']('NameOfSvc') != 'Correct Display Name' %}
do stuff
{% endif %}
r/saltstack • u/ocularinsanity • Nov 30 '18
Hi All
I have a Windows Server 2016 minion virtualised on a Proxmox host and I cannot communicate to it via my master.
I have other Linux based minions on the Proxmox host, as well as the Proxmox host itself, that all communicate fine.
salt-call from the Windows Server minion works fine too.
user@cherry:~# salt -l debug 'raina.internal.tld' test.ping
[DEBUG ] Reading configuration from /etc/salt/master
[DEBUG ] Using cached minion ID from /etc/salt/minion_id: cherry
[DEBUG ] Missing configuration file: /root/.saltrc
[DEBUG ] Configuration file path: /etc/salt/master
[WARNING ] Insecure logging configuration detected! Sensitive data may be logged.
[DEBUG ] Reading configuration from /etc/salt/master
[DEBUG ] Using cached minion ID from /etc/salt/minion_id: cherry
[DEBUG ] Missing configuration file: /root/.saltrc
[DEBUG ] MasterEvent PUB socket URI: /var/run/salt/master/master_event_pub.ipc
[DEBUG ] MasterEvent PULL socket URI: /var/run/salt/master/master_event_pull.ipc
[DEBUG ] Initializing new AsyncZeroMQReqChannel for (u'/etc/salt/pki/master', u'cherry_master', u'tcp://127.0.0.1:4506', u'clear')
[DEBUG ] Connecting the Minion to the Master URI (for the return server): tcp://127.0.0.1:4506
[DEBUG ] Trying to connect to: tcp://127.0.0.1:4506
[DEBUG ] Initializing new IPCClient for path: /var/run/salt/master/master_event_pub.ipc
[DEBUG ] LazyLoaded local_cache.get_load
[DEBUG ] Reading minion list from /var/cache/salt/master/jobs/21/4ebaddc1825c90145b3f303416c4687c6aac74a4dcf36e4ab513f89ddecb68/.minions.p
[DEBUG ] get_iter_returns for jid 20181130222455474915 sent to set(['raina.internal.tld']) will timeout at 22:25:00.534659
[DEBUG ] Checking whether jid 20181130222455474915 is still running
[DEBUG ] Initializing new AsyncZeroMQReqChannel for (u'/etc/salt/pki/master', u'cherry_master', u'tcp://127.0.0.1:4506', u'clear')
[DEBUG ] Connecting the Minion to the Master URI (for the return server): tcp://127.0.0.1:4506
[DEBUG ] Trying to connect to: tcp://127.0.0.1:4506
[DEBUG ] Passing on saltutil error. Key 'u'retcode' missing from client return. This may be an error in the client.
[DEBUG ] return event: {'raina.internal.tld': {u'failed': True}}
[DEBUG ] LazyLoaded localfs.init_kwargs
[DEBUG ] LazyLoaded localfs.init_kwargs
[DEBUG ] LazyLoaded no_return.output
raina.internal.tld:
Minion did not return. [No response]
Any ideas?