Skip to content

Instantly share code, notes, and snippets.

@max-arnold
Created March 27, 2024 05:07
Show Gist options
  • Save max-arnold/7c7ce5b780c84ed29c0815851c3805ea to your computer and use it in GitHub Desktop.
Save max-arnold/7c7ce5b780c84ed29c0815851c3805ea to your computer and use it in GitHub Desktop.
Salt extension development environment

Here is how I set up my extension development environment on Ubuntu 22.04:

git config --global user.name "Name"
git config --global user.email "[email protected]"
git clone [email protected]:USER/saltext-my.git
cd saltext-my
sudo apt install python3-venv python3-dev build-essential python3-wheel python3-wheel-whl
python3 -m venv .venv
source .venv/bin/activate
hash -r
pip install -e '.[tests,dev,docs]'
pre-commit install --install-hooks
mkdir -p .salt/etc/salt/master.d .salt/etc/salt/minion.d .salt/var/cache .salt/var/log
wget https://raw.githubusercontent.com/saltstack/salt/master/conf/minion -O .salt/etc/salt/minion
wget https://raw.githubusercontent.com/saltstack/salt/master/conf/master -O .salt/etc/salt/master
sed -i"" -e "s|#root_dir: /|root_dir: .salt/|" .salt/etc/salt/minion
sed -i"" -e "s|#root_dir: /|root_dir: .salt/|" .salt/etc/salt/master
sed -i"" -e "s|#user: root|user: $(whoami)|" .salt/etc/salt/master
# Saltfile

salt:
  config_dir: .salt/etc/salt/

salt-api:
  config_dir: .salt/etc/salt/

salt-master:
  config_dir: .salt/etc/salt/

salt-minion:
  config_dir: .salt/etc/salt/

salt-call:
  config_dir: .salt/etc/salt/

salt-key:
  config_dir: .salt/etc/salt/

salt-cp:
  config_dir: .salt/etc/salt/

salt-cloud:
  config_dir: .salt/etc/salt/

salt-run:
  config_dir: .salt/etc/salt/

salt-proxy:
  config_dir: .salt/etc/salt/

salt-ssh:
  ssh_priv: agent-forwarding
  config_dir: .salt/etc/salt/

salt-syndic:
  config_dir: .salt/etc/salt/

salt-unity:
  config_dir: .salt/etc/salt/

spm:
  config_dir: .salt/etc/salt/
# .salt/etc/salt/master.d/api.conf

netapi_enable_clients:
  - local
  - local_async
  - local_batch
  - local_subset
  - runner
  - runner_async
  - ssh
  - wheel
  - wheel_async

external_auth:
  auto:
    user:
      - .*
      - '@runner'
      - '@wheel'
      - '@jobs'

rest_cherrypy:
  port: 8000
  disable_ssl: true

After all of that you should be able to run:

  • salt-master
  • salt-call (or salt-call --local without a master)
  • salt-minion
  • salt-api -c .salt/etc/salt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment