Last active
August 29, 2015 14:16
-
-
Save enko/89a2a0b776aeaf1d0fa5 to your computer and use it in GitHub Desktop.
a playbook to configure a host only by its mac address
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
| #!/usr/local/bin/python | |
| def mac2ll(mac): | |
| mac = mac.split(":") | |
| mac.insert(3,'fe') | |
| mac.insert(3,'ff') | |
| mac[0] = str(int(mac[0]) ^ 6) | |
| return "fe80::%s:%s:%s:%s" % ("".join(mac[0:2]),"".join(mac[2:4]),"".join(mac[4:6]),"".join(mac[6:8])) | |
| class FilterModule(object): | |
| ''' Ansible network jinja2 filters ''' | |
| def filters(self): | |
| return { | |
| 'mac2ll': mac2ll | |
| } |
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
| auto lo | |
| iface lo inet loopback | |
| # The primary network interface | |
| auto eth0 | |
| iface eth0 inet static | |
| address 192.168.122.{{ id }} | |
| broadcast 192.168.122.255 | |
| netmask 255.255.255.0 | |
| gateway 192.168.122.1 | |
| iface eth0 inet6 static | |
| address 2a01:4f8:200:2265:3:100::{{ id }} | |
| netmask 64 | |
| gateway fe80::5054:ff:fe9f:c3e4 |
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
| --- | |
| - hosts: linux_guests | |
| vars: | |
| ansible_ssh_host: "{{ mac|mac2ll }}%vtnet0" | |
| tasks: | |
| - name: write sysctl.conf to the disk | |
| copy: src=../templates/network/sysctl.conf dest=/etc/sysctl.conf | |
| - name: write resolv.conf to the disk | |
| copy: src=../templates/network/resolv.conf dest=/etc/resolv.conf | |
| - name: write /etc/network/interfaces | |
| template: src=../templates/network/interfaces dest=/etc/network/interfaces | |
| - name: write /root/startping.sh | |
| copy: src=../templates/network/startping.sh dest=/root/startping.sh mode=u+rx | |
| - name: Make sure tmux is installed | |
| apt: name=tmux state=present | |
| - name: restart networking | |
| shell: "/sbin/ifdown eth0; /sbin/ifup eth0" | |
| - name: start startping | |
| command: "/root/startping.sh" | |
| - name: install startping as cronjob | |
| cron: name="startping" special_time="reboot" job="/root/startping.sh" |
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
| nameserver 192.168.122.1 | |
| search int.datenknoten.me |
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
| #!/bin/sh | |
| tmux new-session -d -s ping | |
| tmux select-pane -t ping | |
| tmux send-keys "/bin/ping6 -i 10 2a01:4f8:200:2265:2::1" C-m |
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
| net.ipv6.conf.all.accept_ra=0 | |
| net.ipv6.conf.all.autoconf=0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment