From 3c4e246b655fb2e7848b5b028df24f7d4e06c306 Mon Sep 17 00:00:00 2001 From: Thilo W Date: Fri, 29 Sep 2023 13:35:26 +0200 Subject: [PATCH] Fix/template integer handling (#183) * add clause to catch integer values in config --- molecule/default/collections.yml | 1 - molecule/default/converge.yml | 33 ++++++++++++++++++---- molecule/default/dependency.yml | 2 ++ molecule/default/requirements.yml | 3 +- molecule/local-default-pgsql/converge.yml | 10 +++---- molecule/local-default/converge.yml | 26 +++++++++++++---- molecule/local-default/molecule.yml | 2 +- roles/icingaweb2/templates/ini_template.j2 | 4 ++- 8 files changed, 60 insertions(+), 21 deletions(-) diff --git a/molecule/default/collections.yml b/molecule/default/collections.yml index 3b5d695f..66cb0953 100644 --- a/molecule/default/collections.yml +++ b/molecule/default/collections.yml @@ -1,6 +1,5 @@ collections: - name: community.mysql - name: community.docker - version: ">=1.9.0,<2.0.0" - name: community.general version: ">=2,<3" diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index 0028d4f3..6294a9ce 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -3,6 +3,13 @@ - name: Converge hosts: all vars: + icingaweb2_db: + type: mysql + name: icingaweb + host: 127.0.0.1 + user: icingaweb + password: icingaweb + icingaweb2_database_import_schema: true icingadb_database_import_schema: true mysql_innodb_file_format: barracuda mysql_innodb_large_prefix: 1 @@ -12,12 +19,17 @@ - mariadb-server - python3-mysqldb mysql_users: + - name: icingaweb + host: "%" + password: icingaweb + priv: "icingaweb.*:ALL" - name: icingadb host: "%" password: icingadb priv: "icingadb.*:ALL" mysql_databases: - name: icingadb + - name: icingaweb icinga2_confd: false icinga2_features: - name: perfdata @@ -61,9 +73,18 @@ - zones.d/main/services collections: - icinga.icinga - roles: - - repos - - icinga2 - - geerlingguy.mysql - - icingadb - - icingadb_redis + pre_tasks: + - include_role: + name: repos + - include_role: + name: geerlingguy.mysql + - include_role: + name: icinga2 + - include_role: + name: icingadb + - include_role: + name: icingadb_redis + + post_tasks: + - include_role: + name: icingaweb2 diff --git a/molecule/default/dependency.yml b/molecule/default/dependency.yml index 9810d54a..8ff1b3a6 100644 --- a/molecule/default/dependency.yml +++ b/molecule/default/dependency.yml @@ -2,3 +2,5 @@ dependency: name: galaxy options: role-file: requirements.yml + env: + ANSIBLE_ROLES_PATH: .ansible/roles diff --git a/molecule/default/requirements.yml b/molecule/default/requirements.yml index 9fb44f01..cf94e2e2 100644 --- a/molecule/default/requirements.yml +++ b/molecule/default/requirements.yml @@ -1 +1,2 @@ -- src: geerlingguy.mysql +roles: + - geerlingguy.mysql diff --git a/molecule/local-default-pgsql/converge.yml b/molecule/local-default-pgsql/converge.yml index be7ff5bb..352641bd 100644 --- a/molecule/local-default-pgsql/converge.yml +++ b/molecule/local-default-pgsql/converge.yml @@ -68,9 +68,9 @@ collections: - icinga.icinga roles: - #- repos - #- geerlingguy.postgresql - #- icinga2 + - repos + - geerlingguy.postgresql + - icinga2 - icingadb - #- icingadb_redis - #- icingaweb2 + - icingadb_redis + - icingaweb2 diff --git a/molecule/local-default/converge.yml b/molecule/local-default/converge.yml index 881c2cea..b1b2da74 100644 --- a/molecule/local-default/converge.yml +++ b/molecule/local-default/converge.yml @@ -1,6 +1,9 @@ - name: Converge hosts: all become: true + module_defaults: + ansible.builtin.apt: + cache_valid_time: 3600 vars: icingaweb2_resources: director_db: @@ -28,7 +31,7 @@ run_kickstart: true kickstart: config: - endpoint: "{{ ansible_fqdn }}" + endpoint: icinga-default host: 127.0.0.1 username: root password: root @@ -79,6 +82,7 @@ icingaweb2_admin_username: admin icingaweb2_admin_password: admin icingaweb2_db_import_schema: true + icingadb_database_type: mysql icingadb_database_import_schema: true mysql_innodb_file_format: barracuda mysql_innodb_large_prefix: 1 @@ -160,8 +164,18 @@ - zones.d/main/services collections: - icinga.icinga - roles: - - repos - - geerlingguy.mysql - - icinga2 - - icingaweb2 + pre_tasks: + - include_role: + name: repos + - include_role: + name: geerlingguy.mysql + - include_role: + name: icinga2 + - include_role: + name: icingadb + - include_role: + name: icingadb_redis + + post_tasks: + - include_role: + name: icingaweb2 diff --git a/molecule/local-default/molecule.yml b/molecule/local-default/molecule.yml index 43de72ec..0a29467c 100644 --- a/molecule/local-default/molecule.yml +++ b/molecule/local-default/molecule.yml @@ -8,7 +8,7 @@ driver: platforms: - name: icinga-default box: ubuntu/jammy64 - memory: 512 + memory: 1024 cpus: 1 interfaces: - network_name: private_network diff --git a/roles/icingaweb2/templates/ini_template.j2 b/roles/icingaweb2/templates/ini_template.j2 index dfeaa376..33c7c5da 100644 --- a/roles/icingaweb2/templates/ini_template.j2 +++ b/roles/icingaweb2/templates/ini_template.j2 @@ -3,7 +3,9 @@ [{{ section }}] {% for option, value in options.items() %} -{% if value is iterable and (value is not string and value is not mapping) %} +{% if value is number %} +{{ option }} = "{{ value }}" +{% elif value is iterable and (value is not string and value is not mapping) %} {{ option }} = "{{ value | join(', ') }}" {% elif value is string and "=" in value %} {% else %}