GENIExperimenter/Tutorials/GENIExperimentEngine/Execute: gee-tutorial-solution.yaml

File gee-tutorial-solution.yaml, 1.8 KB (added by acb@cs.princeton.edu, 9 years ago)

Ansible playbook solution for fetching the parameterized URL

Line 
1---
2- hosts: nodes
3  remote_user: root
4  tasks:
5
6  ### (a): Get the container's FQDN ###
7  - name: Dump container name
8    debug: var=ansible_fqdn
9
10
11  ### (b):  Get the container IP address ###
12  - name: Dump container IP address
13    debug: var=ansible_eth0.ipv4.address
14
15
16  ### (c): Get the control host name ###
17  - name: Dump control host name
18    debug: var=ansible_ssh_host
19
20
21  ### (d): Get the host's public IP address ###
22  - name: Get my public IP
23    shell: dig +short {{ ansible_ssh_host }}
24    register: public_ip
25
26  - name: Dump public_ip variable
27    debug: var=public_ip
28
29
30  ### (e): Get the latitude and longitude for each node ###
31  - name: Download GeoLiteCity DB
32    get_url: url=http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
33      dest=/root
34
35  - name: Unzip GeoLiteCity.dat.gz
36    shell: gunzip GeoLiteCity.dat.gz
37      creates=GeoLiteCity.dat
38
39  - name: Run geoiplookup to get latitude
40    shell: geoiplookup -f GeoLiteCity.dat {{ public_ip.stdout }} | awk -F ', ' '{print $7}'
41    register: lat
42
43  - name: Dump lat variable
44    debug: var=lat
45
46  - name: Run geoiplookup to get longitude
47    shell: geoiplookup -f GeoLiteCity.dat {{ public_ip.stdout }} | awk -F ', ' '{print $8}'
48    register: long
49
50  - name: Dump long variable
51    debug: var=long
52
53
54  ### (f): Fetch the parameterized URL ###
55  - debug: msg="http://www.lively-web.org/nodejs/GEETutorial/helloWorld?slice={{ ansible_hostname }}&name={{ ansible_fqdn }}&ip={{ public_ip.stdout }}&local={{ ansible_eth0.ipv4.address }}&lat={{ lat.stdout }}&lng={{ long.stdout }}"
56
57  - shell: curl "http://www.lively-web.org/nodejs/GEETutorial/helloWorld?slice={{ ansible_hostname }}&name={{ ansible_fqdn }}&ip={{ public_ip.stdout }}&local={{ ansible_eth0.ipv4.address }}&lat={{ lat.stdout }}&lng={{ long.stdout }}"