Rebuilding hosts via ansible

We’ve got an external ansible system that queries some external sources for expired systems that need to be rebuilt. I’d like to have it call to the foreman infrastructure to do builds/jobs and reset them.

documentation for the module is for creating/building.

My hosts are already created, will the same play work? or is there an alternative?

  • name: “Create a host with build context”
    username: “admin”
    password: “changeme”
    server_url: “
    name: “new_host”
    hostgroup: my_hostgroup
    build: true
    state: present

Honestly, not sure :wink:

I think this should put the host in build mode, but you’d still need to reboot it and make sure it boots from Foreman (and not from local disk) to actually re-provision it.

Thanks @evgeni

the reboot would most likely be a second step in the playbook to reboot via power job template… (I hope!)

My work has some “research” servers that researchers do a bunch of tests on… I’d need to do a workflow to pull relevant data from server, apply a rebuild, reboot, and apply some custom “researchy” configs to them.

Ya know… some type of workflow/task sequencer for items in foreman jobs/builds/runs/etc would be really worthwhile.