How to write array in pillar?

67 views
Skip to first unread message

Alexandr Porunov

unread,
Jan 17, 2017, 11:13:24 AM1/17/17
to Salt-users
Hello,

I need to store an array of objects in pillar.
Help me please to figure out if it is possible.

Here is a JSON which I need to convert in pillar

nodes: [
  {
    ip: "192.168.0.1",
    port: 8080
  },
  {
    ip: "192.168.0.2",
    port: 443
  },
  {
    ip: "192.168.0.3",
    port: 8081
  }
]

I need to be able to get IP and ports from the array like these:
{{ salt['pillar.get']('nodes:[0]:ip') }}
{{ salt['pillar.get']('nodes:[0]:port') }}
{{ salt['pillar.get']('nodes:[1]:ip') }}
{{ salt['pillar.get']('nodes:[2]:port') }}

Best regards,
Alexandr

saltycdr

unread,
Jan 17, 2017, 11:44:01 AM1/17/17
to Salt-users
Hi Alexandr,



---
nodes:
- ip: 192.168.0.1
  port: 8080
- ip: 192.168.0.2
  port: 443
- ip: 192.168.0.3
  port: 8081

Alexandr Porunov

unread,
Jan 17, 2017, 11:54:08 AM1/17/17
to Salt-users
Nice tool!

Thank you very much for help!
Reply all
Reply to author
Forward
0 new messages