Skip to content

Instantly share code, notes, and snippets.

@babs
Created March 3, 2023 09:50
Show Gist options
  • Save babs/b64e0d9850708bb42bde33bc8c58c50f to your computer and use it in GitHub Desktop.
Save babs/b64e0d9850708bb42bde33bc8c58c50f to your computer and use it in GitHub Desktop.
Initialize salt standalone
#/bin/bash
. /etc/os-release
curl -fsSL -o $target/usr/share/keyrings/salt-archive-keyring.gpg https://repo.saltproject.io/salt/py3/${ID}/${VERSION_ID}/amd64/latest/salt-archive-keyring.gpg
cat > $target/etc/apt/sources.list.d/salt-latest.list <<EOF
deb [signed-by=/usr/share/keyrings/salt-archive-keyring.gpg] http://repo.saltproject.io/salt/py3/${ID}/${VERSION_ID}/amd64/latest ${VERSION_CODENAME} main
EOF
apt update
apt install git python3-yaml salt-minion
mkdir -p {formulas,pillar,salt}
cat >minion <<EOF
file_client: "local"
file_roots:
base:
- ./salt/
pillar_roots:
base:
- ./pillar/
root_dir: ./
EOF
cat > salt-call.sh <<EOF
#!/bin/bash
salt-call -c ./ --local pillar="$(cat pillar.sls | python3 -c 'import yaml, json, sys; sys.stdout.write(json.dumps(yaml.safe_load(sys.stdin)))')" "$@"
EOF
chmod +x salt-call.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment