Skip to content

Commit

Permalink
Merge pull request #49 from tribe29/devel
Browse files Browse the repository at this point in the history
Add agent role
  • Loading branch information
robin-checkmk authored May 23, 2022
2 parents c5cc49b + f44e426 commit f3c1e31
Show file tree
Hide file tree
Showing 22 changed files with 453 additions and 14 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ansible-integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ on:
- 'changelogs/**'
- '**.md'
- '**.rst'
- 'roles/**'

env:
NAMESPACE: tribe29
Expand Down
42 changes: 36 additions & 6 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ jobs:
runs-on: ubuntu-latest

steps:

#
# Prepare the environment.
#

- name: Checkout code
uses: actions/checkout@v2

Expand All @@ -25,9 +30,31 @@ jobs:
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
#
# First stage: Build and install collection to generate docs and changelogs.
#

- name: Copy Files and Directories to Source
run: |
mkdir -p build/src
cp $files build/src
cp -rf $directories build/src
env:
files: "CHANGELOG.rst LICENSE README.md ansible.cfg galaxy.yml"
directories: "changelogs docs meta playbooks plugins roles"

- name: Build Ansible Collection
run: ansible-galaxy collection build build/src --force

- name: Install Ansible Collection
run: ansible-galaxy collection install ./tribe29-checkmk-${{ steps.current_version.outputs.version }}.tar.gz

- name: Compile Collection Changelog
run: antsibull-changelog release

- name: Compile Collection Docs
run: antsibull-docs collection --use-current --squash-hierarchy --fail-on-error --dest-dir ./docs/ tribe29.checkmk

# https://github.com/marketplace/actions/create-pull-request
- name: Create Pull Request for docs
uses: peter-evans/create-pull-request@v3
Expand All @@ -36,24 +63,27 @@ jobs:
committer: GitHub <[email protected]>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
signoff: false
branch: changelogs-update
branch: changelogs-docs-update
delete-branch: true
title: '[Auto] Update changelogs'
title: '[Auto] Update changelogs and docs'
body: |
Changelogs updated during *${{ steps.current_version.outputs.version }}* release.
Changelogs and docs updated during *${{ steps.current_version.outputs.version }}* release.
assignees: robin-tribe29
reviewers: robin-tribe29
draft: false

#
# Second stage: Build the final version of the collection and release it.
#

- name: Copy Files and Directories to Source
run: |
mkdir -p build/src
cp $files build/src
cp -rf $directories build/src
env:
files: "CHANGELOG.rst LICENSE README.md ansible.cfg galaxy.yml"
# directories: "playbooks plugins roles vars"
directories: "changelogs docs meta playbooks plugins"
directories: "changelogs docs meta playbooks plugins roles"

- name: Build Ansible Collection
run: ansible-galaxy collection build build/src --force
Expand All @@ -65,7 +95,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.current_version.outputs.version }}
release_name: Release v${{ steps.current_version.outputs.version }}
release_name: v${{ steps.current_version.outputs.version }}
body: |
# Ansible Collection: tribe29.checkmk
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
.*.swp
.*.swo
*~
.vagrant/
build/
tests/output
playbooks/vars/config.yml
playbooks/test.yml
92 changes: 87 additions & 5 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,40 @@
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.

Vagrant.configure("2") do |config|

# Ubuntu
config.vm.define "ansible-collection", primary: true do |srv|
srv.vm.box = "ubuntu/focal64"
srv.vm.network "private_network", ip: "IP_ADDRESS"
srv.ssh.insert_key = false
srv.vm.provider "virtualbox" do |v|
v.name = 'ansible-collection'
v.memory = 4096
v.cpus = 2
end
$script = <<-SCRIPT
apt-get update
apt-get install -y python3-pip
pip install -r /vagrant/requirements.txt
ansible-galaxy collection install -f -r /vagrant/requirements.yml
wget "https://download.checkmk.com/checkmk/2.0.0p23/check-mk-raw-2.0.0p23_0.focal_amd64.deb" -O /tmp/checkmk-stable.deb
wget "https://download.checkmk.com/checkmk/2.1.0b5/check-mk-raw-2.1.0b5_0.focal_amd64.deb" -O /tmp/checkmk-beta.deb
apt-get install -y /tmp/checkmk-stable.deb
omd create --admin-password 'cmk' stable
apt-get install -y /tmp/checkmk-beta.deb
omd create --admin-password 'cmk' beta
omd status -b stable || omd start stable
omd status -b beta || omd start beta
SCRIPT
srv.vm.provision "shell", inline: $script
end

