Skip to content

Commit

Permalink
Service discovery script added under utilities and README also modified
Browse files Browse the repository at this point in the history
  • Loading branch information
arnabsinha4u committed Jan 26, 2017
1 parent 726dfc0 commit 6812c59
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,19 @@ System already baselined, just startup the lab with defaults (creates 1 ansiblel
./ansible_lab.yml --tags=users,group,m_startup
```

Execute the service discovery script that will modify the hosts file in the masters to discover and use the slaves via hostnames. Its a parameterized script where the number of masters and slaves can be passed as the first and second parameter respectively. Docker Network can be created and containers can be tagged for automated discovery but Ansible module for that is not mature enough till now
```
./utilities/service_discovery.sh
```

Scaling up: System already baselined, startup the lab the specific number of users and its respective slaves (creates 2 ansiblelabusers, 2 Masters (1 master per user) and 3 slaves per master)
```
./ansible_lab.yml --tags=users,group,m_startup -e users=2 -e slaves=3
```
Execute the service discovery script that will modify the hosts file in the masters to discover and use the slaves via hostnames. Its a parameterized script where the number of masters and slaves can be passed as the first and second parameter respectively. Docker Network can be created and containers can be tagged for automated discovery but Ansible module for that is not mature enough till now
```
./utilities/service_discovery.sh 2 3
```

#### Getting Started: Access to the users and slaves
* ansiblelabuser (always created in sequence of numbers) to login into the host as ssh ansiblelabuser1@hostname
Expand Down
19 changes: 19 additions & 0 deletions utilities/service_discovery.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

cnt_master=${1:-1}
cnt_slaves=${2:-1}

masters=1
slaves=1

while [ $masters -le $cnt_master ]
do
while [ $slaves -le $cnt_slaves ]
do
slave_ip_address=`docker inspect --format '{{ .NetworkSettings.IPAddress }}' master-$masters-slave-$slaves`
docker exec master-$masters /bin/sh -c "echo $slave_ip_address master-$masters-slave-$slaves >> /etc/hosts"
slaves=`expr $slaves + 1`
done
slaves=1
masters=`expr $masters + 1`
done

0 comments on commit 6812c59

Please sign in to comment.