Skip to content

Commit

Permalink
updates for icinga doc
Browse files Browse the repository at this point in the history
  • Loading branch information
bodsch committed Dec 16, 2024
1 parent f594eda commit d699656
Show file tree
Hide file tree
Showing 44 changed files with 999 additions and 584 deletions.
17 changes: 15 additions & 2 deletions hooks/doc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

. hooks/molecule.rc

set -x
# set -x

if [ -z "${COLLECTION_DIR}" ]
then
Expand All @@ -17,7 +17,7 @@ then
# ansible-doc --list --list_files -t module ${COLLECTION_NAMESPACE}.${COLLECTION_NAME}

ansible_modules=$(
ansible-doc --list ${COLLECTION_NAMESPACE}.${COLLECTION_NAME} --json | jq -r 'keys[]'
ansible-doc --list ${COLLECTION_NAMESPACE}.${COLLECTION_NAME} --type module --json | jq -r 'keys[]'
)

for i in ${ansible_modules}
Expand All @@ -26,6 +26,19 @@ then
PAGER='cat' ansible-doc --type module ${i}
echo ""
done

# -------------------------------------------------
ansible_filter=$(
ansible-doc --list ${COLLECTION_NAMESPACE}.${COLLECTION_NAME} --type filter --json | jq -r 'keys[]'
)

# for i in ${ansible_filter}
# do
# # echo " - ${i}"
# PAGER='cat' ansible-doc --type filter ${i}
# echo ""
# done

fi

