1

I have a product that I can install it first, then update it - meaning to add more feature to my base product

I do it by execute the MSI first time, then going to Add \ Remove Programs and when selecting the product, you can click "Change" and the Installation Wizard would shown up again, allowing you to select and install additional feature in the product

I created 2 ansible roles and playbooks for this mission First role uses ansible.windows.win_package to install the base product (see below example)

- name: Install Server.msi primary_appserver
  ansible.windows.win_package:
    path: C:\product.msi
    log_path: C:\InstallProduct.log
    arguments:
     ADDLOCAL=DB,Agent
    state: present
  become: true
  become_method: runas
  vars:
    ansible_become_user: "{{ ansible_user }}"
    ansible_become_password: "{{ ansible_password }}"
  when: "'primary_appservers' in group_names"

Second role uses ansible.windows.win_package again with different ADDLOCAL arguments (the additional features):

- name: Install Engine primary_appserver
  ansible.windows.win_package:
    path: C:\product.msi
    log_path: C:\InstallEngine.log
    arguments:
     ADDLOCAL=Engine
    state: present
  become: true
  become_method: runas
  vars:
    ansible_become_user: "{{ ansible_user }}"
    ansible_become_password: "{{ ansible_password }}"
  when: "'primary_appservers' in group_names"

First role is work fine and executes the msi file, The second one - not If I do those two tasks, with CLI, msiexec /i it's work fine So, Why it is not working when performing ansible.windows.win_package?

6
  • My guess would be the state: present. It is already present, so there is no need to run it again. Is there any file/folder or service you can check for with creates_path or creates_service that is only created by the second run? Jan 26, 2022 at 8:59
  • a new installation log file can be considered?
    – Hiddai
    Jan 26, 2022 at 9:59
  • Possibly. It's worth a try. Jan 26, 2022 at 10:01
  • The additional feature - should add additional directory with its name "Engine" in the product folder. Can we use it in create_path key?
    – Hiddai
    Jan 26, 2022 at 10:12
  • 1
    Yes, that's the purpose of create_path, to check if it exists. If not, your task should be executed. Jan 26, 2022 at 10:15

1 Answer 1

1

This problem is most probably the state: present parameter, since the package is already present when the task is run. Instead you can use the creates_path or creates_service params to check if it is needed to install the package.

Example:

- name: Install Engine primary_appserver
  ansible.windows.win_package:
    path: C:\product.msi
    log_path: C:\InstallEngine.log
    arguments:
    ADDLOCAL=Engine
    creates_path: "C:\Path\to\product\folder"
  become: true
  become_method: runas
  vars:
    ansible_become_user: "{{ ansible_user }}"
    ansible_become_password: "{{ ansible_password }}"
  when: "'primary_appservers' in group_names"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .