Discussion:
[salt-users] Jinja advanced debugging
Pim Jeursen
2017-11-09 08:31:49 UTC
Permalink
Hi there,

So I recently got to play with Saltstack again, and ran into an annoying
issue.
I have a Jinja file that serves as a check_mk config file, so Saltstack
minions are automatically added to Check_mk and monitored. Works great
except for the following:

{% if ip == '127.0.0.1' or '0.0.0.0' in ip or '10.20.118' in ip or
'172.16.' in ip or '169.254' in ip or '10.220.10' in ip -%}


This rule is in the file 3 times, first the variable is set using the
default ip address([ipv4][0]).
If the above rule matches a ip it sets the ip variable to: ([ipv4][1]).
Then it checks again, and if a match is found i goes to ([ipv4][2])

Now there is a host which has one of the matching ip's on nic1 and nic2,
but doesn't have a nic3 configured. So Salt doesn't generate the config
file and exits with a error.
Is there a way to generate extra logging to see what hosts causes the
issue. Or do i need to manually search vmware for the troubling vm?

Thanks in advance.
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/salt-users/0b649755-3e62-4a0f-a0dd-97960846d4b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
'Mircea Ulinic' via Salt-users
2017-11-09 15:57:20 UTC
Permalink
I’m not sure if you’ve seen the new logging module in Nitrogen, which you can invoke directly from Jinja to push messages into the Minion logs (or Master, depending where you execute the code from):

https://docs.saltstack.com/en/latest/topics/jinja/index.html#logs <https://docs.saltstack.com/en/latest/topics/jinja/index.html#logs>

Basically it’s almost the same as you’d log in a Python script:

{%- do salt.log.debug(’this is my IP: ‘ ~ ip) %}

For your checks, you may find this filter useful too: https://docs.saltstack.com/en/latest/topics/jinja/index.html#is-ipv4 <https://docs.saltstack.com/en/latest/topics/jinja/index.html#is-ipv4>
Post by Pim Jeursen
Hi there,
So I recently got to play with Saltstack again, and ran into an annoying issue.
{% if ip == '127.0.0.1' or '0.0.0.0' in ip or '10.20.118' in ip or
'172.16.' in ip or '169.254' in ip or '10.220.10' in ip -%}
This rule is in the file 3 times, first the variable is set using the default ip address([ipv4][0]).
If the above rule matches a ip it sets the ip variable to: ([ipv4][1]).
Then it checks again, and if a match is found i goes to ([ipv4][2])
Now there is a host which has one of the matching ip's on nic1 and nic2, but doesn't have a nic3 configured. So Salt doesn't generate the config file and exits with a error.
Is there a way to generate extra logging to see what hosts causes the issue. Or do i need to manually search vmware for the troubling vm?
Thanks in advance.
--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/salt-users/0b649755-3e62-4a0f-a0dd-97960846d4b7%40googlegroups.com <https://groups.google.com/d/msgid/salt-users/0b649755-3e62-4a0f-a0dd-97960846d4b7%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout <https://groups.google.com/d/optout>.
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/salt-users/C252005A-FD46-4ABB-BAEA-1DD25E6C5E6B%40cloudflare.com.
For more options, visit https://groups.google.com/d/optout.
Pim Jeursen
2017-11-14 08:15:13 UTC
Permalink
I'm running a older version of Saltstack which doesn't have the debug
option.
Is eventually fixed it by doing a
salt '*' grains.get ipv4 > /tmp/salt.txt

And searched for the servers with the issue, i found the servers and
removed them from salt (they don't belong in salt).
Everything is working fine know.
Post by 'Mircea Ulinic' via Salt-users
I’m not sure if you’ve seen the new logging module in Nitrogen, which you
can invoke directly from Jinja to push messages into the Minion logs (or
https://docs.saltstack.com/en/latest/topics/jinja/index.html#logs
{%- do salt.log.debug(’this is my IP: ‘ ~ ip) %}
https://docs.saltstack.com/en/latest/topics/jinja/index.html#is-ipv4
Hi there,
So I recently got to play with Saltstack again, and ran into an annoying issue.
I have a Jinja file that serves as a check_mk config file, so Saltstack
minions are automatically added to Check_mk and monitored. Works great
{% if ip == '127.0.0.1' or '0.0.0.0' in ip or '10.20.118' in ip or
'172.16.' in ip or '169.254' in ip or '10.220.10' in ip -%}
This rule is in the file 3 times, first the variable is set using the
default ip address([ipv4][0]).
If the above rule matches a ip it sets the ip variable to: ([ipv4][1]).
Then it checks again, and if a match is found i goes to ([ipv4][2])
Now there is a host which has one of the matching ip's on nic1 and nic2,
but doesn't have a nic3 configured. So Salt doesn't generate the config
file and exits with a error.
Is there a way to generate extra logging to see what hosts causes the
issue. Or do i need to manually search vmware for the troubling vm?
Thanks in advance.
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/salt-users/0b649755-3e62-4a0f-a0dd-97960846d4b7%40googlegroups.com
<https://groups.google.com/d/msgid/salt-users/0b649755-3e62-4a0f-a0dd-97960846d4b7%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/salt-users/9c14a1aa-9323-44d1-bd6e-e9fd312379a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...