Help with Conditions

Hi All,

Just wondering is their a better way of doing the Following?

`

`

I would use vars to simplify the tasks themselves, alternatively you
could use a block to establish the common condition

- name: run when not powered off
   vmware_guest_powerstate:
           hostname: '{{ mdb_console.json.0[resolved_name]}}'
           ...
  vars:
       powerstate: '{{ (json_file.stdout | from_json).power_state}}'
       console_defined : '{{ mdb_console.json.0['console'] is defined}}'
       resolved_name: '{{ console_defined|ternary("console", "vconsole")}}'
  when: 'powerstate != "poweredOff"'