|
2 | 2 | # SPDX-License-Identifier: BUSL-1.1
|
3 | 3 |
|
4 | 4 | ---
|
5 |
| - |
6 | 5 | # download the latest json to fetch the latest released version
|
7 | 6 |
|
8 | 7 | - name: Determine latest released version
|
|
31 | 30 | jmesquery: "files[*].filename | [?contains(@, 'arm64.msi')] | [0]"
|
32 | 31 | when: ansible_architecture2 | lower == 'arm64' and pkg_version_url is undefined
|
33 | 32 |
|
| 33 | +- name: Extract filename from the URL |
| 34 | + set_fact: |
| 35 | + pkg_filename: "{{ pkg_version_url | basename }}" |
| 36 | + |
34 | 37 | - name: Log latest version
|
35 | 38 | ansible.builtin.debug:
|
36 | 39 | var: pkg_version_url
|
37 | 40 |
|
| 41 | +- name: Log Filename |
| 42 | + ansible.builtin.debug: |
| 43 | + var: pkg_filename |
| 44 | + |
| 45 | +- name: Create working directory |
| 46 | + ansible.builtin.file: |
| 47 | + path: "{{ mondoo_download_path }}" |
| 48 | + state: directory |
| 49 | + mode: "0755" |
| 50 | + delegate_to: localhost |
| 51 | + run_once: true |
| 52 | + become: false |
| 53 | + |
| 54 | +- name: Set Mondoo Package variables |
| 55 | + ansible.builtin.set_fact: |
| 56 | + mondoo_pkg_src: "{{ mondoo_download_path }}/{{ pkg_filename }}" |
| 57 | + |
| 58 | +- name: Download Mondoo Package |
| 59 | + ansible.builtin.get_url: |
| 60 | + url: "{{ pkg_version_url }}" |
| 61 | + dest: "{{ mondoo_pkg_src }}" |
| 62 | + mode: 440 |
| 63 | + register: url_result |
| 64 | + until: url_result is not failed |
| 65 | + retries: 3 |
| 66 | + delay: 10 |
| 67 | + delegate_to: localhost |
| 68 | + become: false |
| 69 | + |
| 70 | +- name: Set Monoo pkg path | Windows |
| 71 | + ansible.builtin.set_fact: |
| 72 | + mondoo_pkg_path: "{{ mondoo_tmp_windows }}\\{{ pkg_filename }}" |
| 73 | + |
| 74 | +- name: Create working directory | Windows |
| 75 | + ansible.windows.win_file: |
| 76 | + path: "{{ mondoo_tmp_windows }}" |
| 77 | + state: directory |
| 78 | + |
| 79 | +- name: Copy Mondoo Pkg | Windows |
| 80 | + ansible.windows.win_copy: |
| 81 | + src: "{{ mondoo_pkg_src }}" |
| 82 | + dest: "{{ mondoo_pkg_path }}" |
| 83 | + |
38 | 84 | # download and install msi
|
39 | 85 | # we do register as part of the msi workflow to support reregistration more easily
|
40 | 86 | - name: Install Mondoo msi package
|
41 | 87 | ansible.windows.win_package:
|
42 |
| - path: "{{ pkg_version_url }}" |
| 88 | + path: "{{ mondoo_pkg_path }}" |
43 | 89 | state: present
|
44 | 90 |
|
45 | 91 | - name: Get current cnspec version
|
|
48 | 94 | chdir: "C:\\Program Files\\Mondoo"
|
49 | 95 | register: cnspec_version
|
50 | 96 |
|
| 97 | +- name: Log Cnspec Version |
| 98 | + ansible.builtin.debug: |
| 99 | + var: cnspec_version |
| 100 | + |
51 | 101 | - name: Ensure we have the latest os provider installed
|
52 | 102 | ansible.windows.win_command: cnspec providers install os
|
53 | 103 | args:
|
54 | 104 | chdir: "C:\\Program Files\\Mondoo"
|
55 |
| - when: not ansible_check_mode and cnspec_version.stdout is match(".*cnspec 9.*") |
| 105 | + when: not ansible_check_mode and cnspec_version.stdout is match(".*cnspec 11.*") |
56 | 106 |
|
57 | 107 | - name: Logout cnquery and cnspec from Mondoo Platform
|
58 | 108 | ansible.windows.win_command: cnspec.exe logout --force --config C:\\ProgramData\\Mondoo\\mondoo.yml
|
|
0 commit comments