Hi,
I'm trying to append new key-value pair in the existing yml (
*subcluster_to_subnet_map.yml) * file using combine. New values are
getting appended correctly but it's getting added without spaces.
I need help with adding 2 spaces in starting so that the indentation is
maintained. Please suggest how this can be achieved. (I don't want to use
lineinfile here)
Yaml file on which key-value pair should be added:*
subcluster_to_subnet_map.yml*
*subcluster_to_subnet_map: ee: ee-ci9-sc8 test: test-ci1-sc1*
* <<new value should have 2 spaces>>*
I'm using below code for this -
- name: append new subnet and subcluster values
set_fact:
subcluster_to_subnet_map: "{{ subcluster_to_subnet_map |
default({}) | combine ({input_subcluster: input_subnet}) }}"
- debug:
var: subcluster_to_subnet_map
- name: write var to file
copy:
content: "{{ subcluster_to_subnet_map | to_nice_yaml }}"
dest: environment/subcluster_to_subnet_map.yml
The output I'm getting now is -
subcluster_to_subnet_map:
ee: ee-ci9-sc8
test: test-ci1-sc1
*test1: infra-nodes*
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/80ee5278-ada8-498f-a412-0887e7d79717n%40googlegroups.com.