Skip to content

Commit

Permalink
Change in playbook and nodes with vagrant
Browse files Browse the repository at this point in the history
  • Loading branch information
prabhuvigneshkumarrajagopal committed Oct 7, 2016
1 parent 36d3154 commit 01842a9
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 24 deletions.
33 changes: 33 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"


config.vm.define "n1" do |n1|
n1.vm.hostname = "n1"
n1.vm.network "private_network", ip: "172.28.128.10"
end

config.vm.define "n2" do |n2|
n2.vm.hostname = "n2"
n2.vm.network "private_network", ip: "172.28.128.11"
end

config.vm.define "n3" do |n3|
n2.vm.hostname = "n3"
n2.vm.network "private_network", ip: "172.28.128.12"
end

config.vm.define "n4" do |n4|
n2.vm.hostname = "n4"
n2.vm.network "private_network", ip: "172.28.128.13"
end

config.vm.define "n5" do |n5|
n2.vm.hostname = "n5"
n2.vm.network "private_network", ip: "172.28.128.14"
end
end
1 change: 1 addition & 0 deletions consul_playbook.retry
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
172.28.128.15
172.28.128.16
69 changes: 47 additions & 22 deletions consul_playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@
roles:
- PrabhuVignesh.consul_installer

- hosts: all
sudo: yes

tasks:
- name: Joining consul each other
action: template src=template/consul.d/google.j2 dest=/etc/consul.d/ping.json mode=0777

- hosts: dbservers
sudo: yes
Expand All @@ -21,26 +16,19 @@
- name: creating script file
action: template src=template/scripts/agentrun.j2 dest=/tmp/agentrun.sh mode=0777

- name: Starting consul agent in background process
command: nohup /tmp/agentrun.sh
async: 9999999999999
poll: 0

- hosts: webservers
sudo: yes

tasks:
- name: Placing configuration file into the consul.d
action: template src=template/consul.d/adaptweb.j2 dest=/etc/consul.d/web.json mode=0755


- name: Installing real nginx
apt: name=nginx state=present

- name: creating script file
action: template src=template/scripts/agentrun.j2 dest=/tmp/agentrun.sh mode=0777

- name: Starting consul agent in background process
command: nohup /tmp/agentrun.sh
async: 9999999999999
poll: 0

- hosts: cacheservers
sudo: yes

Expand All @@ -51,18 +39,55 @@
- name: creating script file
action: template src=template/scripts/agentrun.j2 dest=/tmp/agentrun.sh mode=0777

- name: Starting consul agent in background process
command: nohup /tmp/agentrun.sh



- hosts: servers
sudo: yes

tasks:

- name: creating script file for servers
action: template src=template/scripts/serverrun.j2 dest=/tmp/agentrun.sh mode=0777

- name: consul agent -server -data-dir /tmp/consul -node={{ inventory_hostname }} -bind={{ inventory_hostname }}
command: consul agent -server -data-dir /tmp/consul -node={{ inventory_hostname }} -bind={{ inventory_hostname }}
async: 9999999999999
poll: 0

- hosts: all
- hosts: servers
sudo: yes

tasks:
- name: Joining consul each other
- name: join all servers togather
command: consul join {{ item }}
with_items: groups['all']
with_items: groups['servers']

- hosts: clients
sudo: yes
tasks:
- name: Downloading consul UI from official repo .
get_url: url=https://releases.hashicorp.com/consul/0.7.0/consul_0.7.0_web_ui.zip dest=/tmp/ui.zip mode=0777

- name: extract to /tmp/ .
command: unzip /tmp/ui.zip -d /tmp/
async: 1

- name: assigning permission for temp
file:
path: /tmp/
mode: 0777
recurse: yes

- name: delete the zip file
file: path=/tmp/ui.zip state=absent

- name: Starting consul servers in background process
command: consul agent -data-dir /tmp/consul -client {{ inventory_hostname }} -ui-dir /tmp -join {{ item }} -bind={{ inventory_hostname }}
async: 9999999999999
poll: 0
with_items: groups['servers']





4 changes: 2 additions & 2 deletions group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name_for_db: test_db
tag_for_db: test_db_tag
port_for_db: 80

name_for_web: test_web
tag_for_web: test_web_tag
name_for_web: nginx
tag_for_web: nginx
port_for_web: 80

name_for_cacheservers: test_cacheservers
Expand Down
7 changes: 7 additions & 0 deletions inventory
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
[others]
172.28.128.17

[servers]
172.28.128.15
172.28.128.16

[clients]
172.28.128.17

[all:vars]
ansible_connection=ssh
ansible_ssh_user=vagrant
Expand Down
1 change: 1 addition & 0 deletions template/scripts/serverrun.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
consul agent -server -data-dir /tmp/consul -node={{ inventory_hostname }} -bind={{ inventory_hostname }}

0 comments on commit 01842a9

Please sign in to comment.