Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A way for client to trigger Ansible Playbook?

My task is to automate CentOS installs, including a suite of proprietary software, onto bare metal machines. I've set up a PXE boot server which automates initial install from a Kickstart file and the rest gets passed to an Ansible Playbook.

I've solved all of the above, except I have to be in the server to start the Playbook. I haven't found a good way for the Playbook to start at the request of the client (or perhaps the server-side PXE process can hand it off somehow?), in the hopes that I can cut myself out of the install process.

like image 447
Ken Oh Avatar asked Dec 01 '25 03:12

Ken Oh


1 Answers

I thought I would expand on my comment a little bit.

Depending on what you're trying to accomplish, there are a few options you could consider.

Use ansible-pull

The ansible-pull cli fetches a git repository from a remote server and then locally executes ansible-playbook playbook.yml in the top level of that repository.

This means you can drop something like this into your Kickstart %post script:

ansible-pull -U https://server.example.com/playbooks/client-configuration

This is a great solution if your playbook only requires running tasks on the client.

Trigger a playbook run on the server

If your playbook really needs to execute on the server, you could set up a simple web server that would allow clients to trigger the playbook run. In this case, you would embed curl command or similar into your Kickstart %post script:

curl https://my.server.com/trigger-playbook

The trigger-playbook service would take care of triggering a playbook run targeting the appropriate client. This would require you to implement the service yourself (or use something like webhook to handle that task for you).

like image 200
larsks Avatar answered Dec 03 '25 06:12

larsks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!