Cannot figure out how to use a formula without receiving 'The state "formula" in sls formula is not formed as a list'

828 views
Skip to first unread message

Chris Routh

unread,
Jul 1, 2015, 2:59:15 PM7/1/15
to salt-...@googlegroups.com
I've been banging my head off the docs and the 'pillar.example' files in the forumlas.

My understanding is I create something like 'pillar.sls' and include the config I want based on the pillar.example for each forumla, then from top add:

include:
  - formula


However not a single formula I've tried works for me. Every attempt I make at presenting a custom config for a formula results in the aforementioned error ('The state "formula" in sls formula is not formed as a list')

If I just use the include statement and present no pillar config, it works with the formulas default config.

How do I present the code in the pillar.example files to the pillar so they can be read? I've even just tried presenting the 'pillar.example' contents as is. 

For example with the SNMP formula.

Can someone present a working example with this formula? I'd like to get 1 formula working.

Florian Ermisch

unread,
Jul 1, 2015, 3:52:26 PM7/1/15
to salt-...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

1st: clone https://github.com/saltstack-formulas/mysql-formula to `/srv/salt/mysql-formula`

2nd: add ' - /srv/salt/mysql-formula' under
```
file_roots:
base:
```
in your master's /etc/salt/master

3rd: pick a minion you don't have mysql-server installed yet, I'll take "minion-a" here.

4th: Look into your master's config (see above) for the first entry under "base" in "pillar_roots". In this directory open `top.sls`.

5th: if the first line isn't "base:" add it

6th: below "base:" add
```
minion-a:
- mysql
```

7th: in the same dir as top.sls create a file "mysql.sls" containing the following:
```
mysql:
server:
root_password: 'I got my mysql-password from the README'
```

8th: run `salt '*' saltutil.refresh_pillar` and `salt minion-a pillar.items mysql` on your master. The output of the later one should contain the data from step 7.

9th: run `salt minion-a state.sls mysql.server` on your master

10th: on minion-a run `mysql -u root -p` and auth with the password you put into your pillar above to verify your use of the formula to deploy a MySQL-server.

Good luck, Florian
>--
>You received this message because you are subscribed to the Google
>Groups "Salt-users" group.
>To unsubscribe from this group and stop receiving emails from it, send
>an email to salt-users+...@googlegroups.com.
>For more options, visit https://groups.google.com/d/optout.
-----BEGIN PGP SIGNATURE-----
Version: APG v1.1.1

iQFTBAEBCAA9BQJVlETuNhxGbG9yaWFuIEVybWlzY2ggPGZsb3JpYW4uZXJtaXNj
aEBhbHVtbmkudHUtYmVybGluLmRlPgAKCRAu8tzCHoBI/eRkB/9dCHAYNrZCnK0Z
QCqRNQ3qQ3Knnjt/MqRbru8SzpyYMDuxyOpiQYj9SziHhyb7vcfkWGVoQtlUWvYP
GsTIgS9SFwYFwS49s621FeSl2675EGoTKLHmrMDALyR5o6/LEeDZ2noWIno0mQLg
RKpoWr244mkOhumNgHnsSuJoR6vLCWe3MU+JIxcO5xv1ezrKa5MNuVvFKV0vaEqp
DSoKysXuWqupPMiG5KTMVkRLDVF5hnGYQ0gA+xQHSfMF0HQrp1UUZmBiRItcmnfl
HIILGOBkLM0AVqV0L0z5ThHn71Q2D0M2+nV6wSswYsP78WWQ5GJ9Bybd3ULbNMAd
sRDw1f6E
=dLjw
-----END PGP SIGNATURE-----

Chris Routh

unread,
Jul 10, 2015, 7:12:52 AM7/10/15
to salt-...@googlegroups.com, florian...@alumni.tu-berlin.de
Hi Florian, 

Thanks for your response. So I have tried several things without luck.. now I am not using the MySQL formula as I do not have any MySQL databases, just Postgres. What I'm really interested in setting up as a first step with SaltStack is snmp for Shinken. So I followed your directions, with some small alterations. Everything looks good right up until step 9, where I run into the exact same issue yet again.

