use ansible to check if application is installed

Hey everyone,
writing a playbook to check if a package is installed on my windows system. if not run the installer from \Temp\software. and if already there, ignore. i have the command to run the installer but need to know how to check if the application is already installed

  • name: install SCCM
    win_package:
    path: c:\Temp\software\CLENT_2203\install.cmd
    state: present
    ingnor_errors: yes

The great thing about ansible is you are declaring an “end state”. After a task the system should look like the state you describe. In this case you want the state to be the your package is installed. In Ansible if the system is already in that state it does nothing. You don’t need to “check first”. You say you want the package installed. It checks. If it is installed, it does nothing. If it is not installed, it installs it.

The goal of every task is to achieve the state described in the task.

Walter

Thank you. this i will try and share feedback. thank you !