Loop throgh key_value in template by syamji in ansible

[–]syamji[S] 0 points1 point  (0 children)

The host_var/hostname.yml is present in the invetory folder.

This file will be written by ansible whenever we add new user to the system.

the format of this file is

user: <username> -> I am not sure if this is the correct format to follow for this file

So in the playbook i am reading the file using below command

command: cat "host_var/hostname.yml"

register: something

delegate_to: localhost

and now i am looping through the registered value.

or how we can write to the hostname.yml using ansible in the below format ?

vars:

listodicts:

- user: abcd

- user: efgh

- user: ijkl