New super- and exitnode installation V 3.0.0

This commit is contained in:
Ansible Admin 2016-01-27 17:33:47 +01:00
parent 17893e5e7c
commit e82587b46a
3 changed files with 31 additions and 70 deletions

View File

@ -1,51 +0,0 @@
#!/bin/bash
# Version 1.6
# Parameter setzen
GATEWAY1ext=185.66.193.105
GATEWAY2ext=185.66.193.106
GATEWAY1=10.188.255.5
GATEWAY2=10.188.255.6
GATEWAY1v6=2a03:2260:121::255:5
GATEWAY2v6=2a03:2260:121::255:6
IP=/sbin/ip
PING=/bin/ping
BATCTL=/usr/local/sbin/batctl
#if [ "hostname = troisdorf1 | troisdorf2" ]
if [ $(hostname) = "troisdorf1" ] || [ $(hostname) = "troisdorf2" ]
then
DEFAULT_GATEWAY=$GATEWAY1
DEFAULT_GATEWAYext=$GATEWAY1ext
FALLBACK_GATEWAY=$GATEWAY2
FALLBACK_GATEWAYext=$GATEWAY2ext
DEFAULT_GATEWAYv6=$GATEWAY1v6
FALLBACK_GATEWAYv6=$GATEWAY2v6
else
DEFAULT_GATEWAY=$GATEWAY2
DEFAULT_GATEWAYext=$GATEWAY2ext
FALLBACK_GATEWAY=$GATEWAY1
FALLBACK_GATEWAYext=$GATEWAY1ext
DEFAULT_GATEWAYv6=$GATEWAY2v6
FALLBACK_GATEWAYv6=$GATEWAY1v6
fi
if $PING -c 1 $DEFAULT_GATEWAYext
then
$IP route replace default via $DEFAULT_GATEWAY table 42
$IP -6 route replace default via $DEFAULT_GATEWAYv6 table 42
$BATCTL gw server 100Mbit/100Mbit
echo "Gateway erreichbar"
else
if $PING -c 1 $FALLBACK_GATEWAYext
then
$IP route replace default via $FALLBACK_GATEWAY table 42
$IP -6 route replace default via $FALLBACK_GATEWAYv6 table 42
$BATCTL gw server 80Mbit/80Mbit
echo "Nun FALLBACK_GATEWAY"
else
$BATCTL gw off
#Kein Gateway erreichbar, batctl gw off
fi
fi

View File

@ -1,10 +1,29 @@
#!/bin/bash #!/bin/sh
#
# -q quiet
# -c nb of pings
ping -q -I {{ sn_ffrl_IPv4 }} 8.8.8.8 -c 4 -i 1 -W 5 >/dev/null 2>&1 HOST1=8.8.8.8
HOST2=8.8.4.4
BATCTL=/usr/local/sbin/batctl
if test $? -eq 0; then ping -q -c5 $HOST1 > /dev/null
/usr/local/sbin/batctl gw server 100Mbit/100Mbit if [ $? -eq 0 ]
then
echo "ok"
$BATCTL gw server 100Mbit/100Mbit
else else
/usr/local/sbin/batctl gw off
echo "$HOST1 NICHT ok"
ping -q -c5 $HOST2 > /dev/null
if [ $? -eq 0 ]
then
echo "$HOST2 ok"
$BATCTL gw server 100Mbit/100Mbit
else
echo "$HOST2 NICHT ok"
$BATCTL gw off
fi
fi fi

View File

