This example illustrates how the SSH plugin can be used to configure the proxy settings for YUM in the likely event that your servers accesses the internet through a company proxy.
This example expands the How-to: Install YUM packages example, which illustrated how to define resources for enabling usage of the SSH plugin, define credentials for authentication and create the module which installs YUM packages.
This example is included in the default configuration created by Pineapple, so there is no need to create it by hand.
The created module in the How-to: Install YUM packages example was named ssh-002-install-yum-packages. In this example we will start off with a copy of that module, but naming it ssh-003-configure-yum-proxy and expand it on two ways:
Add the configuration file fragment to the module:
# Proxy setting added by Pineapple proxy=http://bossproxy:3128/
The ssh-003-configure-yum-proxy module now has the structure:
ssh-003-configure-yum-proxy | +--- bin | +--- yum.conf.fragment +--- models +--- linux-vagrant.xml
Add these five lines to the model file name linux-vagrant:
<shp:copy-to source="modulepath:bin/yum.conf.fragment" destination="/tmp/yum.conf.fragment"/> <shp:execute command="sudo mv /etc/yum.conf /tmp/yum.conf.backup" /> <shp:execute command="sudo cat /tmp/yum.conf.backup /tmp/yum.conf.fragment >> /tmp/yum.conf" /> <shp:execute command="sudo cp /tmp/yum.conf /etc/yum.conf" /> <shp:execute command="sudo cat /tmp/yum.conf.fragment >> /tmp/yum.conf" />
The result being:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <mmd:models xmlns:mmd="http://pineapple.dev.java.net/ns/module_model_1_0" xmlns:shp="http://pineapple.dev.java.net/ns/plugin/ssh_1_0" > <mmd:model target-resource="regex:ssh-node.*"> <mmd:content> <shp:ssh> <shp:copy-to source="modulepath:bin/yum.conf.fragment" destination="/tmp/yum.conf.fragment"/> <shp:execute command="sudo mv /etc/yum.conf /tmp/yum.conf.backup" /> <shp:execute command="sudo cat /tmp/yum.conf.backup /tmp/yum.conf.fragment >> /tmp/yum.conf" /> <shp:execute command="sudo cp /tmp/yum.conf /etc/yum.conf" /> <shp:execute command="sudo cat /tmp/yum.conf.fragment >> /tmp/yum.conf" /> <shp:execute command="sudo yum --assumeyes install unzip" /> <shp:execute command="sudo yum --assumeyes install chkconfig" /> <shp:execute command="sudo yum --assumeyes install nano" /> <shp:execute command="sudo yum --assumeyes install curl" /> </shp:ssh> </mmd:content> </mmd:model> </mmd:models>
The added five lines copies the configuration fragment file to each accessed host. The fragment is then appended to the YUM configuration file /etc/yum.conf.
Finally, the commands in the model is executed using sudo. The requirement for sudo depends on the privileges of the user used by the SSH plugin to connect to a given host. The users was defined in credentials file in the previous section.
Start your Pineapple client of choice: