Convert PowerShell script to Ansible task

Hi,

I have to convert PowerShell Script (using if else condition) into anisble task.
How we can work with condition in ansible tasks.

Here is my powershell script.

$officeInstalled = Get-WmiObject win32_product | where { $_.Name -like “Microsoft Office*” } | select Name,Version

if ($officeInstalled -is [array])
{

https://docs.ansible.com/ansible/latest/user_guide/playbooks_conditionals.html