Skip to content

Commit 411b123

Browse files
s256Sebastian Noe
andauthored
Adapt Windows Package Installation to allow aws_ssm and other connection types (#84)
* adapt installation for aws_ssm / more connection types * install os provider for latest cnspec version(11) --------- Co-authored-by: Sebastian Noe <[email protected]>
1 parent 6b4b241 commit 411b123

File tree

2 files changed

+57
-3
lines changed

2 files changed

+57
-3
lines changed

defaults/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,7 @@ mondoo_rpm_gpgkey: "https://releases.mondoo.com/rpm/pubkey.gpg"
4646
# zypper repo
4747
mondoo_zypper_repo: "https://releases.mondoo.com/rpm/{{ ansible_userspace_architecture }}/"
4848
mondoo_zypper_gpgkey: "https://releases.mondoo.com/rpm/pubkey.gpg"
49+
50+
# download and transfer
51+
mondoo_download_path: /tmp/mondoo_cache/
52+
mondoo_tmp_windows: "{{ ansible_env.TEMP }}\\s1_install"

tasks/windows.yml

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# SPDX-License-Identifier: BUSL-1.1
33

44
---
5-
65
# download the latest json to fetch the latest released version
76

87
- name: Determine latest released version
@@ -31,15 +30,62 @@
3130
jmesquery: "files[*].filename | [?contains(@, 'arm64.msi')] | [0]"
3231
when: ansible_architecture2 | lower == 'arm64' and pkg_version_url is undefined
3332

33+
- name: Extract filename from the URL
34+
set_fact:
35+
pkg_filename: "{{ pkg_version_url | basename }}"
36+
3437
- name: Log latest version
3538
ansible.builtin.debug:
3639
var: pkg_version_url
3740

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+
3884
# download and install msi
3985
# we do register as part of the msi workflow to support reregistration more easily
4086
- name: Install Mondoo msi package
4187
ansible.windows.win_package:
42-
path: "{{ pkg_version_url }}"
88+
path: "{{ mondoo_pkg_path }}"
4389
state: present
4490

4591
- name: Get current cnspec version
@@ -48,11 +94,15 @@
4894
chdir: "C:\\Program Files\\Mondoo"
4995
register: cnspec_version
5096

97+
- name: Log Cnspec Version
98+
ansible.builtin.debug:
99+
var: cnspec_version
100+
51101
- name: Ensure we have the latest os provider installed
52102
ansible.windows.win_command: cnspec providers install os
53103
args:
54104
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.*")
56106

57107
- name: Logout cnquery and cnspec from Mondoo Platform
58108
ansible.windows.win_command: cnspec.exe logout --force --config C:\\ProgramData\\Mondoo\\mondoo.yml

0 commit comments

Comments
 (0)