I have just started to look into using Ansible for automating some of the tasks we current use on customer infrastructure, from VM template deployment to the install/configure of bespoke applications within the VM.
For my testlab i though i would install ansible and the relevant VMware required modules like Python SDK for VMware and pyvmomi. I also installed AWX to provide a GUI for the task scheduler and to better understand how Ansible Tower works.
To get started with the installation we deploy a simple unbuntu 8.04LTS server using the default options (The VM specs are 2vcpu 16GB ram and a 120GB VMDK). I then ran through the process below to get ansible/AWX and of course Vmware SDK for Python installed. We have a number or requirements as we are running AWX in a docker (it should be noted that i prefer to put this in /opt but that a personal thing)
1 2 3 4 5 6 7 8 9 10
| apt-add-repository --yes --update ppa:ansible/ansible
apt install ansible -y
apt install docker.io
apt install python-pip -y
pip install docker
pip install docker-composer
apt install nodejs npm -y
npm install npm --global
cd /opt
git clone https://github.com/ansible/awx.git |
At this stage we can install AWX however if we were to use the default options the postgress data would be placed in /tmp which means it would be reset every reboot and we would loose out current configuration, as shown below I prefer to edit the inventory and put it to /opt/pgdocker. (again this is personal choice and you can put it anywhere you want)
1 2 3 4 5
| cd /opt
mkdir pgdocker
cd awx/installer
edit inventory change postgres data files location to /opt/pgdocker
ansible-playbook -i inventory install.yml |
You should now be able to visit http:\\(your servername) and login with a username of admin and a password of password
Next we want to install the VMware SDK for python and pyvmomi for ansible.
1 2 3 4 5 6
| cd /opt
clone https://github.com/vmware/vsphere-automation-sdk-python.git
cd vsphere-automation-sdk-python
pip install --upgrade --force-reinstall -r requirements.txt --extra-index-url file:///opt/vsphere-automation-sdk-python/lib
pip install pyvmomi |
Congrats you now have Ansible/AWX/Python all ready for working with Vsphere.
I will be doing an article covering some of the basics of using Ansible and VMware together in another post.
Recent Comments