Created
September 22, 2016 20:17
-
-
Save robrant/0e1d22a4304b5b3592ae7b82d7d46fd1 to your computer and use it in GitHub Desktop.
Not testing ansible networking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mostly copied/scripted from | |
# https://www.modmypi.com/blog/tutorial-how-to-give-your-raspberry-pi-a-static-ip-address | |
# We're assuming you're on ethernet when this is run. | |
# Also worth trying: | |
# route -n | awk '$4 == "UG" {print $2}' | |
# Get basic network information | |
- name: Get the gateway | |
shell: $(/sbin/route -n | awk 'FNR == 3 {print $2}') | |
register: eth0_gateway | |
- name: Get the destination | |
shell: $(/sbin/route -n | awk 'FNR == 4 {print $1}') | |
register: eth0_destination | |
- name: Get the mask | |
shell: $(/sbin/route -n | awk 'FNR == 4 {print $3}') | |
register: eth0_mask | |
# Set variables with those parameters | |
- name: Set the network variables | |
set_fact: | |
eth0_gateway : eth0_gateway | |
eth0_destination : eth0_destination | |
eth0_mask : eth0_mask |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment