Ansible output jinja2 loop to a different files

Shiraz_Kamal
Tue, 29 Apr 2025 18:29:13 +0000
Get Help

I have the following in my vars file.

aux:                "SHR"
cluster_nodes:
- { node_name: sudora123a, node_num: 1, inst_num: "123A" }
- { node_name: sudora123b, node_num: 2, inst_num: "123B" }

I am trying to loop through each node_name and write out to different files.

My template:

  (SID_LIST =
                (SID_NAME = {{ aux }}{{ cn.inst_num }})
        )
  )

I would like to have 2 different files created to have outputs like this.
file1.out

  (SID_LIST =
                (SID_NAME =SHR123A)
        )
  )

file2.out

  (SID_LIST =
                (SID_NAME =SHR123B)
        )
  )

4 posts - 3 participants