use ansible to check if application is installed

1,028 views
Skip to first unread message

Nestor

unread,
Jan 4, 2023, 8:24:23 PM1/4/23
to Ansible Project
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

Rowe, Walter P. (Fed)

unread,
Jan 5, 2023, 7:14:44 AM1/5/23
to ansible...@googlegroups.com
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
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

--
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 ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/0bbf03f5-d935-41df-ae0b-c85043a3e195n%40googlegroups.com.

Nestor

unread,
Jan 6, 2023, 1:14:15 AM1/6/23
to Ansible Project
Thank you. this i will try and share feedback. thank you !
Reply all
Reply to author
Forward
0 new messages