Skip to content

Commit

Permalink
Merge pull request #36 from dougbtv/getip
Browse files Browse the repository at this point in the history
[minor] adds a handy-dandy get-ip script for getting IPs of VMs
  • Loading branch information
dougbtv authored Sep 1, 2017
2 parents b10f991 + a4380c0 commit f2de25d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions roles/vm-spinup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
dest: /root/spinup.sh
mode: 0755

- name: Template the virtual machine "get IP" script
template:
src: getip.sh.j2
dest: /root/getip.sh
mode: 0755

- name: Get the virsh list
shell: >
virsh list
Expand Down
5 changes: 5 additions & 0 deletions roles/vm-spinup/templates/getip.sh.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
mac=$(virsh domiflist $1 | grep -i "virtio" | awk '{print $5}')
IP=$(nmap -sP {{ bridge_network_cidr }} | grep -i "$mac" -B 2 | head -n1 | sed -e 's/[()]//g' | awk '{print $6}')
echo "IP is: $IP"

0 comments on commit f2de25d

Please sign in to comment.