Skip to content

Rework api feature - #465

Open
Donien wants to merge 11 commits into
NETWAYS:mainfrom
Donien:api-feature
Open

Rework api feature#465
Donien wants to merge 11 commits into
NETWAYS:mainfrom
Donien:api-feature

Conversation

@Donien

@Donien Donien commented Apr 28, 2026

Copy link
Copy Markdown
Member

Add module netways.icinga.icinga2_api to handle setting up the node as a master / agent.

Rework api feature tasks to make use of the new module instead of having all logic in tasks.

@Donien
Donien requested a review from Saeid-Abadi April 28, 2026 13:53
@Donien Donien self-assigned this Apr 28, 2026
@Donien Donien added the feature New feature or request label Apr 28, 2026
@Donien
Donien requested a review from dgoetz May 29, 2026 10:22

@dgoetz dgoetz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not tested yet, just commented what I did see while carefully reading it.

You can use the `netways.icinga.icinga2_ticket` filter to create a valid ticket if you know the secret `TicketSalt`.
Example: `ticket: "{{ <common_name> | netways.icinga.icinga2_ticket(ticketsalt='<secret_ticket_salt>') }}"`

**Auto-signing without ticket:**

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if the headline is misleading as a ticket is still required here, you just don't provide it explicitly. Would "Auto-signing without providing a ticket" be a better headline? If changed, would the headline before also need to be changed to "Providing a ticket for auto-signing"?

**Auto-signing with reverse connection:**
Used in environments where the agent cannot connect to its parent but the parent can connect to the agent.
Here delegation to `parent_host` (or `icinga2_delegate_host`) is used to retrieve the CA certificate and generate a ticket.
This is used if `delegate_pki: true`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would change the wording and order here to more explicitly to tell the user it is required to set delegate_pki to true which changes now what parent_host does.


By default the FQDN is used as certificate common name, to put a name
yourself:
By default the FQDN is used as certificate common name, to put a name yourself:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add some disclaimer here that this is typically not best practice and can require additional work in further steps like the director setup not being able to utilize the agent setting or at least give the one good example for this feature which would be lower-casing the hostname?

```

To increase your security set `ca_fingerprint` to validate the certificate of the `ca_host`:
To increase your security set `ca_fingerprint` to validate the CA certificate:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add how to get the fingerprint for using it here?

* `ca_host: string`
* Use to decide where to gather the certificates. When set to **None**, Ansible will create a local Certificate Authority on the Host. Use **hostname** or **ipaddress** as value.
* `parent_host: string`
* Use to decide where to gather the certificates. When set to **none**, Ansible will create a local Certificate Authority on the Host. Use **hostname** or **ipaddress** as value.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is hostname or ipaddress here really a good choice as the certificate will contain an FQDN?

Comment thread plugins/modules/icinga2_api.py Outdated
# Potential answers
# information/cli: Writing CA certificate to file '/var/lib/icinga2/certs/ca.crt'.
# information/cli: Writing signed certificate to file '/var/lib/icinga2/certs/<node_name>.crt'.
# → RC X

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

X is just a placeholder here

Comment thread plugins/modules/icinga2_api.py Outdated
# → First connection after certificate is signed
#
# Could not fetch valid response. Please check the master log.
# → RC X

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

X is just a placeholder here

Comment thread plugins/modules/icinga2_api.py Outdated
)
ret['changed'] = True

# WIP: Trusted parent cert could be wrong at this point because parent might have forcefully created a new cert

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A WIP that perhaps should be addressed

Comment thread plugins/modules/icinga2_api.py Outdated
if not cn:
cn = socket.getfqdn()

if mode == 'agent':

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be the same for satellite or did I just miss where satellite is changed to agent?

Comment thread plugins/modules/icinga2_api.py Outdated
mode_ret = dict()
config_ret = dict()

if mode == 'agent':

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be the same for satellite or did I just miss where satellite is changed to agent?

@Donien

Donien commented Jun 3, 2026

Copy link
Copy Markdown
Member Author

Also tested by/with @Saeid-Abadi.

We should add a notify to the netways.icinga.icinga2_api task to restart the Icinga service.
It took us long enough to find out a restart would have solved our issue...

Add module `netways.icinga.icinga2_api` to handle setting up the node as
a master / agent.

Rework api feature tasks to make use of the new module instead of having
all logic in tasks.
@dgoetz

dgoetz commented Jul 31, 2026

Copy link
Copy Markdown
Member

Just as a note for myself for further reviews: Reviewed all the changes till now which address my comments, no additional comments, but not everything is solved yet.

@dgoetz dgoetz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing all my nitpicking! ;-)

@Donien

Donien commented Aug 10, 2026

Copy link
Copy Markdown
Member Author

Thank you for nitpicking! :D

@Donien
Donien marked this pull request as ready for review August 10, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants