Deploy Bundle for Simple Shell Script?

Latest response

I'd like to deploy a bundle to servers with a RHQ Agent installed to execute a shell command or run a shell script, but I'm a bit confused on how to do this after looking at the documentation.

Could someone provide an example deploy.xml or provide some direction on how to accomplish this?

Thanks.

Responses

To make sure that I understand, you are wanting to simply execute some command on a target platform by deployment a JBoss ON provisioning bundle?

Basically, you will use Ant's Exec Task in a preinstallTarget or postinstallTarget target.

...
  <rhq:bundle name="example-exec-bundle" version="1.0" description="A sample bundle demonstrating the use of the Ant exec task">
    <rhq:deployment-unit name="onlypretarget" preinstallTarget="executeCommand" compliance="filesAndDirectories">
        ...
    </rhq:deployment-unit>
  </rhq:bundle>

...

  <target name="executeCommand">
    <exec executable="ls" outputproperty="ls.out">
      <arg value="-l"/>
      <arg value="${rhq.deploy.dir}"/>
    </exec>
    ...
  </target>

Hope that helps.

Thanks, I'll give this a shot. Is the snippet that you posted what would go in a deploy.xml?

It looks like I got it, but I'm having trouble echoing the command output back into the "Details" section after deploying the bundle. Is it possible to readin the output to the command after it has been ran?

You can use the bundle task rhq:audit to produce output/status information that will appear in the bundle deployment status/detail view. For example:

    <rhq:audit status="SUCCESS" action="Run ls Command" info="Executed ls ${rhq.deploy.dir}" message="Output from ls command: ${ls.out}">
    </rhq:audit>

If you have more details you can also add them as the content of the rhq:audit element.

This is exactly what I needed. Thanks for the help!

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.