ICINGA2 master clone - change hostname

I need to perform OS upgrade and migration to ICINGADB on my ICINGA2 Master node.

To test the entire procedure - I hace created a CLONE of my Master node.
I need a step by step procedure to change the HOSTNAME of my ICINGA2 Master.
Looking for a procure I found a couple of post in this forum.

Mostly they say to

  • change hostname at OS Level

  • Adapt /etc/hosts

  • rm /var/lib/icinga2/ca/*

  • rm /var/lib/icinga2/certs/*

  • rm /var/cache/icinga2/*

vi /etc/icinga2/constants.conf -->and modify hostname using the new one

  • icinga2 feature disable api
  • vi /etc/icinga2/constants.conf
  • icinga2 api setup
  • icinga2 daemon -C

Arriving at this point I have several error .

The error says :
critical/config: Error: Validation failed for object ‘SRV123’ of type ‘Zone’; Attribute ‘parent’: Object ‘icinga2-prd.local’ of type ‘Zone’ does not exist.

where “'icinga2-prd.local” is my source server used to create the copy.

FRom director I still see the OLD endponint and OLD Zone… but I cannot delete from director…
What are the complete steps to perform a hostname change in icinga master node ?

The error looks like you missed zones.conf and zones.d/.

Try a recursive grep of the old name against /etc/icinga2:

grep -r icinga2-prd.local /etc/icinga2

The director hold the objects, once detected, in its dedicated DB.
Not sure if you can just re detect or need to export all as baskets and rebuild the director DB.

Is not so easy.
Changing these occorence do not solve the problem…
That’s a pity!

Because hostname change can be an operation that is needed during the lifecycle of system

You will probably also need to clean up the rendered configs under /var/lib/icinga2/ and rebuild the PKI and deploy new certificates.

Yes, a script or a Ansible role to document and automate this would be great.