2
votes

I am trying to install salt minion from master using salt ssh

This is my sls file

salt-minion:
  pkgrepo:
    - managed
    - ppa: saltstack/salt
    - require_in:
      - pkg: salt-minion
  pkg.installed:
    - version: 2015.5.3+ds-1trusty1
  service:
    - running
    - watch:
      - file: /etc/salt/minion
      - pkg: salt-minion

/etc/salt/minion:
  file.managed:
    - source: salt://minion/minion.conf
    - user: root
    - group: root
    - mode: 644

And this my roster file

minion3:        
    host: 192.168.33.103                            
    user: vagrant                
    passwd: vagrant    
    sudo: True

My problem is that when I run

sudo salt-ssh -i '*' state.sls

I get this error

      ID: salt-minion
Function: service.running
  Result: False
 Comment: One or more requisite failed: install_minion./etc/salt/minion
 Started:
Duration:
 Changes: 

Strangely it works fine when I run it for the second time.

Any pointers to what I am doing wrong would be very helpful.

2

2 Answers

1
votes

When installing salt on a machine via SSH you might want to look at the Salt's saltify module.

It will connect to a machine using SSH, run a bootstrap method, and register the new minion with the master. By default it runs the standard Salt bootstrap script, but you can provide your own.

I have a similar setup running in my Salt/Consul example here. This was originally targeted at DigitalOcean, but it also works with Vagrant (see cheatsheet.adoc for more information). A vagrant up followed by a salt-cloud -m mapfile-vagrant.yml will provision all minion using ssh.

0
votes

Solved it.

The state file should be like this:

salt-minion:
  pkgrepo:
    - managed
    - ppa: saltstack/salt
    - require_in:
      - pkg: salt-minion
  pkg.installed:
    - version: 2015.5.3+ds-1trusty1

/etc/salt/minion:
  file.managed:
    - template: jinja
    - source: salt://minion/files/minion.conf.j2
    - user: root
    - group: root
    - mode: 644

salt-minion_watch:
  service:
    - name: salt-minion
    - running
    - enable: True
    - restart: True
    - watch:
      - file: /etc/salt/minion
      - pkg: salt-minion

This is working for me. Though I am not clear on the reason.