Installing software in Ansible / AWX on Windows using ansible.windows.win_package and when criteria

47 Views Asked by At

I am trying install Visual C++ on windows using ansible / awx. I need to put a check in to confirm the version is lower before running. I use ansible.windows.win_reg_stat to get the bld.raw_value from registry. This is a 5 digit integer of the version number. Microsoft frequently releases visual c++ runtimes and vmtools used 32bit and 64bit runtime. However, during this deployment or release, Microsoft can release a newer runtime with a higher version number. I cannot use the software guid because a newer version would have a different guid. The code works win_package works when the 'when' is removed.

.

name:get reg value
ansible.windows.win_reg_stat:
  path: HKLM:\SOFTWARE\Wow6432node\Microsoft\VisualStudio\14.0\VC\Runtimes\x86
  name: Bld
register: Bld_x86

name: run visual c++
ansible.windows.win_package:
  path: "C:\\temp\\vcredist_x86.exe"
  state: present
  arguments:
    - /q
    - /norestart
 when: (Bld_x86.raw_value | int) < 32532

I am looking to either fix the 'when' criteria or find another way to perform an 'if'/'when' check for the win_package command

0

There are 0 best solutions below