Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt Windows Package Installation to allow aws_ssm and other connection types #84

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@ mondoo_rpm_gpgkey: "https://releases.mondoo.com/rpm/pubkey.gpg"
# zypper repo
mondoo_zypper_repo: "https://releases.mondoo.com/rpm/{{ ansible_userspace_architecture }}/"
mondoo_zypper_gpgkey: "https://releases.mondoo.com/rpm/pubkey.gpg"

# download and transfer
mondoo_download_path: /tmp/mondoo_cache/
mondoo_tmp_windows: "{{ ansible_env.TEMP }}\\s1_install"
56 changes: 53 additions & 3 deletions tasks/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# SPDX-License-Identifier: BUSL-1.1

---

# download the latest json to fetch the latest released version

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

- name: Extract filename from the URL
set_fact:
pkg_filename: "{{ pkg_version_url | basename }}"

- name: Log latest version
ansible.builtin.debug:
var: pkg_version_url

- name: Log Filename
ansible.builtin.debug:
var: pkg_filename

- name: Create working directory
ansible.builtin.file:
path: "{{ mondoo_download_path }}"
state: directory
mode: "0755"
delegate_to: localhost
run_once: true
become: false

- name: Set Mondoo Package variables
ansible.builtin.set_fact:
mondoo_pkg_src: "{{ mondoo_download_path }}/{{ pkg_filename }}"

- name: Download Mondoo Package
ansible.builtin.get_url:
url: "{{ pkg_version_url }}"
dest: "{{ mondoo_pkg_src }}"
mode: 440
register: url_result
until: url_result is not failed
retries: 3
delay: 10
delegate_to: localhost
become: false

- name: Set Monoo pkg path | Windows

Check warning on line 70 in tasks/windows.yml

View workflow job for this annotation

GitHub Actions / Run spell check

`Monoo` is not a recognized word. (unrecognized-spelling)
ansible.builtin.set_fact:
mondoo_pkg_path: "{{ mondoo_tmp_windows }}\\{{ pkg_filename }}"

- name: Create working directory | Windows
ansible.windows.win_file:
path: "{{ mondoo_tmp_windows }}"
state: directory

- name: Copy Mondoo Pkg | Windows
ansible.windows.win_copy:
src: "{{ mondoo_pkg_src }}"
dest: "{{ mondoo_pkg_path }}"

# download and install msi
# we do register as part of the msi workflow to support reregistration more easily
- name: Install Mondoo msi package
ansible.windows.win_package:
path: "{{ pkg_version_url }}"
path: "{{ mondoo_pkg_path }}"
state: present

- name: Get current cnspec version
Expand All @@ -48,11 +94,15 @@
chdir: "C:\\Program Files\\Mondoo"
register: cnspec_version

- name: Log Cnspec Version
ansible.builtin.debug:
var: cnspec_version

- name: Ensure we have the latest os provider installed
ansible.windows.win_command: cnspec providers install os
args:
chdir: "C:\\Program Files\\Mondoo"
when: not ansible_check_mode and cnspec_version.stdout is match(".*cnspec 9.*")
when: not ansible_check_mode and cnspec_version.stdout is match(".*cnspec 11.*")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: provider install/update would fail in an air-gapped environment as well


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