Skip to content

Commit

Permalink
feat: Add support for windows (#7)
Browse files Browse the repository at this point in the history
* add support for windows

* remove todo

* fix package url

* add note about winrm

* update repo paths for bindplane-agent

* remove product id
  • Loading branch information
jsirianni authored Aug 3, 2023
1 parent a571639 commit 0c02da2
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 7 deletions.
3 changes: 2 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ insecure_skip_verify: false

package_type: "{{ 'rpm' if ansible_os_family in ['RedHat', 'Suse'] else 'deb' }}"
arch: "{{ 'arm64' if ansible_architecture in ['arm64', 'aarch64'] else 'amd64' }}"
package_url: "https://github.com/observIQ/observiq-otel-collector/releases/download/v{{ version }}/observiq-otel-collector_v{{ version }}_linux_{{ arch }}.{{ package_type }}"
linux_package_url: "https://github.com/observIQ/bindplane-agent/releases/download/v{{ version }}/observiq-otel-collector_v{{ version }}_linux_{{ arch }}.{{ package_type }}"
windows_package_url: "https://github.com/observIQ/bindplane-agent/releases/download/v{{ version }}/observiq-otel-collector.msi"
13 changes: 13 additions & 0 deletions docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ Your directory stucture should look like this:
└── site.yml
```

**Windows**

Windows targets must have `winrm` properly configured. See the
[Ansible Documentation](https://docs.ansible.com/ansible/latest/os_guide/windows_setup.html)
for proper configuration.

To get started quickly for testing purposes only, you can run the following commands
to configure winrm quickly, but in an insecure way:
```ps
winrm set winrm/config/service/auth '@{Basic="true"}'
winrm set winrm/config/service '@{AllowUnencrypted="true"}'
```

## Basic Example

This example assumes you have a BindPlane OP instance at the endpoint
Expand Down
5 changes: 5 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@
state: restarted
daemon_reload: true
enabled: yes

- name: "restart windows service"
win_service:
name: "observIQ Distro for OpenTelemetry Collector"
state: restarted
10 changes: 5 additions & 5 deletions tasks/linux.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
- name: Install RHEL package
yum:
name: "{{ package_url }}"
name: "{{ linux_package_url }}"
state: present
disable_gpg_check: true
when:
Expand All @@ -10,7 +10,7 @@

- name: Install SUSE package
zypper:
name: "{{ package_url }}"
name: "{{ linux_package_url }}"
state: present
disable_gpg_check: true
when:
Expand All @@ -19,15 +19,15 @@

- name: Install Debian package
apt:
deb: "{{ package_url }}"
deb: "{{ linux_package_url }}"
state: present
when:
- ansible_os_family == 'Debian'
notify: "restart systemd service"

- name: Check if manager configuration exists
stat:
path: "{{ manager_path }}"
path: "{{ linux_manager_path }}"
register: manager

# Deploy initial manager configuration if it does not exist. BindPlane
Expand All @@ -37,7 +37,7 @@
when: manager.stat.exists == False
template:
src: "manager.yaml.tmpl"
dest: "{{ manager_path }}"
dest: "{{ linux_manager_path }}"
owner: observiq-otel-collector
group: observiq-otel-collector
mode: 0640
Expand Down
4 changes: 4 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@
- name: Call Linux specific playbook
include_tasks: linux.yml
when: ansible_os_family in ['Debian', 'RedHat', 'Suse']

- name: Call Windows specific playbook
include_tasks: windows.yml
when: ansible_os_family in ['Windows']
27 changes: 27 additions & 0 deletions tasks/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
- name: Install MSI package
ansible.windows.win_package:
path: "{{ windows_package_url }}"
# Install without opamp. OpAMP will be configured when the manager
# configuration is deployed.
arguments:
- /quiet
- ENABLEMANAGEMENT=0
wait_for_children: true
state: present

- name: Check if manager configuration exists
win_stat:
path: "{{ windows_manager_path }}"
register: manager

# Deploy initial manager configuration if it does not exist. BindPlane
# will push updates to the manager configuration, therefor Ansible
# cannot maintain it's state.
- name: Create initial manager configuration
when: manager.stat.exists == False
template:
src: "manager.yaml.tmpl"
dest: "{{ windows_manager_path }}"
mode: 0640
notify: "restart windows service"
3 changes: 2 additions & 1 deletion vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
---
manager_path: /opt/observiq-otel-collector/manager.yaml
linux_manager_path: "/opt/observiq-otel-collector/manager.yaml"
windows_manager_path: "C:/Program Files/observIQ OpenTelemetry Collector/manager.yaml"

0 comments on commit 0c02da2

Please sign in to comment.