puppet remote command execution without agent configuration - puppet

Which puppet module to used (How to configure), so that it can execute command in the remote machine, without using any puppet agent
for example from HOST-A, a puppet script to be executed and it takes the command and execute the command in HOST-B
what i know is the openssh keys can be used to exchange the login info, then after the command can be executed, what i'm missing is is there any module available that do this job, so that, just adding the command the same can be achieved
This is coming from the ANsible background

You maybe looking for mcollective/live management feature of puppet which allows you to run ad-hoc commands on the nodes. However you will have to install mcollective agents on all the nodes being managed any ways.
If you compare it with Ansible, puppet does not support running ad-hoc commands inherently otherwise. It does not work over ssh like ansible does. Its not agentless by nature. You need puppet agent/apply to be installed and configured.

There is no built in way of achieving this, but you can use exec to execute ssh with a command to run on another machine. The command to execute would be the same as what you would use from the shell.

you need jump out from the pit what you know about Ansible when thinking of puppet, they are different.
Puppet works for final status called idempotency, ansible is as batch ssh scripts.
The rest, #Gourav has been explained clearly.

Related

Bash Script Fails During Jenkins Build But Does Not Fail Locally

I've been trying to debug this issue all day with no success.
Issue: Bash script executes successfully on a Linux CentOS7 VM (jenkins build agent) but fails during Jenkins build.
Here's the simple script.
#! /bin/bash
echo "before beyond compare command"
bcompare #"bc_report.ps1" "./Output_Base/<Folder_Name>" "./Output_Compare/<Folder Name>" "Report.html"
echo "after beyond compare command"
The output in the Jenkins build log is just:
before beyond compare command
after beyond compare command
When viewing the VM during the Jenkins build, I'm not seeing an artifact being produced. The user during the Jenkins build is Root, when executing the script locally, I'm also doing so as Root with success.
I'm pretty sure this is a Jenkins issue, just can't seem to figure it out. Anyone seen something similar?
Beyond Compare 4 for Linux requires an X-Window/GUI session to run, even for scripts. As a cron job or in an SSH terminal without an X-Window client, Beyond Compare for Linux scripts will fail to run. This might be what is causing your Jenkins job to fail.
Beyond Compare 4 for Windows doesn't have the GUI session requirement for scripts. Beyond Compare 4 for Linux and macOS both require a GUI session for scripts. Removing the GUI session requirement for scripting on Linux and macOS is on the feature request list for a future version.

What is the best method to execute script on remote via Jenkins

Am looking for the best & proper method to execute script on remote via Jenkins job.
What is better:
Write the commands directly on the Jenkins "Exec command" label on the "Send files or execute commands over SSH" tab.
Just copy a bash file to the remote and execute it through Jenkins "Exec Com.." label command.
The reason I'm asking this question is because I am struggling with the second approach (i.e. execute local file which located on the remote...) and thinking maybe that not the best practice.
In addition, should I execute the script using sudo (because running as sudo causes me gitlab issues when try to clone..).
And when I am execute the the script he ask for password.
So far added permissions to /etc/sudoers not do the job but I'm thinking maybe that's a tab/lines issue...possible ?
Any suggestions ?
I personally would go for SSH protocol approach (Simple, secure and reliable). Moreover, there are some plugins already made for those use cases you've mentioned.
1. SSH plugin
You can use the SSH Plugin to run shell commands on a remote machine
via ssh.
So this plugin would fit into your first option of executing script or commands on remote via SSH.
2. Publish Over SSH Plugin
The goal of the Publish Over plugins is to provide a consistent set of
features and behaviors when sending build artifacts ... somewhere.
The Publish over SSH plugin will allow you copy files to a remote server and execute arbitrary commands on the remote server. So this fits into your second approach where you want to first copy script and then execute.
Really you can use any of those plugins (Both use SSH so it's more secure). The question is what suits you the most. Choose wisely :)

How to remotely control Trace32 via Terminal

I have an automated Linux agent (CentOS) with Bamboo to aid in building and deployment of new software onto a board. I want to be able to run .cmm files via Trace32 and a Lauterbach onto my locally located board using the remote Bamboo agent to trigger daily builds and deployment.
I am aware of the terminal command option: ./trace32 -s file.cmm to avoid using the GUI.
Is there anyway I can use this kind of thing for remote deployment, perhaps utilising ssh?
There is no SSH server in TRACE32. However you can control TRACE32 remotely via the TRACE32 remote API. See the document "api_remote.pdf" in the PDF folder of your TRACE32 installation.
To launch some scripts or execute some simple commands from a bash shell, you can use the command line tool t32rem from the <t32>/bin/linux folder.
This tool uses the TRACE32 remote API to send TRACE32 commands to open TRACE32 GUIs.
Do the following:
Enable the TRACE32 remote API to add the following two lines to your TRACE32 configuration file (usually "config.t32")RCL=NETASSIST
PORT=20000 You have to ensure that there is an empty line before and after these lines in your configuration file.
Launch TRACE32 and send a command to it with t32rem like that: t32rem localhost port=20000 <command> For <command> you can choose any TRACE32 command like DO file.cmm to execute your mentioned PRACTICE script.
For more complex remote control of TRACE32 (e.g. from a Python script) you should have a look at the previously mentioned "api_remote.pdf" and the examples at <t32>/demo/api.
When you already have a command to run, how about using a Script task in your plan, so that you can execute the command you wanted?

Running a terminal command permanently

I am currently hosting my database for free on Openshift and have my program running on a linux box on my local server. I need to pass the data from the program to my openshift database. I want to run the linux box headless.
To do this I run the command:
rhc port-forward -a webapp
My question is how can I run this command permanently without it timing out (some checking to see if process is running?) and without a terminal running (background process)?
You could add that command in the startup settings of your Linux computer. So a systemd configuation, or an init one (details could depend upon your particular distribution and system). See systemd(1) and/or sysvinit
You could also use crontab(5). It can be used for periodic tasks, but also for started once tasks, thru some #reboot entry.
At last, you might use batch facilities, look into at (& batch)
Perhaps you may just want nohup(1) (or screen(1)...)

Can Jenkins run shell script on agent-less linux host

I am looking for a Jenkins plugin that makes it execute simple shell script into a given machine.
A possible execution of this plugin would be:
Given hostname,username,password, execution folder, and script --> connect to the machine and execute the script.
Can I do it without pre-configuring the machine as Jenkins slave?
I've checked out ssh-plugin and publish-over-ssh but they don't offer doing such thing without preconfiguring the hosts.
So I couldn't find the right built-in solution for Jenkins but Python Fabric is an interesting direction

Resources