Skip to content

Commit

Permalink
Merge pull request #598 from Checkmk/devel
Browse files Browse the repository at this point in the history
Release 4.4.1
  • Loading branch information
robin-checkmk authored May 1, 2024
2 parents c7664da + 4c10695 commit eca938f
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 34 deletions.
42 changes: 36 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ COLLECTION_ROOT="/home/vagrant/ansible_collections/checkmk/general"
CONTAINER_BUILD_ROOT="$(COLLECTION_ROOT)/tests/container"
CONTAINER_NAME="ansible-checkmk-test"

#https://stackoverflow.com/questions/3931741/why-does-make-think-the-target-is-up-to-date
.PHONY: clean

help:
@echo "setup - Run all setup target at once."
@echo ""
Expand All @@ -19,12 +22,16 @@ help:
@echo ""
@echo "vbox - Copy the correct Vagrantfile for use with VirtualBox."
@echo ""
@echo "vm - Create a virtual development environment."
@echo "molecule - Create a virtual environment for molecule tests."
@echo "vms - Create a virtual environment with all boxes (exept for the development ones and ansidows)."
@echo "vms-debian - Create a virtual environment with all Debian family OSes."
@echo "vms-redhat - Create a virtual environment with all RedHat family OSes."
@echo "vms-suse - Create a virtual environment with all Suse family OSes."
@echo "setup-vagrant - Install and enable Vagrant."
@echo ""
@echo "venv - Install Python Virtual Environment. You need to activate it yourself though!"
@echo ""
@echo "vm - Create a virtual development environment."
@echo "molecule - Create a virtual environment for molecule tests."
@echo "vms - Create a virtual environment with all boxes (exept for the development ones and ansidows)."
@echo "vms-debian - Create a virtual environment with all Debian family OSes."
@echo "vms-redhat - Create a virtual environment with all RedHat family OSes."
@echo "vms-suse - Create a virtual environment with all Suse family OSes."
@echo ""
@echo "container - Create a customized container image for testing."
@echo ""
Expand Down Expand Up @@ -61,6 +68,7 @@ setup-python:
@sudo apt-get -y update --quiet
@sudo apt-get -y install -y \
python3-pip \
python3-venv \
ca-certificates \
curl \
gnupg \
Expand Down Expand Up @@ -98,6 +106,28 @@ vbox:

setup-vbox: vbox

