can you try to debug first and see whats returning

      - name: debug
        debug:
          msg: "{{ item['device_name'] }}"
        loop: "{{ ebs_volumes_list }}"

On Wed, Feb 2, 2022 at 10:50 PM Shivani Arora <[email protected]> wrote:

> Hi All,
>
> Looking for suggestions for above query.
>
> Thanks
>
> On Wednesday, February 2, 2022 at 4:52:35 PM UTC+5:30 Shivani Arora wrote:
>
>> Hi,
>>
>> I'm trying to create aws launch template using ansible module - "
>> community.aws.ec2_launch_template". I have different types of nodes and
>> want to map different volumes (according to node type) in the launch
>> template.
>>
>> For Core node - I'm trying to map 2 volumes (sdf and sdh) for which I'm
>> getting below error -
>>
>> * ansibleundefinedvariable 'str object' has no attribute 'device_name'*
>>
>>
>> My code looks like this -
>>
>> - name: Set ebs volumes
>>
>>   set_fact:
>>
>>     ebs_volumes_list:
>>
>>     - device_name: *sdf*
>>
>>       ebs:
>>
>>         volume_size: 10
>>
>>         delete_on_termination: yes
>>
>>         encrypted: yes
>>
>>         volume_type: gp3
>>
>>     - device_name:* sdh*
>>
>>       ebs:
>>
>>         volume_size: 10
>>
>>         delete_on_termination: yes
>>
>>         encrypted: yes
>>
>>         volume_type: io1
>>
>>         iops: 500
>>
>>   when: node_type == "Core"
>>
>>
>> - name: "Create Node launch template"
>>
>>   community.aws.ec2_launch_template:
>>
>>     template_name: "Test”
>>
>>     monitoring:
>>
>>       enabled: true
>>
>>     state: present
>>
>> *    block_device_mappings:*
>>
>> *     - device_name: "{{ item.device_name }}"*
>>
>> *       ebs: "{{ item.ebs}}”*
>>
>>
>>   loop: "{{ ebs_volumes_list }}"
>>
>> Ansible version -
>> ansible [core 2.12.1]
>> python version = 3.9.9 (main, Jan  5 2022, 11:59:43) [GCC 4.8.5 20150623
>> (Red Hat 4.8.5-44)]
>>
>>
>>
>> --
> 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/56cb91d7-5d54-4c18-9328-85ecccf28659n%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/56cb91d7-5d54-4c18-9328-85ecccf28659n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAE5Yv1SxoW3GsgrLaEJEjq8wKeJws%2BVD2d7k21OGN_swX_7A1g%40mail.gmail.com.

Reply via email to