56 lines
1.4 KiB
YAML
56 lines
1.4 KiB
YAML
|
|
---
|
||
|
|
# Install NSSM on Windows - reusable role
|
||
|
|
|
||
|
|
- name: Create NSSM installation directory
|
||
|
|
ansible.windows.win_file:
|
||
|
|
path: "{{ nssm_install_dir }}"
|
||
|
|
state: directory
|
||
|
|
|
||
|
|
- name: Check if NSSM is already installed
|
||
|
|
ansible.windows.win_stat:
|
||
|
|
path: "{{ nssm_exe }}"
|
||
|
|
register: __nssm_check
|
||
|
|
|
||
|
|
- name: Download NSSM if not installed
|
||
|
|
ansible.windows.win_get_url:
|
||
|
|
url: "{{ nssm_zip_url }}"
|
||
|
|
dest: "{{ nssm_zip_path }}"
|
||
|
|
force: false
|
||
|
|
when: not __nssm_check.stat.exists
|
||
|
|
|
||
|
|
- name: Extract NSSM if not installed
|
||
|
|
community.windows.win_unzip:
|
||
|
|
src: "{{ nssm_zip_path }}"
|
||
|
|
dest: "{{ nssm_install_dir }}"
|
||
|
|
delete_archive: false
|
||
|
|
creates: "{{ nssm_exe }}"
|
||
|
|
|
||
|
|
- name: Verify NSSM executable is present
|
||
|
|
ansible.windows.win_stat:
|
||
|
|
path: "{{ nssm_exe }}"
|
||
|
|
register: __nssm_stat
|
||
|
|
|
||
|
|
- name: Fail if NSSM executable is missing
|
||
|
|
ansible.builtin.fail:
|
||
|
|
msg: >-
|
||
|
|
nssm binary not found at {{ nssm_exe }}.
|
||
|
|
Check download/unzip and nssm_version.
|
||
|
|
when: not __nssm_stat.stat.exists
|
||
|
|
|
||
|
|
# - name: Add NSSM to PATH (user level)
|
||
|
|
# ansible.windows.win_path:
|
||
|
|
# name: Path
|
||
|
|
# elements:
|
||
|
|
# - "{{ nssm_install_dir }}\\nssm-{{ nssm_version }}\\win64"
|
||
|
|
# state: present
|
||
|
|
|
||
|
|
- name: Add NSSM to PATH (system level)
|
||
|
|
ansible.windows.win_path:
|
||
|
|
name: Path
|
||
|
|
elements:
|
||
|
|
- "{{ nssm_install_dir }}\\nssm-{{ nssm_version }}\\win64"
|
||
|
|
state: present
|
||
|
|
become: true
|
||
|
|
become_method: ansible.builtin.runas
|
||
|
|
become_user: SYSTEM
|