setup-vagrant:
@sudo apt update -y
@sudo apt install -y \
apt-transport-https \
ca-certificates \
wget \
software-properties-common
@wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
@echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $$(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
@sudo apt update -y
@sudo apt -y install vagrant
@sudo usermod -aG libvirt $(USER)
@vagrant plugin install vagrant-libvirt

venv:
@python3 -m venv venv
@echo
@echo "Run the following command to actually activate the venv!"
@echo ". venv/bin/activate"
@echo
@(. venv/bin/activate && python3 -m pip install pip --upgrade && python3 -m pip install -r requirements.txt)

clean: clean-vm

clean-vm:
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@ See [CONTRIBUTING](CONTRIBUTING.md).
See [CHANGELOG.rst](CHANGELOG.rst).
## Versioning
This collection uses [Semantic Versioning](https://semver.org/) for releases. From the official homepage:
Given a version number MAJOR.MINOR.PATCH, increment the:
MAJOR version when you make incompatible API changes
MINOR version when you add functionality in a backward compatible manner
PATCH version when you make backward compatible bug fixes
## Roadmap
<!-- Optional. Include the roadmap for this collection, and the proposed release/versioning strategy so users can anticipate the upgrade/update cycle. -->
This is merely a collection of possible additions to the collection.
Expand Down
1 change: 1 addition & 0 deletions SUPPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ Collection Version | Checkmk Versions | Ansible Versions | Remarks
4.3.0 | 2.0.0p39, 2.1.0p39, 2.2.0p22 | 2.14, 2.15, 2.16 | None
4.3.1 | 2.0.0p39, 2.1.0p39, 2.2.0p22 | 2.14, 2.15, 2.16 | None
4.4.0 | 2.0.0p39, 2.1.0p41, 2.2.0p24 | 2.14, 2.15, 2.16 | None
4.4.1 | 2.0.0p39, 2.1.0p41, 2.2.0p24 | 2.14, 2.15, 2.16 | None
1 change: 0 additions & 1 deletion Vagrantfile.kvm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Vagrant.configure("2") do |config|
libvirt.memory = 8096
libvirt.cpus = 4
libvirt.title = 'collection'
libvirt.keymap = "de"
libvirt.memorybacking :access, :mode => 'shared'
libvirt.memorybacking :source, :type => 'memfd'
end
Expand Down
2 changes: 2 additions & 0 deletions changelogs/fragments/fix_host_initial_folder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- Host module - Fix hosts always being created in the main directory.
3 changes: 3 additions & 0 deletions changelogs/fragments/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
minor_changes:
- Add 'ansible.utils' collection as an explicitely dependency.
We already had this dependency, but are now declaring it explicitely.
1 change: 1 addition & 0 deletions changelogs/fragments/release_summary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
release_summary: "Bugfix Release."
3 changes: 2 additions & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ name: general

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

version: 4.4.0
version: 4.4.1

# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md
Expand Down Expand Up @@ -47,6 +47,7 @@ tags: [checkmk, monitoring, check_mk, check, discovery, ubuntu, debian, sles, rh
dependencies:
"community.general": ">=5.0.0"
"ansible.posix": ">=1.4.0"
"ansible.utils": ">=1.0.1"

# The URL of the originating SCM repository
repository: https://github.com/Checkmk/ansible-collection-checkmk.general
Expand Down
9 changes: 2 additions & 7 deletions plugins/modules/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,7 @@ def __init__(self, module):
# Get the current host from the API and set some parameters
self._get_current()

if self.state == "present":
if (
self.params.get("folder")
and self.current["folder"] != self.params["folder"]
):
self.desired["folder"] = self.params["folder"]
self.desired["folder"] = self.params["folder"]

if self.params.get("nodes"):
self.desired["nodes"] = self.params.get("nodes")
Expand Down Expand Up @@ -423,7 +418,7 @@ def _build_modify_cluster_endpoint(self):
return HostEndpoints.modify_cluster % self.desired["host_name"]

def _detect_changes_folder(self):
current_folder = self.current.get("folder")
current_folder = self.current.get("folder", "/")
desired_folder = self.desired.get("folder")
changes = []

Expand Down
48 changes: 32 additions & 16 deletions tests/integration/targets/host/tasks/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ item.name }}"
folder: "{{ item.folder }}"
folder: "{{ item.folder | default(omit) }}"
attributes:
site: "{{ outer_item.site }}"
ipaddress: 127.0.0.1
Expand All @@ -40,14 +40,30 @@
delegate_to: localhost
run_once: true # noqa run-once[task]

- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Verify host folder."
ansible.builtin.assert:
that: "(item.folder | default('/')) == extensions.folder"
vars:
extensions: "{{ lookup('checkmk.general.host',
item.name,
server_url=checkmk_var_server_url,
site=outer_item.site,
validate_certs=False,
automation_user=checkmk_var_automation_user,
automation_secret=checkmk_var_automation_secret)
}}"
delegate_to: localhost
run_once: true # noqa run-once[task]
loop: "{{ checkmk_hosts }}"

