Hi Vladimir,

I have added* |list* and execute below task in ansible [core 2.11.12] but
no luck. Not getting where is stopping.

*Error:*

TASK [set_fact] *********************************
fatal: [10.250.198.160]: FAILED! => {}

MSG:

The task includes an option with an undefined variable. The error was:
'ansible.utils.unsafe_proxy.AnsibleUnsafeText object' has no attribute
'percent_complete'

The error appears to be in '/home/u630850/facts/netapp_volume_move.yml':
line 48, column 19, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

      - debug: var=variable_data
                  ^ here

There appears to be both 'k=v' shorthand syntax and YAML in this task. Only
one syntax may be used.

*Playbook as previously mentioned:*
     ---
- hosts: all
  connection: local
  gather_facts: false
  collections:
    - netapp.ontap
  vars:
    login: &login
      username: "{{ admin_username }}"
      password: "{{ admin_password }}"
      https: true
      validate_certs: false
      use_rest: Always
  tasks:
  - name: block section task
    block:
      - name: Volume move
        na_ontap_volume:
          <<: *login
          aggregate_name: "{{ aggregate_name }}"
          vserver: svm1
          name: vol1
          hostname: "{{ inventory_hostname }}"
        register: ontap_volume
        no_log: false
      - name: run ontap rest cli command to check volume move status
        netapp.ontap.na_ontap_rest_cli:
          <<: *login
          hostname: "{{ inventory_hostname }}"
          command: 'volume/move?fields=percent-complete,state'
          params:
            volume: '*'
            vserver: '*'
          verb: 'GET'
        register: variable_data








*- debug: var=variable_data   # output mentioned below      - set_fact:
           data_done: "{{ variable_data| selectattr('percent_complete',
'ne', 100)|list| length == 0}}"      - name: Retry a task until a certain
condition is met        debug:      # register:        until: data_done
    retries: 5        delay: 10*





*the output of "variable_data"*
*TASK [debug] ****************ok: [c*luster1] => {
    "variable_data": {
        "changed": true,
        "failed": false,
        "msg": {
            "num_records": 3,
            "records": [
                {
                    "percent_complete": 30,
                    "state": "done",
                    "volume": "vol1",
                    "vserver": "svm1"
                },
                {
                    "percent_complete": 98,
                    "state": "healthy",
                    "volume": "vol2",
                    "vserver": "svm1"
                },
                {
                    "percent_complete": 50,
                    "state": "done",
                    "volume": "vol1",
                    "vserver": "svm2"
                }
            ]
        }
    }
}


On Wed, Jun 21, 2023 at 5:59 PM Aharonu <[email protected]> wrote:

> Hi Vladimir,
>
> Thank you.
>
> I will check in higher version and update the status how it works.
>
> On Wed, 21 Jun 2023, 21:59 Vladimir Botka, <[email protected]> wrote:
>
>> On Wed, 21 Jun 2023 11:08:16 +0000
>> Aharonu <[email protected]> wrote:
>>
>> > The conditional check 'data_done' failed. The error was: Unexpected
>> > templating type error occurred on ({{ variable_data|
>> > selectattr('percent_complete', 'ne', 100) | length == 0 }}): object of
>> type
>> > 'generator' has no len()
>>
>> Add the explicit conversion to *list*
>>
>>   data_done: "{{ variable_data|
>>                  selectattr('percent_complete', 'ne', 100)|
>>                  list|length == 0 }}"
>>
>> This has already been fixed. If you can update the latest version.
>>
>> --
>> Vladimir Botka
>>
>

-- 
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/CANGEjuVydnsT_OEnSNe0i%3DeD006mipKzX38%3DGw%3D4wn6j__aMYQ%40mail.gmail.com.

Reply via email to