spuder
spuder

Reputation: 18417

How to apply a top file when using salt-ssh and roster file

I'm new to salt, and I'm trying to use salt-ssh to manage hosts. I have the following roster file

~/salt/roster

pi:
  host: raspberypi1.local
  tty: True
  sudo: True

I have salt states

~/salt/states/docker.sls

I am able to apply the salt states by calling the state explicitly

sudo salt-ssh '*' -c . state.apply docker

How can I make it so that I don't have to call the state directly? I want the raspberypi1.local node to always run the docker state.

Things I've tried

  1. Make ~/salt/top.sls
base:
  'pi*':
    - docker

However the top.sls appears to be ignored by salt-ssh

I've tried editing ~/salt/Saltfile to point at a specific file_roots

salt-ssh:
  roster_file: /Users/foobar/salt/roster
  config_dir: /Users/foobar/salt
  log_file: /Users/foobar/salt/log.txt
  ssh_log_file: /Users/foobar/salt/ssh-log.txt
  file_roots:
    base:
      - /Users/foobar/salt/top.sls

Here file_roots also appears to be ignored.

Whats the proper way to tie states to nodes when using salt-ssh?

Upvotes: 2

Views: 282

Answers (1)

spuder
spuder

Reputation: 18417

I moved ~/salt/top.sls to ~/salt/states/top.sls, and removed file_roots: entirely from the Saltfile (it belongs in the master file). And now I am able to apply states like so:

sudo salt-ssh '*' -c . state.apply

Upvotes: 1

Related Questions