exit 0
3 changes: 3 additions & 0 deletions hooks/install
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ rsync \
--verbose \
--recursive \
--exclude hooks \
--exclude *OBSOLETE* \
--exclude *obsolete* \
--exclude __pycache__ \
--delete \
--delete-excluded \
../ansible-collection-${COLLECTION_NAME}/* \
"${COLLECTION_DIR}/"
29 changes: 29 additions & 0 deletions plugins/filter/append_checksum.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

DOCUMENTATION:
name: append_checksum
author: Bodo Schulz (@bodsch)
version_added: 1.0.0
short_description: create a list from list
description:
- create a list from list.
positional: _input
options:
_input:
description: a dictionary with some icingaweb modules or themes.
type: dict
required: true
checksums:
description: A dictionary mit checksums.
type: dict
required: true
notes:

EXAMPLES: |
icingaweb_modules: "{{ icingaweb_modules | bodsch.icinga.append_checksum(_module_checksum) }}"
icingaweb_themes: "{{ icingaweb_themes | bodsch.icinga.append_checksum(_theme_checksum) }}"
RETURN:
_value:
description: The original dictionary, in which each entry was extended with a checksum for the corresponding archive.
type: dict
27 changes: 27 additions & 0 deletions plugins/filter/apply_notification.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

DOCUMENTATION:
name: apply_notification
author: Bodo Schulz (@bodsch)
version_added: 1.0.0
short_description: TBD
description:
- TBD
positional: _input
options:
_input:
description: A directories of ...
type: dict
required: true
name:
description: TBD.
type: string
required: true
notes:

EXAMPLES: |
data, _type, valid_data = icinga2_notification_apply_rules | bodsch.icinga.apply_notification(n)
RETURN:
_value:
description: TBD
type: tuple
27 changes: 27 additions & 0 deletions plugins/filter/apply_service_name.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

DOCUMENTATION:
name: apply_service_name
author: Bodo Schulz (@bodsch)
version_added: 1.0.0
short_description: TBD
description:
- TBD
positional: _input
options:
_input:
description: A directories of ...
type: dict
required: true
default:
description: TBD.
type: string
required: true
notes:

EXAMPLES: |
v, _name = v | bodsch.icinga.apply_service_name(c)
RETURN:
_value:
description: TBD
type: tuple
27 changes: 27 additions & 0 deletions plugins/filter/database_schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

DOCUMENTATION:
name: database_schema
author: Bodo Schulz (@bodsch)
version_added: 1.0.0
short_description: Defines a database schema file to be imported.
description:
- Defines a database schema file to be imported.
positional: _input
options:
_input:
description: A dictionary with found files.
type: dict
required: true
database_type:
description: A string with database types to be searched for in the dictionary. The default is ‘mysql’
type: string
required: false
notes:

EXAMPLES: |
icingadb_database_schema: "{{ found_schema | bodsch.icinga.database_schema('mysql') | first }}"
RETURN:
_value:
description: A list of the files found.
type: list
27 changes: 27 additions & 0 deletions plugins/filter/database_upgrade_directory.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

DOCUMENTATION:
name: database_upgrade_directory
author: Bodo Schulz (@bodsch)
version_added: 1.0.0
short_description: Defines a directory from which update files are to be obtained.
description:
- Defines a directory from which update files are to be obtained.
positional: _input
options:
_input:
description: A dictionary with found directories.
type: dict
required: true
database_type:
description: A string with database types to be searched for in the dictionary. The default is ‘mysql’
type: string
required: false
notes:

EXAMPLES: |
icingadb_upgrade_directory: "{{ found_directory | bodsch.icinga.database_upgrade_directory('mysql')}}"
RETURN:
_value:
description: A string with the found directories.
type: string
27 changes: 27 additions & 0 deletions plugins/filter/dict_from_list.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

DOCUMENTATION:
name: dict_from_list
author: Bodo Schulz (@bodsch)
version_added: 1.0.0
short_description: create a dictionary from list
description:
- create a dictionary from list.
positional: _input
options:
_input:
description: A list of elements.
type: list
required: true
search:
description: An string to search entries in (c(_input)) list.
type: string
required: true
notes:

EXAMPLES: |
_icingaweb_module_grafana: "{{ icingaweb_modules | bodsch.icinga.dict_from_list('grafana') }}"
RETURN:
_value:
description: The element you are looking for as a dictionary.
type: dict
35 changes: 35 additions & 0 deletions plugins/filter/dns_icinga_primary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

DOCUMENTATION:
name: dns_icinga_primary
author: Bodo Schulz (@bodsch)
version_added: 1.0.0
short_description: TBD
description:
- TBD
positional: _input
options:
_input:
description: A directories of ...
type: dict
required: true
object_name:
description: TBD.
type: bool
required: true
object_data:
description: TBD.
type: string
required: true
alternatives:
description: TBD.
type: list
required: true
notes:

EXAMPLES: |
address = icinga2_masters | bodsch.icinga.dns_icinga_primary(object_name=key, object_data=values, alternatives=[key, ansible_fqdn])
RETURN:
_value:
description: TBD
type: string
39 changes: 39 additions & 0 deletions plugins/filter/dns_icinga_satellite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

DOCUMENTATION:
name: dns_icinga_satellite
author: Bodo Schulz (@bodsch)
version_added: 1.0.0
short_description: TBD
description:
- TBD
positional: _input
options:
_input:
description: A directories of ...
type: dict
required: true
object_name:
description: TBD.
type: bool
required: true
object_data:
description: TBD.
type: string
required: true
satellite_zone:
description: TBD.
type: dict
required: true
alternatives:
description: TBD.
type: list
required: true
notes:

EXAMPLES: |
address = icinga2_masters | bodsch.icinga.dns_icinga_satellite(object_name=key, object_data=values, satellite_zone=icinga2_satellite_zone, alternatives=[key, ansible_fqdn])
RETURN:
_value:
description: TBD
type: string
38 changes: 38 additions & 0 deletions plugins/filter/host_object_values.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

DOCUMENTATION:
name: host_object_values
author: Bodo Schulz (@bodsch)
version_added: 1.0.0
short_description: TBD
description:
- TBD
positional: _input
options:
_input:
description: A directories of ...
type: dict
required: true
primary:
description: TBD.
type: bool
required: true
key:
description: TBD.
type: string
required: true
ansible_fqdn:
description: TBD.
type: string
required: true
notes:

EXAMPLES: |
values, endpoint, endpoint_name, zone_name, display_name, check_command, _ = values | bodsch.icinga.host_object_values(True, key, None)
values, _, object_name, zone_name, display_name, check_command, address = values | bodsch.icinga.host_object_values(False, key, ansible_fqdn)
RETURN:
_value:
description: TBD
type: tuple
27 changes: 27 additions & 0 deletions plugins/filter/icinga_satellite_zone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

DOCUMENTATION:
name: icinga_satellite_zone
author: Bodo Schulz (@bodsch)
version_added: 1.0.0
short_description: Defines a satellite zone if icinga2_satellites is configured.
description:
- Defines a satellite zone if icinga2_satellites is configured.
positional: _input
options:
_input:
description: A directories of icinga satellites.
type: dict
required: true
ansible_fqdn:
description: The ansible_fqdn to search for in the dictionary to define the zone.
type: string
required: true
notes:

EXAMPLES: |
icinga2_satellite_zone: "{{ icinga2_satellites | bodsch.icinga.icinga_satellite_zone(ansible_fqdn) }}"
RETURN:
_value:
description: The zone name for the ansible_fqdn.
type: string
1 change: 1 addition & 0 deletions plugins/filter/icingadb.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
class FilterModule(object):
"""
"""

def filters(self):
return {
'database_schema': self.database_schema,
Expand Down
8 changes: 4 additions & 4 deletions plugins/filter/icingaweb.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# python 3 headers, required if submitting to Ansible

from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

from ansible.utils.display import Display

import json
import crypt

# https://docs.ansible.com/ansible/latest/dev_guide/developing_plugins.html
# https://blog.oddbit.com/post/2019-04-25-writing-ansible-filter-plugins/
__metaclass__ = type


display = Display()

Expand All @@ -21,7 +21,7 @@ class FilterModule(object):
def filters(self):
return {
# 'type': self.var_type,
'create_password_hash': self.password_hash,
# 'create_password_hash': self.password_hash,
'dict_from_list': self.dict_from_list,
'module_version': self.module_version,
}
Expand Down
Loading

0 comments on commit d699656

Please sign in to comment.