Well I would like to know if there is way to use to the Remote Execution Plugin to orchestrate the patching of a server and its after restart with out losing the control of the Job and see it as failed task. As you could see at the screenshot below.
Any other idea as an alternative is great as well.
Fix for the
uninitialized constant is merged into upstream REX core, but wasn’t relesed yet. However you can quite easily patch it by hand, see
https://github.com/theforeman/foreman_remote_execution/commit/49f59f9a614197cab26c2f80cff80ac844e5ff6f . Just add the line into
Another way to approach it would be to use the Power Action template which ships with REX instead of just putting “reboot” at the end of the script.
<%= render_template("Power Action - SSH Default", :action => "restart" %>
Even with this in place the job may still fail under certain circumstances, so I’ve seen people cloning the power action template and replacing its contents with the following and using the clone instead.
echo <%= input('action') %> host && sleep 3
<%= case input('action')
'shutdown -r +1'
'shutdown -h now'
Hi Adam, thank you for your quick answer. I am going to try both options and I will share with you my results and thoughts.
Once again, thank very much you were so helpful to me.
Hi again Adam,
Using the option you suggested of rendering the power action template for restarting the server at the end of my script works perfectly.
But now, and as I meant with not losing the control of the job during the server restart i would like to continue executing tasks aftrr the reboot of the sever as post reboot tasks in the same job.
To check for instance the server fulfill some requirements fter the reboot. Like checking for up and running services, etc…
Is this possible, to make the job wait for the server come to live again without failing?
sadly what you’re describing is not possible so far and has to be done by running a follow-up job by hand after the first one finishes. We have an issue for tracking this feature, but as far as I know noone started working on that yet.
Feature #15872: Ability to monitor whether a host is up or not, after a reboot through the remote execution feature. - Foreman Remote Execution - Foreman
Ok. I see… Thank you for your help.
I will try to implement my solution using the Ansible, but first I have to make the Ansible plugin works.
Again, thank you so much.
I don’t intend to hijack your thread but since we are discussing remote execution here, can you please tell what type of remote execution you have tried so far?
Also, can you please point me to a documentation for setting up remote execution? There are few versions of the remote execution plugin and I got confused about what to pick up and what not to.
Yes sure, don’t worry.
First of all,the remote execution plugin’s installation documentation I am using is the one belonging to version 1.3.
And about your other question, I just want to run a script which patch the the target server, reboot it and then perform some post-booting tests on the server as part of the same job.
February 26, 2018, 3:03pm
Yes, REX is legging that feature it cannot wait till reboot finishes even there are no email notifications for Job results.