salt-stack

How to import and use Jinja macros in a python script (Saltstack setup)

How to import and use Jinja macros in a python script (Saltstack setup) Question: I have a saltstack setup where one of my pillar file is written in python. This pillar file is pulling some data from a json file. In this python script, there are 2 functions. In the second function, I want to …

Total answers: 1

Ignoring a specific undefined variable with pyright

Ignoring a specific undefined variable with pyright Question: When writing custom SaltStack modules/states using VScode and linting with pyright, I get the following error all over the place: "__salt__" is not defined It’s not a killer, because I can put the following on the end of every line that references it: # pyright: ignore[reportUndefinedVariable] But …

Total answers: 2

How to define name of win package in salt state for python?

How to define name of win package in salt state for python? Question: I’m tryint to create salt state for Windows, to install python3. Here is my sls file: {% set version = "3.8.3150.0" %} {% set SOURCE_PATH = ‘http://local-nas/’ %} {% if grains[‘cpuarch’] == ‘AMD64’ %} {% set PROGRAM_FILES = "%ProgramFiles(x86)%" %} {% else …

Total answers: 1

What's the difference between state.sls and state.apply?

What's the difference between state.sls and state.apply? Question: What’s the difference between state.apply and state.sls? When should I use state.apply vs state.sls? Asked By: aedry || Source Answers: state.sls <state_file> will execute the states in a specific file. state.highstate will execute the highstate configured by top.sls state.apply will do a state.highstate if no arguments are …

Total answers: 1

how to grant www-data user access to python salt module?

how to grant www-data user access to python salt module? Question: I’m maintaining a small legacy php5 application (based on CodeIgniter) that acts as a salt web UI that allows me to run salt commands and schedule repeating jobs. The web app runs python scripts which invoke the salt api to execute the commands. The …

Total answers: 1

How to call salt-ssh (SSHClient) via Python API

How to call salt-ssh (SSHClient) via Python API Question: I installed Salt in a Python 3 virtual environment and created a Salt configuration that uses a non-root folder for everything (/home/user/saltenv). When using the salt-ssh command inside the venv, e.g. salt-ssh ‘*’ test.ping, everything works as exptected. (Please note that the config dir is resolved …

Total answers: 1

Set a variable based on a py.test (testinfra) check output

Set a variable based on a py.test (testinfra) check output Question: I am trying to make a testinfra test file more portable, I’d like to use a single file to handle tests for either a prod / dev or test env. For this I need to get a value from the remote tested machine, which …

Total answers: 1

salt-ssh : Disable SSH Host Key Checking with python api

salt-ssh : Disable SSH Host Key Checking with python api Question: I’m working with salt-ssh and with the command line I can use option -i to use ‘StrictHostKeyChecking’ (agent) [root@NODE ~]# salt-ssh ‘af0abc4b-6980d-4fdd-ba63-192cb3d116be’ test.ping af0abc4b-6980d-4fdd-ba63-192cb3d116be: ———- retcode: 254 stderr: stdout: The host key needs to be accepted, to auto accept run salt-ssh with the -i …

Total answers: 1

SaltStack Can't get Master config variables to minion

SaltStack Can't get Master config variables to minion Question: New to SaltStack. I’m writing a custom returner for salt but the minion does not seem to be able to see config variables set in the master (/etc/salt/master). I have things like connection info which need to be passed to the minion. __salt__[‘config.option’](‘returner.myconfig.test’) comes back empty …

Total answers: 2

How do I write a salt state to pip install requirements file?

How do I write a salt state to pip install requirements file? Question: Can’t find this written down. I’m trying: pip.install: – requirements: /path/to/requirements.txt But I’m getting the error that ID pip.install in SLS python.python-pip is not a dictionary Many of the other ways include virtualenvs, but I don’t want to use a virtualenv to …

Total answers: 1