@ -9,7 +9,7 @@
user: root user: root
gather_facts: False gather_facts: False
vars: vars:
snversion: master_v2.9000001_beta snversion: master_v3.0.0
batmanversion: v2015.2 batmanversion: v2015.2
common_required_packages: common_required_packages:
- git - git
@ -192,21 +192,18 @@
with_items: logrotate_config with_items: logrotate_config
- name: Create freifunk directory - name: Create freifunk directory
file: path=/opt/freifunk state=directory mode=0755 file: path=/opt/freifunk state=directory mode=0755
- name: Check gateway / keepalive script - name: Check gateway / keepalive script supernode
copy: src=./files/{{ item }} dest=/opt/freifunk owner=root group=root mode=0500 copy: src=./files/{{ item }} dest=/opt/freifunk owner=root group=root mode=0500
with_items: check_gw_script with_items: check_gw_script
register: check_gw register: check_gw
when: sn_exit is undefined when: sn_exit is undefined
- name: Check gateway / keepalive script super- and exitnode
- name: Check gateway / keepalive script
template: src=./files/keepalive.exit.sh.j2 dest=/opt/freifunk/keepalive.sh owner=root group=root mode=0500 template: src=./files/keepalive.exit.sh.j2 dest=/opt/freifunk/keepalive.sh owner=root group=root mode=0500
register: check_gw register: check_gw
when: sn_exit is defined when: sn_exit is defined
- name: Add cron job with check gateway script - name: Add cron job with check gateway script
cron: name=check_gw job="/opt/freifunk/keepalive.sh > /dev/null 2>&1" user="root" cron: name=check_gw job="/opt/freifunk/keepalive.sh > /dev/null 2>&1" user="root"
when: check_gw.changed when: check_gw.changed
- name: Tunneldigger stats - name: Tunneldigger stats
copy: src=./files/{{ item }} dest=/opt/freifunk owner=root group=root mode=0500 copy: src=./files/{{ item }} dest=/opt/freifunk owner=root group=root mode=0500
with_items: tunneld_stats_file with_items: tunneld_stats_file
@ -215,8 +212,6 @@
- name: Add cron job tunneldigger stats - name: Add cron job tunneldigger stats
cron: name=tunneld_stats job="/opt/freifunk/collectd_td_stat.sh > /dev/null 2>&1" user="root" cron: name=tunneld_stats job="/opt/freifunk/collectd_td_stat.sh > /dev/null 2>&1" user="root"
when: tunneld_stats.changed when: tunneld_stats.changed
- name: Copy dhcpd template file - name: Copy dhcpd template file
template: src=./files/dhcpd.conf.j2 dest=/etc/dhcp/dhcpd.conf owner=root group=root mode=0444 template: src=./files/dhcpd.conf.j2 dest=/etc/dhcp/dhcpd.conf owner=root group=root mode=0444
register: dhcpd register: dhcpd
@ -235,23 +230,24 @@
cron: name=backbone special_time=reboot job="/opt/freifunk/l2tp_backbone.sh" cron: name=backbone special_time=reboot job="/opt/freifunk/l2tp_backbone.sh"
- name: Add cron startup script - name: Add cron startup script
cron: name=startup special_time=reboot job="/opt/freifunk/sn_startup.sh" cron: name=startup special_time=reboot job="/opt/freifunk/sn_startup.sh"
- name: Copy backbone script - name: Copy backbone script
template: src=./files/l2tp_backbone.sh.j2 dest=/opt/freifunk/l2tp_backbone.sh owner=root group=root mode=0544 template: src=./files/l2tp_backbone.sh.j2 dest=/opt/freifunk/l2tp_backbone.sh owner=root group=root mode=0544
when: sn_exit is undefined when: sn_exit is undefined
- name: Copy backbone script - name: Copy backbone script
template: src=./files/l2tp_backbone.sh.exit.j2 dest=/opt/freifunk/l2tp_backbone.sh owner=root group=root mode=0544 template: src=./files/l2tp_backbone.sh.exit.j2 dest=/opt/freifunk/l2tp_backbone.sh owner=root group=root mode=0544
when: sn_exit is defined when: sn_exit is defined
- name: Collectd template file - name: Collectd template file
template: src=./files/collectd.conf.j2 dest=/etc/collectd/collectd.conf owner=root group=root mode=0444 template: src=./files/collectd.conf.j2 dest=/etc/collectd/collectd.conf owner=root group=root mode=0444
register: collectd register: collectd
- name: Restart collectd - name: Restart collectd
service: name=collectd state=restarted service: name=collectd state=restarted
when: collectd.changed when: collectd.changed
- name: configure startup script - name: configure startup script supernode
template: src=./files/sn_startup.sh.j2 dest=/opt/freifunk/sn_startup.sh owner=root group=root mode=0500 template: src=./files/sn_startup.sh.j2 dest=/opt/freifunk/sn_startup.sh owner=root group=root mode=0500
when: sn_exit is undefined when: sn_exit is undefined
- name: Exit node startup script super- and exitnode
template: src=./files/sn_startup.exit.sh.j2 dest=/opt/freifunk/sn_startup.sh owner=root group=root mode=0500
when: sn_exit is defined
- name: SSH authorized_keys - name: SSH authorized_keys
copy: src=./files/{{ item }} dest=/root/.ssh owner=root group=root mode=0400 copy: src=./files/{{ item }} dest=/root/.ssh owner=root group=root mode=0400
with_items: authorized_keys with_items: authorized_keys
@ -271,9 +267,6 @@
- name: Interface configuration with ffrl gre tunnel - name: Interface configuration with ffrl gre tunnel
copy: src=./files/interfaces-{{ sn_hostname }} dest=/etc/network/interfaces owner=root group=root mode=0544 copy: src=./files/interfaces-{{ sn_hostname }} dest=/etc/network/interfaces owner=root group=root mode=0544
when: sn_exit is defined when: sn_exit is defined
- name: Exit node startup script
template: src=./files/sn_startup.exit.sh.j2 dest=/opt/freifunk/sn_startup.sh owner=root group=root mode=0500
when: sn_exit is defined
- apt: update_cache=yes - apt: update_cache=yes
- name: Install bird - name: Install bird
apt: state=installed pkg=bird apt: state=installed pkg=bird