# Ubuntu
config.vm.define "ansible-collection", primary: true do |srv|
srv.vm.box = "ubuntu/focal64"
srv.vm.network "private_network", ip: "IP_ADDRESS"
srv.vm.network "private_network", ip: "192.168.56.42"
srv.ssh.insert_key = false
srv.vm.provider "virtualbox" do |v|
v.name = 'ansible-collection'
Expand All @@ -23,7 +51,7 @@ Vagrant.configure("2") do |config|
pip install -r /vagrant/requirements.txt
ansible-galaxy collection install -f -r /vagrant/requirements.yml
wget "https://download.checkmk.com/checkmk/2.0.0p23/check-mk-raw-2.0.0p23_0.focal_amd64.deb" -O /tmp/checkmk-stable.deb
wget "https://download.checkmk.com/checkmk/2.1.0b5/check-mk-raw-2.1.0b5_0.focal_amd64.deb" -O /tmp/checkmk-beta.deb
wget "https://download.checkmk.com/checkmk/2.1.0b8/check-mk-raw-2.1.0b5_0.focal_amd64.deb" -O /tmp/checkmk-beta.deb
apt-get install -y /tmp/checkmk-stable.deb
omd create --admin-password 'cmk' stable
apt-get install -y /tmp/checkmk-beta.deb
Expand All @@ -32,8 +60,62 @@ Vagrant.configure("2") do |config|
omd status -b beta || omd start beta
SCRIPT
srv.vm.provision "shell", inline: $script
# srv.vm.provision "shell" do |s|
# s.path = "./setup.sh"
# end
end

# Ubuntu
config.vm.define "ansibuntu", autostart: false , primary: false do |srv|
srv.vm.box = "ubuntu/focal64"
srv.vm.network "private_network", ip: "192.168.56.61"
srv.ssh.insert_key = false
srv.vm.provider "virtualbox" do |v|
v.name = 'ansibuntu'
v.memory = 1024
v.cpus = 2
end
srv.vm.provision "shell",
inline: "apt-get -y update --quiet && apt-get -y install vim htop curl wget git"
end

# Debian
config.vm.define "debsible", autostart: false , primary: false do |srv|
srv.vm.box = "debian/bullseye64"
srv.vm.network "private_network", ip: "192.168.56.62"
srv.ssh.insert_key = false
srv.vm.provider "virtualbox" do |v|
v.name = 'debsible'
v.memory = 1024
v.cpus = 2
end
srv.vm.provision "shell",
inline: "apt-get -y update --quiet && apt-get -y install vim htop curl wget git"
end

# CentOS Stream
config.vm.define "anstream", autostart: false , primary: false do |srv|
srv.vm.box = "centos/stream8"
srv.vm.network "private_network", ip: "192.168.56.63"
srv.ssh.insert_key = false
srv.vm.provider "virtualbox" do |v|
v.name = 'anstream'
v.memory = 1024
v.cpus = 2
end
srv.vm.provision "shell",
inline: "dnf --quiet check-update ; dnf -y install vim curl wget git"
end

# openSUSE
config.vm.define "ansuse", autostart: false , primary: false do |srv|
srv.vm.box = "opensuse/Tumbleweed.x86_64"
srv.vm.network "private_network", ip: "192.168.56.64"
srv.ssh.insert_key = false
srv.vm.provider "virtualbox" do |v|
v.name = 'ansuse'
v.memory = 1024
v.cpus = 2
end
srv.vm.provision "shell",
inline: "zypper --quiet up -y"
end

end
47 changes: 47 additions & 0 deletions changelogs/fragments/role-agent.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# https://docs.ansible.com/ansible/latest/community/development_process.html#changelogs-how-to
minor_changes:
- Add agent role. Currently supports the vanilla agent.

# known_issues:
# - This release is still in development and a heavy work in progress.
# - Discovery module is not feature complete yet.
# - Downtime module is not fully idempotent yet. This affects service downtimes and deletions.

