Score:1

Why running second time ansible.windows.win_package isn't working?

uz flag

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?

in flag
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?
uz flag
a new installation log file can be considered?
in flag
Possibly. It's worth a try.
uz flag
The additional feature - should add additional directory with its name "Engine" in the product folder. Can we use it in ```create_path``` key?
in flag
Yes, that's the purpose of `create_path`, to check if it exists. If not, your task should be executed.
uz flag
@GeraldSchneider I removed ```state``` and added ```creates_path``` key - It's working like a magic. thank you
Score:1
in flag

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"
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.