I’ve an Icinga Ansible role with a template that contains:
/* Our local instance name. By default this is the server's hostname as returned by `hostname --fqdn`.
* This should be the common name from the API certificate.
*/
const NodeName = "{{ inventory_hostname }}"
/* Our local zone name. */
const ZoneName = "{{ inventory_hostname }}"
On commits I have a GitLab CI configuration which runs Molecule to test the role, this is currently generating a idempotence error:
CRITICAL Idempotence test failed because of the following tasks:
* => icinga : Icinga constants configuration file in place
The template task that generates this is:
- name: Icinga constants configuration file in place
ansible.builtin.template:
src: "constants.conf.j2"
dest: "/etc/icinga2/constants.conf"
backup: true
owner: nagios
group: nagios
mode: "0640"
And the error is:
TASK [icinga : Icinga constants configuration file in place] *******************
--- before: /etc/icinga2/constants.conf
+++ after: /root/.ansible/tmp/ansible-local-16599q5y5noqw/tmp0p1mg328/constants.conf.j2
@@ -22,10 +22,10 @@
/* Our local instance name. By default this is the server's hostname as returned by `hostname --fqdn`.
* This should be the common name from the API certificate.
*/
-const NodeName = "runner-tusiyw1--project-879-concurrent-0"
+const NodeName = "localhost"
/* Our local zone name. */
-const ZoneName = "runner-tusiyw1--project-879-concurrent-0"
+const ZoneName = "localhost"
/* Secret key for remote node tickets */
const TicketSalt = "eef5mujau3Tae3niesohK6uicheQu8oh"
changed: [localhost]
Does anyone know the cause and or solution for this? I guess I could add tags to ignore any task that uses inventory_hostname
in all roles but I’d rather have a more elegant answer!