Skip to content

Commit

Permalink
Add idlebox role
Browse files Browse the repository at this point in the history
  • Loading branch information
the-maldridge committed Apr 9, 2016
1 parent 3a0ba31 commit 31d09c7
Show file tree
Hide file tree
Showing 13 changed files with 150 additions and 0 deletions.
5 changes: 5 additions & 0 deletions idler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- hosts: idlebox
sudo: yes
roles:
- idlebox
3 changes: 3 additions & 0 deletions inventory
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ luggable-gw

[luggable]
luggable

[idlebox]
lug-idler
23 changes: 23 additions & 0 deletions roles/idlebox/files/0common.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Firewall configuration written by phy1729
# Modified by maldridge 2/25/2016
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT DROP [0:0]
-A INPUT -i lo -j ACCEPT
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp --dport 22 -j ACCEPT
-A INPUT -p icmp -j ACCEPT

-A OUTPUT -o lo -j ACCEPT
-A OUTPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A OUTPUT -p icmp -j ACCEPT
# DNS
-A OUTPUT -p udp -d 8.8.8.8 --dport 53 -j ACCEPT
-A OUTPUT -p tcp -d 8.8.8.8 --dport 53 -j ACCEPT
-A OUTPUT -p udp -d 8.8.4.4 --dport 53 -j ACCEPT
-A OUTPUT -p tcp -d 8.8.4.4 --dport 53 -j ACCEPT
# Allow github for dotfiles and vim plugins
-A OUTPUT -p tcp -d 192.30.252.0/22 --dport 443 -j ACCEPT

COMMIT
1 change: 1 addition & 0 deletions roles/idlebox/files/hostname
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lug-idler
2 changes: 2 additions & 0 deletions roles/idlebox/files/hosts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
127.0.0.1 localhost
158.69.215.92 idle.utdlug.org lug-idler
6 changes: 6 additions & 0 deletions roles/idlebox/files/idle-box.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*filter
# Allow mosh in
-A INPUT -p udp --dport 60001:60999 -j ACCEPT
# Allow IRC, IRC SSL, jabber, HTTP, and HTTPS
-A OUTPUT -p tcp -m multiport --destination-port 6667,6697,9003,16667,5222,80,443 -j ACCEPT
COMMIT
7 changes: 7 additions & 0 deletions roles/idlebox/files/ip6tables.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT DROP [0:0]
-A INPUT -i lo -j ACCEPT
-A OUTPUT -o lo -j ACCEPT
COMMIT
6 changes: 6 additions & 0 deletions roles/idlebox/files/iptables
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
iptables -F
for file in /etc/iptables.d/*; do
iptables-restore -n < "$file"
done
ip6tables-restore < /etc/ip6tables.conf
3 changes: 3 additions & 0 deletions roles/idlebox/files/resolv.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nameserver 8.8.8.8
nameserver 8.8.4.4
search utdlug.org
9 changes: 9 additions & 0 deletions roles/idlebox/files/ssh_banner
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Welcome!

This box is provided to idle your IRC session on.
Use of this server for other purposes may lead
to your access being removed.

For problems or software requests, contact [email protected]

Enjoy!
19 changes: 19 additions & 0 deletions roles/idlebox/files/sshd_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# See the sshd_config(5) manpage for details

AddressFamily inet

HostKey /etc/ssh/ssh_host_ed25519_key
HostKey /etc/ssh/ssh_host_rsa_key

Ciphers [email protected],[email protected],aes256-ctr
KexAlgorithms [email protected],diffie-hellman-group-exchange-sha256
MACs [email protected],hmac-sha2-512,hmac-sha2-256,hmac-ripemd160

UsePrivilegeSeparation sandbox
Subsystem sftp /usr/lib/openssh/sftp-server
PermitRootLogin no

Banner /etc/ssh/banner

PubkeyAuthentication yes
PasswordAuthentication no
6 changes: 6 additions & 0 deletions roles/idlebox/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: idle-iptables
command: /etc/network/if-up.d/iptables

- name: idle-sshd
service: name=ssh state=restarted
60 changes: 60 additions & 0 deletions roles/idlebox/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
- name: Configure resolvconf
copy: src=resolv.conf dest=/etc/resolvconf/resolv.conf.d/base owner=root group=root mode=0644

- name: Add iptables script
copy: src=iptables dest=/etc/network/if-up.d/iptables owner=root group=root mode=0740

- name: Make iptables.d
file: path=/etc/iptables.d state=directory owner=root group=root mode=0740

- name: Configure IPv4 firewall
copy: src={{ item }} dest=/etc/iptables.d/{{ item }} owner=root group=root mode=0640
with_items:
- 0common.rules
- idle-box.rules
notify:
- idle-iptables

- name: Configure IPv6 firewall
copy: src=ip6tables.conf dest=/etc/ip6tables.conf owner=root group=root mode=0640
notify:
- idle-iptables

- name: Configure hostname 1/2
copy: src=hostname dest=/etc/hostname owner=root group=root mode=0644

- name: Configure hostname 2/2
copy: src=hosts dest=/etc/hosts owner=root group=root mode=0644

- name: Configure sshd
copy: src=sshd_config dest=/etc/ssh/sshd_config owner=root group=root mode=0644
notify:
- idle-sshd

- name: Add SSH banner
copy: src=ssh_banner dest=/etc/ssh/banner owner=root group=root mode=0644
notify:
- idle-sshd

- name: Add weechat repository
apt_repository: repo=ppa:nesthib/weechat-stable update_cache=yes

- name: Install idle-box packages
apt: pkg={{ item }} state=present update_cache=yes
with_items:
- bc
- git
- irssi
- mosh
- screen
- tmux
- zsh
# For SASL in irssi
- libcrypt-blowfish-perl
- libcrypt-dh-perl
- libcrypt-openssl-bignum-perl
# For jabber in weechat
- python-xmpp
- weechat-curses
- weechat-plugins

0 comments on commit 31d09c7

Please sign in to comment.