## Line Format
# When writing a changelog entry, use the following format:

# - scope - description starting with a lowercase letter and ending with a period at the very end. Multiple sentences are allowed (https://github.com/reference/to/an/issue or, if there is no issue, reference to a pull request itself).

# The scope is usually a module or plugin name or group of modules or plugins, for example, lookup plugins. While module names can (and should) be mentioned directly (foo_module), plugin names should always be followed by the type (foo inventory plugin).

# For changes that are not really scoped (for example, which affect a whole collection), use the following format:

# - Description starting with an uppercase letter and ending with a dot at the very end. Multiple sentences are allowed (https://github.com/reference/to/an/issue or, if there is no issue, reference to a pull request itself).


## Possible keys:

# breaking_changes

# Changes that break existing playbooks or roles. This includes any change to existing behavior that forces users to update tasks. Displayed in both the changelogs and the Porting Guides.
# major_changes

# Major changes to Ansible itself. Generally does not include module or plugin changes. Displayed in both the changelogs and the Porting Guides.
# minor_changes

# Minor changes to Ansible, modules, or plugins. This includes new features, new parameters added to modules, or behavior changes to existing parameters.
# deprecated_features

# Features that have been deprecated and are scheduled for removal in a future release. Displayed in both the changelogs and the Porting Guides.
# removed_features

# Features that were previously deprecated and are now removed. Displayed in both the changelogs and the Porting Guides.
# security_fixes

# Fixes that address CVEs or resolve security concerns. Include links to CVE information.
# bugfixes

# Fixes that resolve issues.
# known_issues

# Known issues that are currently not fixed or will not be fixed.
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace: tribe29
name: checkmk

# The version of the collection. Must be compatible with semantic versioning
version: 0.2.2
version: 0.3.2

# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md
Expand Down
2 changes: 1 addition & 1 deletion playbooks/demo.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- name: "Test all modules."
hosts: all
hosts: test
gather_facts: 'no'
vars_files:
- ./vars/config.yml
Expand Down
42 changes: 42 additions & 0 deletions playbooks/roles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
- name: "Run all roles."
hosts: vagrant
vars_files:
- ./vars/config.yml

roles:
- agent

# tasks:
# - name: "Create host."
# host:
# server_url: "{{ server_url }}"
# site: "{{ site }}"
# automation_user: "{{ automation_user }}"
# automation_secret: "{{ automation_secret }}"
# host_name: "{{ inventory_hostname }}"
# folder: "{{ checkmk_folder_path }}"
# attributes:
# site: "{{ site }}"
# ipaddress: "{{ ansible_host }}"
# state: "present"
# delegate_to: localhost
# - name: "Discover services on host."
# discovery:
# server_url: "{{ server_url }}"
# site: "{{ site }}"
# automation_user: "{{ automation_user }}"
# automation_secret: "{{ automation_secret }}"
# host_name: "{{ inventory_hostname }}"
# state: "fix_all"
# delegate_to: localhost
# - name: "Activate changes."
# activation:
# server_url: "{{ server_url }}"
# site: "{{ site }}"
# automation_user: "{{ automation_user }}"
# automation_secret: "{{ automation_secret }}"
# force_foreign_changes: 'true'
# sites:
# - "{{ site }}"
# delegate_to: localhost
# run_once: 'true'
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
ansible >= 4.10.0
antsibull-changelog >= 0.12.0
antsibull-changelog >= 0.12.0
antsibull-docs >= 1.1.0
4 changes: 4 additions & 0 deletions requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
collections:
- name: tribe29.checkmk
version: 0.3.2
33 changes: 33 additions & 0 deletions roles/agent/.yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
# Based on ansible-lint config
extends: default

rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
colons:
max-spaces-after: -1
level: error
commas:
max-spaces-after: -1
level: error
comments: disable
comments-indentation: disable
document-start: disable
empty-lines:
max: 3
level: error
hyphens:
level: error
indentation: disable
key-duplicates: enable
line-length: disable
new-line-at-end-of-file: disable
new-lines:
type: unix
trailing-spaces: disable
truthy: disable
Loading

0 comments on commit f3c1e31

Please sign in to comment.