Scheduled remote execution with variable

Hi, we are using Foreman with ansible. Remote execution is activated on every host. I want to know if it’s possible to run a remote command every time a new host is added to foreman.

OR

Run a scheduled job on every host but passing the hostname as a variable.
i.e : curl -H ‘https://www.blablabla.com?name=“host name variable of the remote host”’

I’m pretty new with foreman, the guys how built it just left the company.

Thanks!

Welcome @SudoBoomer !

These new hosts, how are they being added to Foreman?

In case you don’t know already, we have some docs here:

Foreman with Ansible for configuration management:
https://docs.theforeman.org/3.1/Configuring_Ansible/index-foreman-el.html

General host administration, REX, and config management docs here:
https://docs.theforeman.org/3.1/Managing_Hosts/index-foreman-el.html

We add host to Foreman with the subscription-manager command with passing activation key. We use foreman only to patch our Linux systems. We made the switch recently after Spacewalk announce EOL.

What I want to acheive is installing a nessus agent on every new linux host. The command is very basic but I don’t know how to automate that with Foreman

You should take a look at the new registration process and customize the linux host init template. That allows you to perform further customization as part of the registration process. If you already have hosts registered, the easiest way is to trigger the rex job on all of them.