- name: "{{ outer_item.version }} - {{ outer_item.edition | upper }} - Delete hosts."
host:
server_url: "{{ checkmk_var_server_url }}"
site: "{{ outer_item.site }}"
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ item.name }}"
folder: "{{ item.folder }}"
folder: "{{ item.folder | default(omit) }}"
state: "absent"
delegate_to: localhost
run_once: true # noqa run-once[task]
Expand Down Expand Up @@ -134,7 +150,7 @@
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ item.name }}"
folder: "{{ item.folder }}"
folder: "{{ item.folder | default(omit) }}"
state: "absent"
delegate_to: localhost
run_once: true # noqa run-once[task]
Expand All @@ -160,7 +176,7 @@
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ item.name }}"
folder: "{{ item.folder }}"
folder: "{{ item.folder | default(omit) }}"
attributes:
site: "{{ outer_item.site }}"
ipaddress: 127.0.0.1
Expand Down Expand Up @@ -188,7 +204,7 @@
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ item.name }}"
folder: "{{ item.folder }}"
folder: "{{ item.folder | default(omit) }}"
nodes: "{{ item.nodes }}"
attributes:
site: "{{ outer_item.site }}"
Expand Down Expand Up @@ -217,7 +233,7 @@
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ item.name }}"
folder: "{{ item.folder }}"
folder: "{{ item.folder | default(omit) }}"
nodes: "{{ item.nodes }}"
attributes:
site: "{{ outer_item.site }}"
Expand All @@ -234,7 +250,7 @@
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ first.name }}"
folder: "{{ first.folder }}"
folder: "{{ first.folder | default(omit) }}"
nodes: "{{ second.nodes }}"
attributes:
site: "{{ outer_item.site }}"
Expand Down Expand Up @@ -265,7 +281,7 @@
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ first.name }}"
folder: "{{ first.folder }}"
folder: "{{ first.folder | default(omit) }}"
nodes: "{{ second.nodes }}"
attributes:
site: "{{ outer_item.site }}"
Expand All @@ -284,7 +300,7 @@
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ item.name }}"
folder: "{{ item.folder }}"
folder: "{{ item.folder | default(omit) }}"
add_nodes: "{{ item.add_nodes }}"
attributes:
site: "{{ outer_item.site }}"
Expand Down Expand Up @@ -313,7 +329,7 @@
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ item.name }}"
folder: "{{ item.folder }}"
folder: "{{ item.folder | default(omit) }}"
add_nodes: "{{ item.add_nodes }}"
attributes:
site: "{{ outer_item.site }}"
Expand Down Expand Up @@ -342,7 +358,7 @@
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ item.name }}"
folder: "{{ item.folder }}"
folder: "{{ item.folder | default(omit) }}"
remove_nodes: "{{ item.remove_nodes }}"
attributes:
site: "{{ outer_item.site }}"
Expand Down Expand Up @@ -371,7 +387,7 @@
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ item.name }}"
folder: "{{ item.folder }}"
folder: "{{ item.folder | default(omit) }}"
remove_nodes: "{{ item.remove_nodes }}"
attributes:
site: "{{ outer_item.site }}"
Expand Down Expand Up @@ -401,7 +417,7 @@
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ item.name }}"
folder: "{{ item.folder }}"
folder: "{{ item.folder | default(omit) }}"
state: "absent"
delegate_to: localhost
run_once: true # noqa run-once[task]
Expand All @@ -426,7 +442,7 @@
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ item.name }}"
folder: "{{ item.folder }}"
folder: "{{ item.folder | default(omit) }}"
state: "absent"
delegate_to: localhost
run_once: true # noqa run-once[task]
Expand Down Expand Up @@ -506,7 +522,7 @@
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ item.name }}"
nodes: "{{ item.nodes }}"
folder: "{{ item.folder }}"
folder: "{{ item.folder | default(omit) }}"
state: "absent"
delegate_to: localhost
run_once: true # noqa run-once[task]
Expand All @@ -519,7 +535,7 @@
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ item.name }}"
folder: "{{ item.folder }}"
folder: "{{ item.folder | default(omit) }}"
state: "absent"
delegate_to: localhost
run_once: true # noqa run-once[task]
Expand Down
12 changes: 9 additions & 3 deletions tests/integration/targets/host/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ test_sites:
- version: "2.1.0p41"
edition: "cre"
site: "old_cre"
- version: "2.0.0p39"
edition: "cre"
site: "ancient_cre"
# Temporarily disable due to #596 until the permanent change to remove it lands.
# - version: "2.0.0p39"
# edition: "cre"
# site: "ancient_cre"

checkmk_var_folders:
- path: /foo
Expand All @@ -24,6 +25,7 @@ checkmk_var_folders:
name: Digital

checkmk_hosts:
- name: test0.tld
- name: test1.tld
folder: "/"
- name: test2.tld
Expand All @@ -36,6 +38,10 @@ checkmk_hosts:
folder: "/foo/bar1"

checkmk_cluster_hosts:
- name: cluster_test0.tld
nodes:
- "test0.tld"
- "test4.tld"
- name: cluster_test1.tld
folder: "/"
nodes:
Expand Down

0 comments on commit eca938f

Please sign in to comment.