<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Unix HOWTOs and Tips &#187; Automation</title>
	<atom:link href="http://blog.bulsynt.org/category/utils/automation/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.bulsynt.org</link>
	<description>Short unix command line administration tips and scripts</description>
	<lastBuildDate>Wed, 30 Oct 2019 07:51:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Execute identical commands in all running OpenVZ containers on a hardware host</title>
		<link>https://blog.bulsynt.org/2014/07/11/execute-commands-in-all-openvz-containers-on-a-hardware-host/</link>
		<comments>https://blog.bulsynt.org/2014/07/11/execute-commands-in-all-openvz-containers-on-a-hardware-host/#comments</comments>
		<pubDate>Fri, 11 Jul 2014 09:12:45 +0000</pubDate>
		<dc:creator>Delyan Angelov</dc:creator>
				<category><![CDATA[Automation]]></category>
		<category><![CDATA[OpenVZ]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Utilities]]></category>

		<guid isPermaLink="false">http://blog.bulsynt.org/?p=166</guid>
		<description><![CDATA[Suppose, that you have to execute some identical commands on all your running OpenVZ containers. For example you may want to check their disk usage, or ban an IP on all of them, or force a restart of their webserver for some reason. Typing the same commands over and over again is tiresome, and error [...]]]></description>
			<content:encoded><![CDATA[<p>Suppose, that you have to execute some identical commands on all your running OpenVZ containers. For example you may want to check their disk usage, or ban an IP on all of them, or force a restart of their webserver for some reason. Typing the same commands over and over again is tiresome, and error prone.  Suppose also, that you do not have an automated system like <a href="http://www.ansible.com/" title="Ansible" target="_blank">Ansible</a> already (which by the way, I highly recommend) ...</p>
<p>Do not worry, just follow these steps:</p>
<p>1) Save the following script as allvpses_do, somewhere on your PATH, and make it executable:</p>
<pre class="brush:bash">
#!/bin/bash

THECMD=$*

for i in `vzlist -o veid -H|  xargs`; do
   echo "============================  VPS: $i: CMD: $THECMD ===================================";
   echo "$THECMD" | vzctl exec $i - | grep --line-buffered -v 'Executing command:' | sed -e "s@^@VPS $i: @gm"
   echo;
done
</pre>
<p>2) Run a test command like this:</p>
<pre class="brush:bash">
allvpses_do uptime
</pre>
<p>... or, you can try:</p>
<pre class="brush:bash">
allvpses_do 'iptables --list -nv|grep DROP'
</pre>
<p>3) Enjoy your puppet master powers <img src='https://blog.bulsynt.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>https://blog.bulsynt.org/2014/07/11/execute-commands-in-all-openvz-containers-on-a-hardware-host/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
