It’s quite sometime since RHEL/CentOS 7 (2014-06-09) was released so a few days ago I thought I should try it out and maybe create a KVM Guest template in case I need it in the future.
I have been trying to create a simple bash script for copying/configuring KVM guests using templates.
This way I don’t need to do the whole installation over and over again.
The script would use an already KVM image file copy it to a new image file, mount it change the hostname and network settings. It would also copy the xml file remove the uuid, change its name and define it with virsh command.
I have been curious to see how chef attibutes priority is working. So I decided to do a simple experiment. I have been using wrapper cookbooks after I read this amazing post from Jamie Winsor http://blog.vialstudios.com/the-environment-cookbook-pattern/ and this post from Doug Ireton http://dougireton.com/blog/2013/02/16/chef-cookbook-anti-patterns/.
Today I decided to test the chef development kit. Chef released chefdk 0.3.6 version on 2015/01/20. Till now I used to install and upgrade chef manually installing all required gems. What I found out is that knife ec2 plugin is not bundled with chefdk so you ‘ll have to install it yourself which is not very difficult. You only need to execute the following command
$ /opt/chefdk/embedded/bin/gem install knife-ec2
Recently I have been trying to cut off expanses in one of the projects I ve been working. So we decided to move two of the t1.micro ec2 AWS instances to our dedicated server,which was already hosting VMS for other projects, as one KVM guest. First instance was the production MySQL DB server for the project while the other was the webserver(apache) hosting our php application. I thought it would be great to have the whole migration automated with chef in case we need to migrate later back to AWS or to another dedicated server.
Let’s say you wish to set the memcached CACHESIZE variable based on your system’s(node) memory.
By default CACHESIZE is defined as 64MB. You get the nodes total memory using the node[‘memory’][‘total’] which will return the memory in KB for example 1019492kB In this case you need to divide it with 1024 to get the size in MB. If you want to assign 10% of your total memory to memcached CACHESIZE then you ll have 1019492kB * 0.1 / 1024 = 99.559MB. You can remove the .559 using ruby’s to_i method.
So you can put the following in your cookbook to set your memcached cachesize. The only dependency is opscode memcached cookbook
node.set['memcached']['memory'] = (node['memory']['total'].to_i * 0.1 / 1024).to_i include_recipe 'memcached'
I ve been using KVM for virtualization. Sometimes we need to resize our VM’s disk. We can either expand or shrink. Below I am going to describe how we can do it.
I have been using vagrant to develop chef cookbooks. Vagrant is a tool for managing virtualized development environments. When vagrant was initially launched supported VirtualBox only. As vagrant matured more providers were added like VMWare, AWS, Docker etc. I prefer using vagrant with its default provider, VirtualBox. I use vagrant 1.6.3 with ruby 1.9.3p547 on my Ubuntu 12.04 Lenovo U410 ultrabook.
My name is Dimosthenis Karagiannis but since I remember myself everybody calls me Dimos. So it would be more logical to use dimoskaragiannis than dimokaragiannis – the difference is just an (s). The reason that I ‘ve picked the latter is because of twitter’s limit on max length for its usernames. I have a pretty big name and surname and even if I used my short name (Dimos) and surname I would still exceed twitter’s limit. I would have picked dimka(nickname that I got on my first year in university which was given to me by the Computer’s Lab of Physics School,Aristotle University of Thessaloniki automatic system) but this was very common and already taken in both twitter.com and wordpress.com