{{vars.var_prefix.var_name}}
base (replace var_prefix
and var_name
by the value used in the method defining the variable ).
snapshot
, name: data
, you can use for example {{vars.snapshots.data.OS_PROJECT_ID}}
.
Thank you for the tip.. I tried the variable dict and filled one like this:
Variable prefix: snapshot
Variable name: data
Value : OS_PROJECT_ID
now at the Directive level I have a parameter called "config" as TXT with:
klantnaam: test
OS_PROJECT_ID: 9417c7f023714f5f86a0193
volume: idv01-vol01
volume: idv01-vol02
volume: idv02-vol01
When I update and run the agent I get this error:
error: Error parsing JSON expression 'OS_PROJECT_ID': Unable to parse json data as object, unrecognized token beginning entry
Earlier, the rudder branch update from 6.0 to 6.1 worked well in rudder itself.
But the same for 6.2 doesn't work.
https://docs.rudder.io/rudder-by-example/current/system/update-rudder-agent-package.html
Any idea?
Bonjour Everyone.
I'm trying to do some templating with mustache and rudder. Basic stuff : custom nftables rules based off a json object in the node properties.
I'm, however, stuck on one part :
{{#vars.node.properties.ports_tcp}}
add rule ip filter INPUT tcp dport {{{.}}} ip daddr {{{vars.sys.ipv4[ens18]}}} accept # {{{@}}} CUSTOM
{{/vars.node.properties.ports_tcp}}
########UDP
{{#vars.node.properties.ports_udp}}
add rule ip filter INPUT udp dport {{{.}}} ip daddr {{{vars.sys.ipv4[{{{vars.sys.interfaces}}}]}}} accept # {{{@}}} CUSTOM
{{/vars.node.properties.ports_udp}}
#########
This iterates over the list of ports defined in the json, but I haven't managed to make it work dynamically (see the UDP part). Is there a way to get the interface name dynamically?
Cheers
sys.interfaces_data
variable (available with vars.sys.interfaces_data
containing the interfaces, with some statistics about them:{
"enp4s0": {
"device": "enp4s0",
"receive_bytes": "446377831179",
"receive_compressed": "0",
"receive_drop": "0",
"receive_errors": "0",
"receive_fifo": "0",
"receive_frame": "0",
"receive_multicast": "0",
"receive_packets": "492136556",
"transmit_bytes": "428200856331",
"transmit_compressed": "0",
"transmit_drop": "0",
"transmit_errors": "0",
"transmit_fifo": "0",
"transmit_frame": "0",
"transmit_multicast": "0",
"transmit_packets": "499195545"
},
"lo": {
"device": "lo",
"receive_bytes": "1210580426",
"receive_compressed": "0",
"receive_drop": "0",
"receive_errors": "0",
"receive_fifo": "0",
So, I've tried using jinja, but I don't understand something.
This is the template :
{#######TCP #}
{% for interface in vars.sys.interfaces %}
{% for port_tcp in vars.node.properties['ports_tcp'] %}
add rule ip filter INPUT tcp dport {{ port_tcp }} meta iifname {{interface}} accept # {{ port_tcp.key }} CUSTOM
{% endfor %}
{% endfor %}
This is the "ports_tcp" property :
{
"http": 80,
"https": 443
}
Why is it that "port_tcp", my iterator item, is a str (http) and not the value (80) ?
{% for port_name, port_tcp in vars.node.properties['ports_tcp'] %}
items()
. I will see how we can add it
Not really incorrect, but as you said, there is no mention of the .items().
I'd say that this section needs more examples, at least for me, its easier to understand with a given exemple than with a generic explanation.
I can provide the code I made for a dynamic firewall for NFtables based off a simple json entry in the node property if you feel it might be useful for future reference
Hey there i've got a little problem getting reports from my clients. As far as I see I get following errormassage on my server:
error: HailServer: ERROR, could not resolve '**'
error: Rudder agent was interrupted during execution by a fatal error Run with -i to see log messages.
I already tried:
checking firewall, running with -i ->nor results or errors
Have you got any suggestions?