Friday, November 13, 2015

Running Ansible on Vagrant

0 lượt xem comment 0 comments

On the previous post i was talking about how to run Ansible on AWS.  IF you dont have acess to AWS or your solution runs on bare metal you still can run ansible on Vagrant and have an environment to test your playbooks.

Once you download and install Vagrant, you just need pick up my vagrant file and them you ready to have ansible running :-)

So you download the Vagrantfile and put it into a directory in your machine, them you gonna run:

$ vagrant up
$ vagrant ssh 

That`s it, you are ready to have fun. Keep in mind for this vagrant file im using a shared folder where im putting my playbooks, if you dont want this just comment the line on the Vagrantfile.

From Vagrant 1.7.2 to Vagrant 1.7.4 there was some issues with Windows and RSYNC, if you having this kind of trouble, follow this instructions and you will be able to run on windows without issues.

If you want my sample playbook, check it out on my GitHub. Once you are into the box via SSH, you can just do:
$ ansible-playbook book.yml

# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
config.vm.provider "virtualbox"
config.vm.provider "virtualbox" do |vb|
end
config.vm.box = "bento/centos-7.1"
config.vm.network "private_network", ip: "55.55.55.150"
config.vm.synced_folder ".", "/home/vagrant/shared/"
config.vm.provision "shell", inline: <<-SHELL
#
# Update and install basic linux programs for development
#
sudo yum update -y
sudo yum install -y wget
sudo yum install -y curl
sudo yum install -y vim
sudo yum install -y git
sudo yum install -y build-essential
sudo yum install -y unzip
#
# Install Ansible
#
cd /usr/local/src
sudo yum -y install git python-jinja2 python-paramiko PyYAML make MySQL-python
sudo git clone https://github.com/ansible/ansible.git
cd /usr/local/src/ansible
sudo git submodule update --init --recursive
sudo make install
sudo echo "[localhost]" > ~/ansible_hosts
sudo echo "localhost ansible_connection=local" >> ~/ansible_hosts
export ANSIBLE_INVENTORY=~/ansible_hosts
SHELL
end
view raw Vagrantfile hosted with ❤ by GitHub
Cheers,
Diego Pacheco
Tags: update, Windows,

comment 0 comments

Chuyên mục văn hoá giải trí của VnExpress

.

© 2017 www.blogthuthuatwin10.com

Tầng 5, Tòa nhà FPT Cầu Giấy, phố Duy Tân, Phường Dịch Vọng Hậu, Quận Cầu Giấy, Hà Nội
Email: nguyenanhtuan2401@gmail.com
Điện thoại: 0908 562 750 ext 4548; Liên hệ quảng cáo: 4567.