Skip to content

Commit

Permalink
NR-164383 feat: assert version on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenruizdegauna committed Jan 8, 2024
1 parent d01b069 commit 161456c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
13 changes: 12 additions & 1 deletion caos.ansible_roles/roles/assert_version/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Assert application version.

```yaml
# Linux
- name: assert version
include_role:
name: caos.ansible_roles.assert_version
Expand All @@ -10,4 +11,14 @@ Assert application version.
version: "1.36.1"
- exec: "otelcol-contrib --version"
version: "0.70.0"
```

# Windows

- name: Assert version
include_role:
name: caos.ansible_roles.assert_version
vars:
target_versions:
- exec: '"C:\Program Files\New Relic\newrelic-infra\newrelic-infra.exe" "--version"'
version: "1.47.2"
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---

- name: Assert expected version
ansible.windows.win_command: '{{ item.exec }}'
register: check
loop: "{{ target_versions }}"

- name: Stdout from version grep
ansible.builtin.assert:
that: "{{ item.stdout | regex_search('([0-9\\.]+)', '\\1') | first == item.item.version }}"
fail_msg: "{{ item.stdout | regex_search('([0-9\\.]+)', '\\1') | first }} does not match {{ item.item.version }}"
loop: "{{ check.results }}"

...
5 changes: 5 additions & 0 deletions caos.ansible_roles/roles/assert_version/vars/main.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
---

# Linux
#target_versions:
# - exec: "/usr/bin/newrelic-infra --version"
# version: "1.34.0"
# Windows:
# - exec: "C:\Program Files\New Relic\newrelic-infra\newrelic-infra.exe" "--version"
# version: "1.34.0"
#
target_versions: []

...

0 comments on commit 161456c

Please sign in to comment.