From 0c02da2b128970990077e6b2a97ca33dd7f99774 Mon Sep 17 00:00:00 2001 From: Joseph Sirianni Date: Thu, 3 Aug 2023 14:22:46 -0400 Subject: [PATCH] feat: Add support for windows (#7) * add support for windows * remove todo * fix package url * add note about winrm * update repo paths for bindplane-agent * remove product id --- defaults/main.yml | 3 ++- docs/USAGE.md | 13 +++++++++++++ handlers/main.yml | 5 +++++ tasks/linux.yml | 10 +++++----- tasks/main.yml | 4 ++++ tasks/windows.yml | 27 +++++++++++++++++++++++++++ vars/main.yml | 3 ++- 7 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 tasks/windows.yml diff --git a/defaults/main.yml b/defaults/main.yml index 0eb7ca8..ea23007 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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" diff --git a/docs/USAGE.md b/docs/USAGE.md index 3c972c1..8e335d5 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -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 diff --git a/handlers/main.yml b/handlers/main.yml index 50225ef..abe6876 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -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 diff --git a/tasks/linux.yml b/tasks/linux.yml index 0ef0c92..99f3861 100644 --- a/tasks/linux.yml +++ b/tasks/linux.yml @@ -1,7 +1,7 @@ --- - name: Install RHEL package yum: - name: "{{ package_url }}" + name: "{{ linux_package_url }}" state: present disable_gpg_check: true when: @@ -10,7 +10,7 @@ - name: Install SUSE package zypper: - name: "{{ package_url }}" + name: "{{ linux_package_url }}" state: present disable_gpg_check: true when: @@ -19,7 +19,7 @@ - name: Install Debian package apt: - deb: "{{ package_url }}" + deb: "{{ linux_package_url }}" state: present when: - ansible_os_family == 'Debian' @@ -27,7 +27,7 @@ - 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 @@ -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 diff --git a/tasks/main.yml b/tasks/main.yml index fe501cf..efe13a8 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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'] diff --git a/tasks/windows.yml b/tasks/windows.yml new file mode 100644 index 0000000..0344a43 --- /dev/null +++ b/tasks/windows.yml @@ -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" diff --git a/vars/main.yml b/vars/main.yml index 93cd048..5828fd1 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -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"