for loop in pillar state file

783 views
Skip to first unread message

Arun Rajendran

unread,
Oct 31, 2014, 4:08:46 AM10/31/14
to salt-...@googlegroups.com
I am using the following for loop in the pillar state file and it's does not return any output with 'salt '*' pillar.items apple' command and it is working fine without for loop with hardcode value. Is there any bug in using for loop in pillar state file? Also it is possible to import OS python module in pillar state file?


# pillar file for application
(% for appns in 'apple1','apple2' %}
include:
  - appconf.{{ appns }}
{% endfor %}

Florian Ermisch

unread,
Oct 31, 2014, 4:22:55 AM10/31/14
to salt-...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Hi Arun,

Check `salt '*' pillar.items _errors` because you will have salt complain about two 'include'-statements in there.

Just put the include above the loop and this part of your problem will be fixed.

Regards, 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

iQFTBAEBCgA9BQJUU0bWNhxGbG9yaWFuIEVybWlzY2ggPGZsb3JpYW4uZXJtaXNj
aEBhbHVtbmkudHUtYmVybGluLmRlPgAKCRAoI7w/vNtfZbHKB/4uwaCM9VvWleb6
/8TNDiFTbccskZJn+x5QBQ7QExt3c1XmXQwIyQ051MeAHug1XRNlUKSpeT6o811d
5pAJfz7HmIYNTAqj1zTTqPdulDEvhJAPTZARbf2zgyrxqGqcmBKwOOj/LE9Qd9qe
DJoP5rj4gB8vECinE6m5MHr1WoEl+QThWJW9L99s029K4ifC3+6By+RDeE7y4rWX
O+S8sVM9RvGuQ7hfrhFxNXCLy5pvKmIWVtyT2Z3PuouNBK0hkYsewsaGrLz4Xo/X
GK3CE0H4snGsiJ/EXpt7GRns6s4l+rax/aBDjQ6QI5O94fVV140+BZjbk29OKuCc
K0Q96hT3
=uexD
-----END PGP SIGNATURE-----

Arun Rajendran

unread,
Oct 31, 2014, 8:57:57 AM10/31/14
to salt-...@googlegroups.com, florian...@alumni.tu-berlin.de
Thanks Florian..its working fine now

Is it possible to import OS python module in pillar state file?

Arun Rajendran

unread,
Oct 31, 2014, 9:13:15 AM10/31/14
to salt-...@googlegroups.com, florian...@alumni.tu-berlin.de
I want to iterate through all the sls files in /srv/pillar/appconf and need to include it in top.sls file. To do this I guess I need to import python module...Is there any other way for this?

Paul Reinking

unread,
Oct 31, 2014, 9:59:46 AM10/31/14
to salt-...@googlegroups.com
I'm running into an issue with one of the nodes managed by salt and a
complete reinstall of the minion does not seem to help.
Does anyone has an idea of how I could further trouble shoot this issue?

[ERROR ] An un-handled exception was caught by salt's global exception
handler:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
4566: ordinal not in range(128)
Traceback (most recent call last):
File "/usr/bin/salt", line 10, in <module>
salt_main()
File "/usr/lib/python2.7/dist-packages/salt/scripts.py", line 135, in
salt_main
client.run()
File "/usr/lib/python2.7/dist-packages/salt/cli/__init__.py", line
140, in run
self._output_ret(ret, out)
File "/usr/lib/python2.7/dist-packages/salt/cli/__init__.py", line
155, in _output_ret
salt.output.display_output(ret, out, self.config)
File "/usr/lib/python2.7/dist-packages/salt/output/__init__.py", line
35, in display_output
display_data = get_printout(out, opts)(data).rstrip()
File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py",
line 44, in output
return _format_host(host, hostdata)[0]
File "/usr/lib/python2.7/dist-packages/salt/output/highstate.py",
line 200, in _format_host
return '\n'.join(hstrs), changed

Thanks

Elias Probst

unread,
Oct 31, 2014, 12:32:08 PM10/31/14
to salt-...@googlegroups.com
On 10/31/2014 02:59 PM, Paul Reinking wrote:
>
> I'm running into an issue with one of the nodes managed by salt and a
> complete reinstall of the minion does not seem to help.
> Does anyone has an idea of how I could further trouble shoot this issue?

Please don't hijack existing threads for new questions!
This mail was posted as response to the "for loop in pillar state file"
thread.

Thanks!

signature.asc

Colton Myers

unread,
Nov 19, 2014, 3:30:05 PM11/19/14
to salt-...@googlegroups.com, florian...@alumni.tu-berlin.de
Hey Arun,

Sorry for the late reply, I'm catching up on old threads.

If you want the full power of python in your pillar generation, I would recommend you write an external pillar module:


Hope that helps!

--
Colton Myers
Platform Engineer, SaltStack
@basepi on Github/Twitter/IRC
signature.asc

Colton Myers

unread,
Nov 19, 2014, 3:31:16 PM11/19/14
to salt-...@googlegroups.com
Paul,

Gah, I hate those stupid unicode errors! They can be a beast to track down, because they're often caused by the environment, rather than salt directly.

I would recommend filing an issue on Github so we can track it.

--
Colton Myers
Platform Engineer, SaltStack
@basepi on Github/Twitter/IRC

signature.asc
Reply all
Reply to author
Forward
0 new messages