GENIExperimenter/Tutorials/GENI-SAVI/Execute: gee-tutorial-solution.yaml

File gee-tutorial-solution.yaml, 1.6 KB (added by Vic Thomas, 9 years ago)
Line 
1---
2- hosts: nodes
3  sudo: yes
4  remote_user: "{{ ansible_ssh_user }}"
5  tasks:
6
7  ### (a): Get the container's FQDN ###
8  - name: Dump container name
9    debug: var=ansible_fqdn
10
11
12  ### (b):  Get the container IP address ###
13  - name: Dump container IP address
14    debug: var=ansible_eth0.ipv4.address
15
16
17  ### (c): Get the control host name ###
18  - name: Dump control host name
19    debug: var=ansible_ssh_host
20
21
22  ### (d): Get the host's public IP address ###
23  - name: Get my public IP
24    ###shell: dig +short {{ ansible_hostname }}
25    shell: curl ipecho.net/plain
26    register: public_ip
27
28  - name: Dump public_ip variable
29    debug: var=public_ip
30
31
32  - name: Run geoiplookup to get latitude
33    #shell: geoiplookup -f GeoLiteCity.dat {{ public_ip.stdout }} | awk -F ', ' '{print $7}'
34    shell: curl -s ipinfo.io | grep loc | sed "s/^.*loc..// " | sed "s/..$//" | sed "s/^.*\"//" | sed "s/,.*$//"
35    register: lat
36
37  - name: Dump lat variable
38    debug: var=lat
39
40  - name: Run geoiplookup to get longitude
41#    shell: geoiplookup -f GeoLiteCity.dat {{ public_ip.stdout }} | awk -F ', ' '{print $8}'
42    shell: curl -s ipinfo.io | grep loc | sed "s/^.*loc..// " | sed "s/..$//" | sed "s/^.*,//"
43    register: long
44
45  - name: Dump long variable
46    debug: var=long
47
48
49  ### (f): Fetch the parameterized URL ###
50
51  - shell: curl "http://www.lively-web.org/nodejs/GEETutorial/helloWorld?slice=<<GENI-Username>&name={{ansible_fqdn}}&ip={{public_ip.stdout }}&local={{ansible_eth0.ipv4.address}}&lat={{lat.stdout}}&lng={{long.stdout}}"
52    register: hello
53
54  - debug: var=hello