1

Apologies if the question is really simple, still learning and was not able to locate the exact answer of what I was after for.

I have the following Dictionary:

guests:
  small:
     name: small-{{ rand_gb_var }}
     mem: 1024
     cpus: 1
     os_type: rhel7
     file_type: qcow2
  large:
     name: large-{{ rand_gb_var }}
     mem: 2048
     cpus: 2
     os_type: rhel7
     file_type: qcow2
  XL:
     name: small-{{ rand_gb_var }}
     mem: 4096
     cpus: 4
     os_type: rhel7
     file_type: qcow2

and I am trying to ONLY access the small key and it's values one task at a time and don't want to go through the whole dictionary every time my task runs.

The task that I am running is:

- name: create disk
  command: >
           virt-builder --format qcow2 centos-7.4
           -o {{ vm_location }}/{{ guests.small.name }}.{{ 
           guests.small.file_type }}
           --root-password password:{{ root_pass }}
  when: guests.small.name  not in disks.stdout
  with_items: '{{ guests.keys() }}'

However, this appears to be looping through all of the keys and only the 'small' one.

Thank you a lot!

1 Answer 1

1

Just remove with_items: '{{ guests.keys() }}' . There is no item used.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .