Automatically deleting a provisioned host

Is there anyway to automatically delete a provisioned host? I tried looking through the settings but can’t find any.
Expected outcome:
Host is automatically deleted after successful provision
Foreman and Proxy versions:
Foreman and Proxy plugin versions:
Distribution and version:

Other relevant data:

Hi @jpbw720,

Short answer is no, I mean not directly with foreman settings. Can you describe your exact need ?

If it’s for CI (create, test, delete), you can use hammer or REST API. And wrap it with Jenkins, Ansible playbooks … Or even with foreman hooks (not advised).

Are you using bare metal hosts, virtualization platforms ? When you said delete, you mean only delete foreman host or delete foreman host & delete virtual host itself ?

1 Like

So you want to utilize Foreman only for provisioning and then you manage it outside of Foreman so you want to keep the database clean?

Interesting, that sounds like an ad-hoc provisioning feature.

Anyway, we have a new plugin that you can use:

It is available with 2.5 tho. Here are WIP docs:

If you create a Build Exited hook you can then delete the host via CLI/API.

1 Like

For CI like use cases also take a look at GitHub - theforeman/foreman_expire_hosts: Foreman plugin for limiting host lifetime and GitHub - redhat-performance/quads: The infrastructure deployment time machine

The first is a plugin that adds the feature you are interested in. The second is a standalone project that uses Foreman as a provisioning engine and offers such usecase (if I’m not mistaken, it’s been few years sice I’ve seen it)