-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix quoting in template and quote if "!" is in chars * add icingaweb2_groups syntax for testing * added molecule test for ini_templating * added pyinilint as ini validator
- Loading branch information
1 parent
12c4ac1
commit b93d146
Showing
10 changed files
with
182 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: Icingaweb2 Templates | ||
on: | ||
push: | ||
tags: | ||
- '*' | ||
branches: | ||
- main | ||
- 'feature/**' | ||
- 'fix/**' | ||
- '!doc/**' | ||
paths: | ||
- 'roles/icingaweb2/templates/**' | ||
- 'molecule/ini-configuration-tests/**' | ||
pull_request: | ||
branches: | ||
- 'feature/**' | ||
- 'fix/**' | ||
- '!doc/**' | ||
|
||
jobs: | ||
test_ini_template: | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
COLLECTION_NAMESPACE: icinga | ||
COLLECTION_NAME: icinga | ||
|
||
strategy: | ||
fail-fast: false | ||
max-parallel: 1 | ||
matrix: | ||
distro: [ubuntu2204] | ||
python: ['3.9', '3.10'] | ||
ansible: ['2.13.10', '2.14.7'] | ||
scenario: [ini-configuration-tests] | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python }} | ||
|
||
- name: Install dependencies ansible | ||
run: | | ||
python3 -m pip install --upgrade pip | ||
python3 -m pip install -r requirements-test-${{ matrix.ansible }}.txt | ||
- name: Install collection | ||
run: | | ||
mkdir -p ~/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE | ||
cp -a ../ansible-collection-$COLLECTION_NAME ~/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE/$COLLECTION_NAME | ||
- name: Test with molecule | ||
run: | | ||
ansible --version | ||
molecule --version | ||
molecule test -s ${{ matrix.scenario }} | ||
env: | ||
MOLECULE_DISTRO: ${{ matrix.distro }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
bugfixes: | ||
- "Fix quoting for ! in templating Issue #208" | ||
- "Replaced quote filter from ini template" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
collections: | ||
- name: community.docker | ||
- name: community.general | ||
version: ">=2,<3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
- name: Converge | ||
hosts: all | ||
vars: | ||
test_cases: | ||
- name: string | ||
_i2_config_hash: | ||
section: | ||
test: string | ||
- name: number | ||
_i2_config_hash: | ||
section: | ||
test: 10 | ||
- name: advanced_filter | ||
_i2_config_hash: | ||
section: | ||
test: '!(objectClass=user)' | ||
test2: "!(objectClass=user)" | ||
test3: "!attribute" | ||
- name: list | ||
_i2_config_hash: | ||
section: | ||
test: | ||
- "foo" | ||
- bar | ||
- 'baz' | ||
- name: equal_sign | ||
_i2_config_hash: | ||
section: | ||
test: equal=sign | ||
|
||
|
||
collections: | ||
- icinga.icinga | ||
tasks: | ||
- ansible.builtin.pip: | ||
name: pyinilint | ||
state: present | ||
|
||
- ansible.builtin.template: | ||
src: "{{ lookup('ansible.builtin.env', 'MOLECULE_PROJECT_DIRECTORY', default=Undefined) }}/roles/icingaweb2/templates/modules_config.ini.j2" | ||
dest: "/tmp/{{ item.name }}" | ||
validate: pyinilint %s | ||
loop: "{{ test_cases }}" | ||
vars: | ||
_i2_config_hash: "{{ item._i2_config_hash }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
dependency: | ||
name: galaxy | ||
driver: | ||
name: docker | ||
platforms: | ||
- name: icinga-default | ||
image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2204}-ansible:latest" | ||
command: ${MOLECULE_DOCKER_COMMAND:-""} | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:rw | ||
cgroupns_mode: host | ||
privileged: true | ||
pre_build_image: true | ||
provisioner: | ||
name: ansible | ||
inventory: | ||
link: | ||
host_vars: host_vars/ | ||
verifier: | ||
name: testinfra | ||
directory: tests/integration/ | ||
lint: | | ||
set -e | ||
yamllint --no-warnings roles/ | ||
ansible-lint roles/ |
29 changes: 29 additions & 0 deletions
29
molecule/ini-configuration-tests/tests/integration/test_ini_config.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
def test_string(host): | ||
i2_file = host.file("/tmp/string") | ||
print(i2_file.content_string) | ||
assert i2_file.is_file | ||
assert i2_file.content_string == "\n[section]\ntest = string\n" | ||
|
||
def test_number(host): | ||
i2_file = host.file("/tmp/number") | ||
print(i2_file.content_string) | ||
assert i2_file.is_file | ||
assert i2_file.content_string == '\n[section]\ntest = "10"\n' | ||
|
||
def test_list(host): | ||
i2_file = host.file("/tmp/list") | ||
print(i2_file.content_string) | ||
assert i2_file.is_file | ||
assert i2_file.content_string == '\n[section]\ntest = "foo, bar, baz"\n' | ||
|
||
def test_advanced_filter(host): | ||
i2_file = host.file("/tmp/advanced_filter") | ||
print(i2_file.content_string) | ||
assert i2_file.is_file | ||
assert i2_file.content_string == "\n[section]\ntest = '!(objectClass=user)'\ntest2 = '!(objectClass=user)'\ntest3 = '!attribute'\n" | ||
|
||
def test_equal_sign(host): | ||
i2_file = host.file("/tmp/equal_sign") | ||
print(i2_file.content_string) | ||
assert i2_file.is_file | ||
assert i2_file.content_string == "\n[section]\ntest = 'equal=sign'\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters