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

[#188360028] Role Rewrite #1

Closed
wants to merge 12 commits into from
11 changes: 2 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,20 @@ jobs:
include:
- distro: ubuntu-20.04
ansible_scenario: ansible_current
test_type: unit
python_version: '3.8'
experimental: false
- distro: ubuntu-20.04
ansible_scenario: ansible_next
test_type: unit
python_version: '3.8'
experimental: true
- distro: ubuntu-22.04
ansible_scenario: ansible_latest
test_type: unit
python_version: '3.10'
experimental: true

steps:
- uses: Rheinwerk/molecule@v3
- uses: Rheinwerk/molecule@main
with:
distro: ${{ matrix.distro }}
ansible_scenario: ${{ matrix.ansible_scenario }}
test_type: ${{ matrix.test_type }}
python_version: ${{ matrix.python_version }}


release:
name: Release
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ Example Playbook
- hosts: servers
vars:
OPS_TOOLS:
apt_repos:
- key_url: "https://s3.amazonaws.com/download.draios.com/DRAIOS-GPG-KEY.public"
repo_line: "deb http://download.draios.com/stable/deb stable-$(ARCH)/"
deb822_repository:
- name: elastic
types: deb
uris: https://artifacts.elastic.co/packages/8.x/apt
suites: stable
components: main
signed_by: https://artifacts.elastic.co/GPG-KEY-elasticsearch
tools:
- sysstat
- iotop
Expand Down
26 changes: 13 additions & 13 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
---

_ops_tools:
apt_repos:
- key_url: "https://s3.amazonaws.com/download.draios.com/DRAIOS-GPG-KEY.public"
repo_line: "deb http://download.draios.com/stable/deb stable-$(ARCH)/"
# credentials:
# base_name: "draios"
# machine: "download.draios.com"
# login: "username"
# password: "<password or empty string>"

# - ppa: "ppa:.../..."
# - key_id: abc321
# keyserver="keyserver.ubuntu.com"
tools:
# repo_credentials:
# base_name: "draios"
# machine: "download.draios.com"
# login: "username"
# password: "<password or empty string>"
deb822_repository:
- name: elastic
types: deb
uris: https://artifacts.elastic.co/packages/8.x/apt
suites: stable
components: main
signed_by: https://artifacts.elastic.co/GPG-KEY-elasticsearch
packages:
- iotop
- sysstat
- sysdig
Expand Down
151 changes: 0 additions & 151 deletions files/usr/local/bin/usereport.py

This file was deleted.

109 changes: 23 additions & 86 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,91 +1,28 @@
# vim: ft=ansible et ts=2
---
# tasks file for ops_tools

- name: Copy Ops Tools
- name: Add Repository Credentials
ansible.builtin.copy:
src: "{{ item }}"
dest: "/{{ item }}"
content: "machine {{ item.machine }} login {{ item.login }} password {{ item.password }}"
dest: "/etc/apt/auth.conf.d/{{ item.name }}.conf"
mode: "0640"
owner: root
group: root
mode: 0755
with_items:
- "usr/local/bin/usereport.py"

## Ubuntu

- name: Debian OS family tasks
when: ansible_distribution == 'Ubuntu' or ansible_distribution == 'Debian'
block:
- name: Add Repository Credentials
ansible.builtin.copy:
content: "machine {{ item.credentials.machine }} login {{ item.credentials.login }} password {{ item.credentials.password }}"
dest: "/etc/apt/auth.conf.d/{{ item.credentials.base_name }}.conf"
mode: "0640"
owner: root
group: root
when: item.credentials is defined
with_items: "{{ _ops_tools.apt_repos | default([]) }}"
register: new_credentials

- name: Add Repository Key by URL
ansible.builtin.apt_key:
url: "{{ item.key_url }}"
id: "{{ item.key_id | default(omit) }}"
state: present
when: item.key_url is defined
with_items: "{{ _ops_tools.apt_repos | default([]) }}"
register: new_keys_by_url

- name: Add Repository Key by ID
ansible.builtin.apt_key:
id: "{{ item.key_id }}"
keyserver: "{{ item.key_server | default('keyserver.ubuntu.com') }}"
state: present
when: item.key_id is defined
with_items: "{{ _ops_tools.apt_repos | default([]) }}"
register: new_keys_by_id

- name: Add Repositories URL
ansible.builtin.apt_repository:
repo: "{{ item.repo_line }}"
state: present
update_cache: no
when: item.repo_line is defined
with_items: "{{ _ops_tools.apt_repos | default([]) }}"
register: new_repos

- name: Add Repositories PPA
ansible.builtin.apt_repository:
repo: "{{ item.ppa }}"
state: present
update_cache: no
when: item.ppa is defined
with_items: "{{ _ops_tools.apt_repos | default([]) }}"
register: new_ppas

- name: Update APT Cache
ansible.builtin.apt:
update_cache: yes
when: new_keys_by_url is changed or new_keys_by_id is changed or new_repos is changed or new_ppas is changed or new_credentials is changed

- name: Install Ops Tools
ansible.builtin.apt:
state: present
name: "{{ _ops_tools.tools }}"

## ipkg
- name: IPKG tasks
when: ansible_cmdline.syno_hw_version is defined
block:
- name: Check if ipkg is installed
ansible.builtin.command: /opt/bin/ipkg --version
register: ipkg
check_mode: false
changed_when: false
failed_when: ipkg is failed

- name: Install Ops Tools
ansible.builtin.command: /opt/bin/ipkg install {{ item }}
with_items: "{{ _ops_tools.tools }}"
when: ipkg is success
when: item.name is defined
with_items: "{{ _ops_tools.repo_credentials | default([]) }}"

- name: Add Deb822 Repo
ansible.builtin.deb822_repository:
name: "{{ item.name }}"
types: deb
uris: "{{ item.uris }}"
suites: "{{ item.suites }}"
components: "{{ item.components }}"
signed_by: "{{ item.signed_by }}"
when: item.name is defined
with_items: "{{ _ops_tools.deb822_repository | default([]) }}"

- name: Install Packages
ansible.builtin.apt:
state: present
name: "{{ _ops_tools.packages }}"
update_cache: true
Loading