--- - hosts: nodes remote_user: root tasks: ### (a): Get the container's FQDN ### - name: Dump container name debug: var=ansible_fqdn ### (b): Get the container IP address ### - name: Dump container IP address debug: var=ansible_eth0.ipv4.address ### (c): Get the control host name ### - name: Dump control host name debug: var=ansible_ssh_host ### (d): Get the host's public IP address ### - name: Get my public IP shell: dig +short {{ ansible_ssh_host }} register: public_ip - name: Dump public_ip variable debug: var=public_ip ### (e): Get the latitude and longitude for each node ### - name: Download GeoLiteCity DB get_url: url=http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz dest=/root - name: Unzip GeoLiteCity.dat.gz shell: gunzip GeoLiteCity.dat.gz creates=GeoLiteCity.dat - name: Run geoiplookup to get latitude shell: geoiplookup -f GeoLiteCity.dat {{ public_ip.stdout }} | awk -F ', ' '{print $7}' register: lat - name: Dump lat variable debug: var=lat - name: Run geoiplookup to get longitude shell: geoiplookup -f GeoLiteCity.dat {{ public_ip.stdout }} | awk -F ', ' '{print $8}' register: long - name: Dump long variable debug: var=long ### (f): Fetch the parameterized URL ### - 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 }}" - 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 }}"