4

I've got an sls file; the contents of which follow:

apache:
 pkg.installed:
    -name: apache2
 service.running:
   -enable: True
   - require:
     - pkg: apache

And I'm getting the error when trying to provision an Ubuntu Vagrant box with salt using the salt-master:

State 'apache' in SLS 'webserver' is not formed as a list

I've tried editing it and I've noticed that you can't have a chunk of code ending in a : but I can't see what's wrong with this.

The salt-master is running on an Ubuntu box and the key is accepted. I'm new to salt!

I've just put it through an on-line YAML parser and it seems to be okay. Wot is I missin'?

Adam Michalik
  • 9,678
  • 13
  • 71
  • 102
David Boshton
  • 2,555
  • 5
  • 30
  • 51

3 Answers3

5

I don't think you need the double space indent, mine works with single, but you do need a space after the dashes.

apache:
  pkg.installed:
    - name: apache2
  service.running:
    - enable: True
    - require:
      - pkg: apache
4

Looks like the spacing is wrong. You need a double "white space" not a single. Try this.

apache:
  pkg.installed:
    -name: apache2
  service.running:
    -enable: True
    - require:
      - pkg: apache
user257986
  • 41
  • 4
1

You may use the following: https://yamlvalidator.com/

Or with this one liner python:

python -c 'import yaml,sys;yaml.safe_load(sys.stdin)' < /srv/salt/state.sls
fboaventura
  • 173
  • 3
  • 7
Juan Medina
  • 134
  • 1
  • 4