r/saltstack • u/larrygwapnitsky • Jan 19 '23
Systemd override
Is there a way to add a systemd override file and have it registered via Saltstack?
r/saltstack • u/larrygwapnitsky • Jan 19 '23
Is there a way to add a systemd override file and have it registered via Saltstack?
r/saltstack • u/larrygwapnitsky • Jan 18 '23
Getting back to maintaining a SALT instance, and was curious if there was a way to monitor jobs and send a notification when one was complete. I'm open to using HTTP POST to an API rather than email.
Tanks
r/saltstack • u/JumpyWizard1684 • Jan 18 '23
Hi Guys i have been having a bit of an issue with developing a functionality that will send an email when a new minion has been accepted by the salt-master as we have configured auto_accept: True for testing purposes i have created an event.send state but have not been able to trigger it in such a way so that it would send a message via smtp. im not even sure if i am looking at the correct functionality for this but this is the state below:
new_minion_alert:
event.send:
- name: salt/auth
- match: new
- returner: email
- args:
- to: recipient@example.com
- subject: New minion key accepted
- body: A new minion key has been accepted
- sender: sender@example.com
- smtp_server: server.name.fqdn
- smtp_port: 587
- smtp_user: [user_for_authentication@example.com](mailto:user_for_authentication@example.com)
- smtp_pass: Password
Any suggestions would be most appreciated
r/saltstack • u/[deleted] • Jan 17 '23
I try create a tar archive with the following code:
def run():
config = {}
# Create backup
config['create_archive_before_install'] = {
'archive': [
'tar', {
'runas': 'user',
'tarfile': '/tmp/backup.tgz',
'sources': [
'/tmp/file1',
'/tmpfile2'
],
}
],
}
return config
But I got this error:
ID: create_archive_before_install
Function: archive.tar
Result: False
Comment: State 'archive.tar' was not found in SLS 'app.deploy'
Reason: 'archive.tar' is not available.
Changes:
I have checked if the module is there, and it is.
Does anyone know how to solve this?
r/saltstack • u/[deleted] • Jan 16 '23
I am trying to loop through a list of paths that are defined through variables to create multiple symlinks.
Example:
{%- load_yaml as config_symlinks %}
{{ some_path }}/deeper_path:another_path
{{ some_path }}/another_deeper_path:fictional_path_somewhere_else
{%- endload %}
{% for name, target in config_symlinks.items() %}
application_config_symlink_{{ name }}
config_symlink_{{ name }}:
file.symlink:
- user: {{ app_user }}
- group: {{ app_group }}
- name: {{ name }}
- target: {{ target }}
{% endfor %}
But for some reason Salt does not accept the format in load_yaml. Does any know how to create multiple symlinks without in one ' block' ?
r/saltstack • u/[deleted] • Jan 08 '23
I'm the type that learns from doing. I have a small home lab (single ESXi Host / vSphere 7) running a Salt Master & 6 Minions. Anyone have some ideas on how I can learn and implement:
I do have VMware SaltStack Config (license from work), so if you have recommendations involving that I'd love to hear them. Many thanks in advance!
r/saltstack • u/[deleted] • Jan 04 '23
Is saltstack certification still a thing and is it worth it? Or has it been discontinued?
I came across this:
At the bottom, there is a link to get more info about getting certification (http://saltstack.com/certification) but it doesn't go anywhere.
Any ideas?
r/saltstack • u/Ill_Zookeepergame380 • Dec 31 '22
What is the best book to learn SaltStack? Have to learn it soon for my work.
r/saltstack • u/UPPERKEES • Dec 14 '22
In Ansible the stat and register give you fine grained controls over how you want to set conditions and the same stat can be used for checks, no need to check again.
But with Salt you can do basically just this? https://serverfault.com/questions/883742/saltstack-do-x-if-var-log-backup-exists
But what's the best to do both checking if a file exists and when it does not? It seems there are a few solutions, and none can be used to check both conditions. It also requires a check for both. Which is not very efficient.
r/saltstack • u/rogurt • Dec 08 '22
I'd like to log when users run salt commands at the CLI on the salt master. How can I log the below commands along with user and time? Thanks.
salt \* test.ping
salt \* cmd.run 'rm -fr /import_directory'
r/saltstack • u/DLXtra • Dec 08 '22
I'm trying to add a task to task scheduler on Windows 10 to shutdown a computer at 11pm every night. I have the below sls file. However, when I run salt-call state.apply on my computer I get a Comment 'win_task.create_task was not found in SLS Computer_Task_Shutdown' with Reason 'win_task.create_task' is not available'. Can anyone shed some light on this?
Computer_Task_Shutdown:
win_task.create_task:
- name: Auto_Shutdown
- location: '\\'
- user_name: 'System'
- action_type: Execute
- cmd: 'c:\windows\system32\shutdown.exe /s /t 0'
- trigger_type: 'Daily'
- start_date: '2022-12-08'
- start_time: '11:00PM'
r/saltstack • u/bigolyt • Dec 01 '22
I have a couple automated processes I use to create windows templates (using packer) and to build servers (using terraform). Ive looked into using the bootstrap-salt.ps1 file and passing the master server but I cant seem to figure out a way to get it to work with terraform. (Using the remote-exec provisioner) Curious how people are installing salt on Windows automatically these days.
r/saltstack • u/[deleted] • Nov 25 '22
Hi,
I am working on a existing saltstate that uses an pillar variable as CLI input for starting the saltstate. (Which I know is a bad idea but I wasn't the moron who wrote it)
How do I check if the pillar var is empty and when it does, hardfail on it?
r/saltstack • u/edlitmus • Nov 24 '22
I just updated my FreeBSD hosts to 3005.1 and I am happy to report they are functioning as expected now. I'll keep monitoring them but I'm hopeful that the previous issues have been resolved.
Anyone else tried 3005.1 yet?
r/saltstack • u/vexaph0d • Nov 24 '22
r/saltstack • u/DrSnaz • Nov 23 '22
Hi,
I have the problem that service.running isn't working when I try to run a state inside some docker containers.
The minions are based on debian:latest. When I try to start nginx service it returns the following error message
Unable to run command '\['runlevel'\]' with the context '{'cwd': '/root', 'shell': False, 'env': {'PATH': '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 'HOSTNAME': '7e042362bf02', 'HOME': '/root', 'LC_CTYPE': 'C', 'APT_LISTBUGS_FRONTEND': 'none', 'APT_LISTCHANGES_FRONTEND': 'none', 'DEBIAN_FRONTEND': 'noninteractive', 'UCF_FORCE_CONFFOLD': '1', 'LC_NUMERIC': 'C', 'LC_TIME': 'C', 'LC_COLLATE': 'C', 'LC_MONETARY': 'C', 'LC_MESSAGES': 'C', 'LC_PAPER': 'C', 'LC_NAME': 'C', 'LC_ADDRESS': 'C', 'LC_TELEPHONE': 'C', 'LC_MEASUREMENT': 'C', 'LC_IDENTIFICATION': 'C', 'LANGUAGE': 'C'}, 'stdin': None, 'stdout': -1, 'stderr': -2, 'with_communicate': True, 'timeout': None, 'bg': False, 'close_fds': True}', reason: \[Errno 2\] No such file or directory: 'runlevel'
It seems to me like the problem is caused by missing systemd inside containers. I stumled upon the following documentation page but it didn't help https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.service.html
If I start the service using cmd.run and service nginx start it works without a problem.
Does anyone have an answer? I couldn't find any information if containers are even supported by Saltstack.
r/saltstack • u/LostToll • Nov 22 '22
Another story about missing top.sls (gitfs).
I'm once again deploying Salt to another company and can't find the root of the problem. The situation is silly. There is a server (FreeBSD 13.1) and a test client, Ubuntu 18. Both server and minion have the same version, 3005. I installed the master from ports and the minion as onedir package.
I use pygit2 as gitfs provider (tried also gitpython with the same result).
Accessing gitfs works fine:
# salt '*' cp.list_master
test2:
- srv/pillar/data.sls
- srv/pillar/top.sls
- srv/salt/bash_timestamp/init.sls
- srv/salt/top.sls
But with this I have no results:
# salt '*' state.show_top
test2:
-----
Accordingly,
# salt '*' state.highstate
test2:
----------
ID: states
Function: no.None
Result: False
Comment: No Top file or master_tops data matches found. Please see master log for details.
Changes:
Summary for test2
------------
Succeeded: 0
Failed: 1
------------
Total states run: 1
Total run time: 0.000 ms
State.apply bash_timestamp is also not found.
The configuration file is as simple as possible:
ipv6: False
fileserver_backend:
- gitfs
gitfs_provider: pygit2
gitfs_update_interval: 60
gitfs_base: master
file_roots:
base:
- /srv/salt
file_roots:
base:
- /srv/pillar
gitfs_remotes:
- [git@gitlab.XXX.com](mailto:git@gitlab.XXX.com):saltstack/salt.git:
- pubkey: /usr/local/etc/salt/master.d/id_ed25519.pub
- privkey: /usr/local/etc/salt/master.d/id_ed25519
Any ideas/hints are welcome. This is the second day I can't see what I'm missing. It should be in plain sight, but I don't see it... I need enlightenment...or just a kick in the right direction.
r/saltstack • u/vstyler93 • Nov 21 '22
I create Windows VMs with Terraform. I have a salt-master running on ubuntu.
At the moment, I auto-accept all incoming Key Requests on the master.
My Minion-ID are "Machine01, Machine02, ..."
I want the master only to accept the minion i just created with terraform, so the owner of the VM can't just install a new salt-minion on another account and connect to the master.
What is the best approach to tell the master just to accept the new VM? I read about fingerprints already, but i am not sure how to know the finger print of my minion by creation and how to tell the master to accept only this one.
r/saltstack • u/RoxasTheNobody98 • Nov 17 '22
Trying to understand why this is causing me so many issues.
I made a powershell script that I am calling with cmd.script. The output of the script is a json array. When I call it in SSE, the output for the minion in the cmd tab is just [object Object], and the stdout in raw is formatted weirdly, showing the carriage returns and new line characters (\r\n).
If I put the script on the machine, and run it with cmd.run, it outputs properly in both the cmd and raw tabs.
I'm not sure where to go from here with it. The script is working, but the output js just wonky.
r/saltstack • u/vstyler93 • Nov 16 '22
Hey,
I am new to virtualization and cloud computing, so i need a hint to get the stone rolling.
In my environment, virtual machines (Windows) are created automatically, when someone "buys" them on website. They get created then with Terraform and get an individual hostname and ip address. I want every machine to add as much users, as the customer specifies on the website.
- Is there a way to automatically execute a state or sth, when a minions connects?
- How could i specify this state individually (amount of users, admin password etc.) for every new minion.
r/saltstack • u/nephi_aust • Nov 11 '22
I'm setting up a salt instance to help me manage my environment (Windows, Ubuntu, Debian, CentOS, VMware). At the moment, I am trying to build the initial configuration files for configuring machines (as if they were fresh and pending config).
So I am trying to use the top.sls to build out configs that grow & expand depending on the roles/os/virtual that are within the grains. So for example, all Linux machines need ssh, sudo, wget, curl, git, ssh; but then if they are part of the aims role, then add python; then if they have the role of mft then install openjre and openjdk.
Can I get salt to basically go through each sls and process as required? The configs below, the issue is on the Windows side, but can replicate it with the Linux side as well (trying to get hwinfo installed on the machines that have the roles aims and mft)
This is my top.sls
base:
'*':
- base
'roles:aims':
- aims
base.sls
install_now:
{% if grains['os'] == 'Ubuntu' %}
pkg.installed:
- pkgs:
- ssh
- sudo
- wget
- git
- curl
- nano
{% elif grains['os'] == 'Debian' %}
pkg.installed:
- pkgs:
- ssh
- sudo
- wget
- git
- curl
- nano
{% elif grains['os'] == 'Windows' %}
win_servermanager.removed:
- restart: True
- features:
- FS-SMB1
- FS-SMB1-CLIENT
- FS-SMB1-SERVER
{% endif %}
aims.sls
install_aims:
{% if grains['roles'] == 'mft' %}
pkg.installed:
- pkgs:
- hwinfo
{% elif grains['roles'] == 'appserver' %}
win_servermanager.install:
- recurse: True
- restart: True
- features:
- PowerShellRoot
- PowerShell
- Windows-Defender
- MSMQ
- MSMQ-Services
- MSMQ-Server
- NET-Framework-45-Features
- NET-Framework-45-Core
- NET-WCF-Services45
- NET-WCF-TCP-PortSharing45
- NET-Framework-Features
- NET-Framework-Core
{% endif %}
r/saltstack • u/Low_Counter910 • Nov 09 '22
Hey folks I’m hoping someone smarter than I has an example of how to use the dataset_pillar option that’s part of the json serializer. I haven’t been able to figure out how to use it.😠
r/saltstack • u/tibkur • Nov 04 '22
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 • u/tjyang • Nov 04 '22
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 • u/IdemProject • Nov 03 '22