I am going to show you how to setup the environment on a virtual box environment using vagrant.
For that, you can use the below vagrant file for creating 3 machines.
ACS(Ansible control server)
web(web server)
db(database server)
For demonstration, I use three different boxes for these machines.
You can watch my Vagrant related posts to see in more detail about above file.
Once the above VMs are ready.
To connect to a VM, use vagrant ssh <machine_name>
vagrant ssh acs ---> to connect to acs vm
it opens the acs machine console.
sudo apt-get install ansible --> This will install ansible
apt-get is for debian machines, Let's try on centos machine.
vagrant ssh web
For centos before ansible we need to install enterprise release package as prereq to ansible.
sudo yum install epel-release
sudo yum install ansible
Instead of package managers like apt-get or yum, we can use direct python code to install ansible.
Below is the procedure.
vagrant ssh db
#install gcc first
sudo yum install gcc
#python setup tools
sudo yum install python-setuptools
#python index packager, through python-setuptools
sudo easy_install pip
#python development library
sudo yum install python-devel
#ansible
sudo pip install ansible
For that, you can use the below vagrant file for creating 3 machines.
ACS(Ansible control server)
web(web server)
db(database server)
For demonstration, I use three different boxes for these machines.
Vagrant.configure("2") do |config| config.vm.define "acs" do |acs| acs.vm.box = "ubuntu/trusty64" acs.vm.hostname = "acs" acs.vm.network "private_network", ip: "192.168.33.10" end config.vm.define "web" do |web| web.vm.box = "nrel/CentOS-6.5-x86_64" web.vm.hostname = "web" web.vm.network "private_network", ip: "192.168.33.20" web.vm.network "forwarded_port", guest: 80, host:8080 end config.vm.define "db" do |db| db.vm.box = "nrel/CentOS-6.5-x86_64" db.vm.hostname = "db" db.vm.network "private_network", ip: "192.168.33.30" end end
You can watch my Vagrant related posts to see in more detail about above file.
Once the above VMs are ready.
To connect to a VM, use vagrant ssh <machine_name>
vagrant ssh acs ---> to connect to acs vm
it opens the acs machine console.
sudo apt-get install ansible --> This will install ansible
apt-get is for debian machines, Let's try on centos machine.
vagrant ssh web
For centos before ansible we need to install enterprise release package as prereq to ansible.
sudo yum install epel-release
sudo yum install ansible
Instead of package managers like apt-get or yum, we can use direct python code to install ansible.
Below is the procedure.
vagrant ssh db
#install gcc first
sudo yum install gcc
#python setup tools
sudo yum install python-setuptools
#python index packager, through python-setuptools
sudo easy_install pip
#python development library
sudo yum install python-devel
#ansible
sudo pip install ansible
No comments:
Post a Comment