----------------------------------
My pillar_roots:

pillar_roots:
  base:
  - /srv/salt/base
  - /srv/formulas/ntp-formula
  - /srv/formulas/haveged-formula
  - /srv/formulas/salt-yum
  - /srv/formulas/epel-formula
  - /srv/formulas/snmp-formula
  dev:
  - /srv/salt/dev/services
  - /srv/salt/dev/states
  prod:
  - /srv/salt/prod/services
  - /srv/salt/prod/states
----------------------------------

My file_roots:

file_roots:
  base:
  - /srv/salt/base
  - /srv/formulas/ntp-formula
  - /srv/formulas/haveged-formula
  - /srv/formulas/salt-yum
  - /srv/formulas/epel-formula
  - /srv/formulas/snmp-formula
  dev:
  - /srv/salt/dev/services
  - /srv/salt/dev/states
  prod:
  - /srv/salt/prod/services
  - /srv/salt/prod/states
----------------------------------

My top.sls:

base:
  '*':
    - common
----------------------------------

My common.sls:

include:
  - ntp
  - haveged
  - snmp
----------------------------------

My snmp.sls:

snmp:
  lookup:
    snmpdargs: '-Lsd -Lf /dev/null -p /var/run/snmpd.pid -a'
    trapdargs: '-Lsd -p /var/run/snmptrapd.pid'
    trapdrun: 'no'
----------------------------------

Results of step 8 commands:

[root@saltmaster ~]# salt '*' saltutil.refresh_pillar
    None
    True
    True
    None

[root@saltmaster ~]# salt '*' pillar.items snmp
    ----------
    snmp:
        ----------
        lookup:
            ----------
            snmpdargs:
                -Lsd -Lf /dev/null -p /var/run/snmpd.pid -a
            trapdargs:
                -Lsd -p /var/run/snmptrapd.pid
            trapdrun:
                no
    ----------
    snmp:
        ----------
        lookup:
            ----------
            snmpdargs:
                -Lsd -Lf /dev/null -p /var/run/snmpd.pid -a
            trapdargs:
                -Lsd -p /var/run/snmptrapd.pid
            trapdrun:
                no
    ----------
    snmp:
        ----------
        lookup:
            ----------
            snmpdargs:
                -Lsd -Lf /dev/null -p /var/run/snmpd.pid -a
            trapdargs:
                -Lsd -p /var/run/snmptrapd.pid
            trapdrun:
                no
    ----------
    snmp:
        ----------
        lookup:
            ----------
            snmpdargs:
                -Lsd -Lf /dev/null -p /var/run/snmpd.pid -a
            trapdargs:
                -Lsd -p /var/run/snmptrapd.pid
            trapdrun:
                no
-----------------------------------------

AND last but not least, the failure at step 9:

[root@saltmaster ~]# salt '*' state.sls snmp
    Data failed to compile:
----------
    The state "snmp" in sls snmp is not formed as a list
    Data failed to compile:
----------
    The state "snmp" in sls snmp is not formed as a list
    Data failed to compile:
----------
    State 'snmp' in SLS 'snmp' is not formed as a list
    Data failed to compile:
----------
    State 'snmp' in SLS 'snmp' is not formed as a list


I really don't understand what is wrong here. I've followed the guides and I believe my syntax and structure is correct for the arch I want to achieve with Salt.. yet I continuously run up against this wall.

James O'Neill

unread,
Jul 11, 2015, 11:11:08 AM7/11/15
to salt-...@googlegroups.com, florian...@alumni.tu-berlin.de
Hi Chris,

Your pillar_roots looks completely wrong. Pillar files do not go into your state or formula directories. You should have a directory structure like this:

- srv
 - salt
  - formulas
   - mysql-formula
  - pillars
   - top.sls
   - mysqlstuff.sls
  - states
   - top.sls

Regards,
James

Reply all
Reply to author
Forward
0 new messages