Automating Apache Cloudstack Deployments with Ansible

I wrote a post awhile back about using node.js, ansible, and python to do my apache cloudstack installation. Ansible is great but I basically used python to make using ansible a bit more easy since there are a few things with any ansible setup which needs to be remembered. One of those things is the ansible hosts that gets used. This could be the default file found in /etc/ansible/hosts or any file of your choose when using the “-i” option. Then there are the variables which have to be dealt with. I happen to use a file in this case because it’s easy to edit pragmatically. You could edit both of these files manually but mistakes can be made and you have to remember what to edit. As I get older this becomes harder and harder. Plus I get the added bonus of being able to hand over a solution that someone else can run without the worry of them screwing it up. Well, at least the screw up potential is low. Enough talking about it, let’s get into my process.

First thing I do is install the dependencies for the main deployment system with ansible and node.js. This only needs to be done once in each environment as long as the main system can reach the remote servers. I’m doing all my installations on CentOS 6.5 and that includes the main deployment system. I’ll be using VMs during this exercise to make the demonstrations easy for me. You can install ansible and node.js on other platforms but I will not show it but there are great resources out there that can help you out. Here is what my example environment looks like.

6x CentOS 6.5 linux VMs using VMware Fusion 6.0.2 and they are all on the same network and accessible via SSH.
- ansible - used to install ansible and node.js
- cldstkdbsrv01 - primary mysql server
- cldstkdbsrv02 - replica mysql server
- cldstkwebsrv01 - cloudstack management server
- cldstkwebsrv02 - cloudstack management server
- cldstkkvm01 - cloudstack agent - KVM host

Step by Step

  1. Because I’m using virtualization I must expose the cpu features needed for KVM. This can be found in the Settings > Processors & Memory section in VMware Fusion. If I had physical hardware I’d need to make sure my processors were compatible.
  2. Log into the ansible server (main deployment server)
  3. Then I install ansible but first I’ll have to configure EPEL. This can be done by running this command rpm -Uvh
  4. Now that EPEL is installed and configured, run yum install ansible -y
  5. Now I install node.js, run yum install npm -y
  6. I then copy over the cldstk-deploy folder using scp, run scp -r cldstk-deploy_3 [email protected]:/tmp/cldstk-deploy_3/
  7. Test that ansible is installed and working, run ansible.
  8. Test that node.js is installed and working, run node.
  9. Now I update the /etc/hosts file with the targeted systems because I do not have DNS configured.
  10. Let’s run cldstk-deploy, run python This is a python script that except inputs that are needed for the deployment and ansible-playbooks used on the backend.
  11. Do not “Start the installation”! So type ‘n’ when asked. I want to something first that you’ll see in a couple of steps.
  12. This created and populated the ‘ansible/hosts’ and ‘ansible/vars_file.yml’ files with what was entered in the prompts.
  13. Lets test that ansible can connect to the systems, run ansible all -i ansible/hosts -m setup -k.
  14. The first time this is run it will ask “Are you sure you want to continue connecting (yes/no)?”, just type ‘yes’.
  15. You can run another test to valid which systems are in the ansible hosts file, run ansible all -i ansible/hosts -m setup -k | grep ansible_hostname
  16. Now we can run the install with python -i
  17. This will start the node.js express server and run the ansible-playbooks.

This process runs through a few ansible playbooks. Here’s a high level process flow in order:
- create-cloudstack-repo.yml # basically edited with the main deployment servers ip address for the cloudstack package repository
- hostfileupdate.yml # used to add all the systems the /etc/hosts file on each system
- mysql-server-install.yml # used to install mysql server
- cloudstack-mgmt_deploy.yml # used to install Cloudstack Management servers
- mysql-replication-setup.yml # used to install and configure replication for mysql server for redundancy
- cloudstack-agent_deploy.yml # used to install Cloudstack Agent servers
- cldstk-install-sys-tmpl.yml # preseeds the system templates

When this process completes all the components are installed and configured so you can login to the Cloudstack Management server. It currently does not add or setup the cloudstack agent servers into a cluster in a Cloudstack zone so this is a manual process for now as there are to many variables to contend with.
Check out the video showing all the things outlined above.

[vsw id=”fqQd6K6iLMg” source=”youtube” width=”425″ height=”344″ autoplay=”no”]


Add yours
  1. Oded

    I used the latest version from github and half way through the install i received the following error:

    PLAY RECAP ******************************************************************** : ok=11 changed=5 unreachable=0 failed=0 : ok=48 changed=24 unreachable=0 failed=0 : ok=22 changed=16 unreachable=0 failed=0

    /usr/lib64/python2.6/site-packages/pycrypto-2.6.1-py2.6-linux-x86_64.egg/Crypto/Util/ PowmInsecureWarning: Not using mpz_powm_sec. You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.
    _warn(“Not using mpz_powm_sec. You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.”, PowmInsecureWarning)

    a google search got me to a known bug in ansible ??

Comments are closed.