How to automate application installation in virtual machine?

956 views Asked by At

Using Open Nebula I have instantiated several virtual machines (qemu-kvm) with the Centos 6.5 image provided by Open Nebula Marketplace. Now I would like to install more applications on VMs and run some postscripts also. Although I could do this by doing ssh over each vm, but I would like to automate the process.

1

There are 1 answers

2
lucorlis On BEST ANSWER

We use Salt (http://www.saltstack.com) for exactly that.

Through some more or less complex configuration-files, you can have the machines automatically install software, configuration-files, users, ssh-keys, ...

You could for example set a rule, that any VM, who's FQDN starts with "web" has to install httpd.

Alternatives are Puppet (https://puppetlabs.com), Chef (https://www.chef.io/chef/), Ansible (http://www.ansible.com/home) and potentially a few others.

For the installation of Salt, we use an additional context-script in the VM (note, you'll have to add 'init.sh' and the other context-script), that takes care of the installation of the minion. The script looks somewhat like this (replace ##salt-master-FQDN## with the salt-master IP or fqdn):

#!/bin/sh

if [ ! -f /etc/salt/minion ]; then
    yum clean all
    yum -y update
    yum -y install salt-minion
    sed -i '/master:/c\master: ##salt-master-FQDN##' /etc/salt/minion
    systemctl enable salt-minion.service
    systemctl start salt-minion.service
fi