*This is an Ansible question *
Here is my list:
userdata.list:
- ClassType: Full Time
FirstName: Grace
LastName: Higgins
Username: g.higgins
- ClassType: Part Time
FirstName: Robert
LastName: Miller
Username: robmil
- ClassType: Flexi
FirstName: Jeffrey
LastName: Keller
Username: jeff.k
I want to append the following values to the existing list, looping for each user:
EmailAddress: {{ Username }} append to @gmail.com
OtherAddresses: primary:{{ Username }}@gmail.com,secondary:{{ Username }}@outlook.com
Registered: Yes
Expected output:
userdata.list:
- ClassType: Full Time
FirstName: Grace
LastName: Higgins
Username: g.higgins
EmailAddress: g.higgins@gmail.com
OtherAddresses: primary:g.higgins@gmail.com,secondary:g.higgins@outlook.com
Registered: Yes
- ClassType: Part Time
FirstName: Robert
LastName: Miller
Username: robmil
EmailAddress: robmil@gmail.com
OtherAddresses: primary:robmil@gmail.com,secondary:robmil@outlook.com
Registered: Yes
- ClassType: Flexi
FirstName: Jeffrey
LastName: Keller
Username: jeff.k
EmailAddress: jeff.k@gmail.com
OtherAddresses: primary:jeff.k@gmail.com,secondary:jeff.k@outlook.com
Registered: Yes
How do I create the dictionary to append the three new key: values, and loop for each user to produce the above output?
This is my current playbook:
- hosts: localhost
tasks:
- read_csv:
path: /var/lib/awx/projects/file/creation.csv
# key: FirstName
fieldnames: FirstName,LastName,ClassType
delimiter: ,
register: userdata
- debug:
var: userdata.list