How to execute remote commands with Katello 2.3 and 2.4 on remote clients




This can be achieve installing the following foreman plugin
http://theforeman.org/plugins/foreman_remote_execution/0.0/

Start by installing  repository and EPEL7, see Quickstart instructions and Foreman manual for more information.
 
After it sucessfully finishes you'll have to manually install plugins by following command
 
yum install ruby193-rubygem-foreman_remote_execution rubygem-smart_proxy_remote_execution_ssh

Note : the plugin only works if you satellite was install on RHEL7/Centos 7 for Katello


after that you going to have job
 
templates in hosts tab just create a new job template for example
 
Template that allow install remove and update packages
 
Name: Package Actions

die() {
echo "${1}, exiting..."
exit $2
}
<% unless input("pre_script").blank? -%>
# Pre Script
<%= input("pre_script") %>
RETVAL=$?
[ $RETVAL -eq 0 ] || die "Pre script failed" $RETVAL
<% end -%>
<% if @host.operatingsystem.family == 'Redhat' -%>
yum -y <%= input("action") %> <%= input("package") %>
<% elsif @host.operatingsystem.family == 'Debian' -%>
apt-get -y <%= input("action") %> <%= input("package") %>
<% end -%>
RETVAL=$?
[ $RETVAL -eq 0 ] || die "Package action failed" $RETVAL
<% unless input("post_script").blank? -%>
# Post Script
<%= input("post_script") %>
RETVAL=$?
[ $RETVAL -eq 0 ] || die "Post script failed" $RETVAL
<% end -%>
 
Go to job tab
 
Job name:Package Actions
Provider type:sshexecutorprovider
Name: pre-script
input type:user input
 
Description: pre-script before package install update or remove
Name: package
input type:user input
 
Description: name of the package
Name: action
input type:user input
 
Description: The package action: install, update, or remove
Name:post-script
input type:user input
 
Description: Post script needed after package installed,removed or update
 
After this save the template and go to hosts-->all hosts tick the host that you want to apply the job and in the top right side next to new host button is going to appear a new button select action just click there and click run job
 
Choose the job name and provide any input necessary for the job complete.
with this you can deploy any command to the host via ssh as remote commands.

Comments

Popular posts from this blog

How to clean all the foreman task and locked task

CentOS 7 Server Hardening Guide

How to restrict users to send only mail to the local domain in Zimbra