How to define hash (dict) in ansible inventory file? -
i able define hash(dict) below in group_vars/all:
region_subnet_matrix: site1: region: "{{ aws_region }}" subnet: "subnet-xxxxxxx" zone: "{{aws_region}}a" site2: region: "{{ aws_region }}" subnet: "subnet-xxxxxxx" zone: "{{aws_region}}b" but life of me, not figure out how define under hosts file
[all:vars] region_subnet_matrix="{ site1: region: "{{ aws_region }}" subnet: "subnet-xxxxxxx" zone: "{{aws_region}}a" site2: region: "{{ aws_region }}" subnet: "subnet-xxxxxxx" zone: "{{aws_region}}b" }" i know incorrect, don't know right way. can enlighten me, please?
you can't use dict in inventory file because use ini format. preferred practice in ansible not store variables in main inventory file. host , group variables can stored in individual files relative inventory file.
assuming inventory file path is: /etc/ansible/hosts
if host named ‘testserver’ variables in yaml file @ following location made available host: /etc/ansible/host_vars/testserver.
the data in file might like:
region_subnet_matrix: site1: region: "{{ aws_region }}" subnet: "subnet-xxxxxxx" zone: "{{aws_region}}a" site2: region: "{{ aws_region }}" subnet: "subnet-xxxxxxx" zone: "{{aws_region}}b" read more here.
Comments
Post a Comment