I try to create a playbook witch use powershell script to install and configure the windows agent.
The goal is for each new server I will deploy, I use the playbook to install and enroll the agent in my icinga.
I successfully create a working script which need me to give an API key. I found on the webui the API key generate for my “windows host” template. It’s working like a charm but it seems that this key need to be regenerated periodically.
So now i’m searching for a way to get it through cli or api call (to be use in my playbook).
How can I achieve that ?
For now my installation process do the following step :
Installation of Icinga framework without wizard → here a certificate request is waiting for approval on the master node
Approve the previously created request
Enroll the host through the director self service api → for this I use the api key from the host template (that I found in the “Agent” tab of the template definition)
the icinga powershell framework can be used to “install icinga” / “register the host” and “get a valid certificate” because there is a feature for generating tickets used for signing requests.
If you post exactly what you are currently doing, I can try to point you in the right direction.
Hope it’s not so far from the good way to do it ^^
The global process is (with ansible)
1- Execute the script with hostname and step define to 1
2- Ansible sign the csr on the master node
3 - Execute the script with hostname, host template api key and step define to 2
For my understanding, step 1 create the csr, step 2 validate the csr, step 3 create the host in director through self service api.
Am I good ?
Thanks, no I didn’t knew the role. I juste test it everythong seems to be good but I have an error when trying to add host in director : Unhandled exception occurred when sending web request. Exception: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
If I try a curl against the director URL the ssl handshake is OK… Maybe ansible doesn’t use the OS CA cert magazine ?
I try with -vvv but nothing helpfull.
I finally find why, I modified the role to execute this task on the ansible server with a delegate_to: 127.0.0.1 but it seems to continue to be executed from client.
Anyway, on client I just install the CA certificate and no more SSL error since
I put the user in Administrator role to validate the concept, now I have to work on permissions (if you already have the minimum necessary permission I’ll take it. ;))