Managing RabbitMQ with Puppet
In my last post I have performed all the steps necessary for installing and configuring RabbitMQ on CentOS 6.2. I did that the old fashioned way by using the command line and typing everything step-by-step.
When installing RabbitMQ on a new box, I would have to do it all over again.
Great times we are living in! There are mechanisms that fully automate those steps. I have already written about Puppet in another blog post and today we are going to use that knowledge to create a Puppet configuration for RabbitMQ. So, let’s start.
I have also created a project where I will keep all the configuration from now on. Get it with
{% highlight none %} git clone [email protected]:tobias-wissmueller/dev_ops_central.git cd dev_ops_central {% endhighlight %}
Let’s add your box first if you don’t have it anymore.
{% highlight none %} vagrant box add dev_ops_central_box <path_to_your_box>/package.box {% endhighlight %}
Set permissions on the ssh key and fire up the box.
{% highlight none %} chmod 0600 id_rsa.vagrant vagrant up vagrant ssh {% endhighlight %}
In your box create the following directory and file structure in the directory /vagrant
.
Am not going to list the contents of all files but instead redirect you to my repository for this project on GitHub where you get the complete stuff. In case you did the very first step and cloned my repository you already have everything on your local machine. Since I will continue working on that branch and you want to get the same version I have committed after this post, don’t worry, I tagged the commit with the label ‘managing_rabbitmq_with_puppet’.
Now go into /etc/puppet
as root
and remove the manifests directory
{% highlight none %} sudo bash cd /etc/puppet rm -rf manifests/ {% endhighlight %}
Now create some symbolic links to your puppet configuration.
{% highlight none %} ln -s /vagrant/manifests ln -s /vagrant/modules {% endhighlight %}
Again we are having a brownfield here. Removing that directory and creating those symbolic links should have been done before packaging up the box, but we could also do that with puppet of course.
Let us continue with adding everything to our configuration we need for RabbitMQ. This time my thanks goes to Rob Harrop from First Banco who wrote an excellent post with the title “Automating Development VMs with Vagrant and Puppet”. Yes, that’s the same I am doing here, but I need to do it on my own and write about it to get a deeper understanding of it.
I took the whole configuration and changed a few version numbers here and there. After that, I triggered the provisioning process with
{% highlight none %} puppet apply –verbose manifests/site.pp {% endhighlight %}
Additionally I stopped the firewall with
{% highlight none %} /etc/init.d/iptables stop {% endhighlight %}
I have included that in my puppet configuration as well, so if you are using my code there is no need to execute the above statement.
Like in my last post I have checked the whole thing by pointing the browser from my host system to the RabbitMQ Management Center on my vagrant box by using the following URL http://localhost:55672
and logged in with username guest
and password guest
.
What I am not going to do here is the SSL configuration. I will leave that for another time since I have no use for it right now.
We are one step further now in automating our infrastructure. In case we mess something up we just need to destroy and build up our box and everything will be fine again. Try it out and exit your box and then do the following
{% highlight none %} vagrant destroy && vagrant up {% endhighlight %}
That will take a while. Anyways, time to get some coffee and when you are back, a fresh box will be waiting for you.
Done for today!