mirror of
https://github.com/trailofbits/algo.git
synced 2025-09-02 18:13:13 +02:00
Merge d7e4ca0528
into 3488e660ad
This commit is contained in:
commit
c6969435f9
18 changed files with 144 additions and 10 deletions
7
playbooks/arch.yml
Normal file
7
playbooks/arch.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: Arch Linux | Install prerequisites
|
||||||
|
become: yes
|
||||||
|
become_method: su
|
||||||
|
become_user: root
|
||||||
|
raw: sleep 10 && pacman -Syu --noconfirm && pacman -S python2 sudo --noconfirm
|
|
@ -12,4 +12,9 @@
|
||||||
include_tasks: freebsd.yml
|
include_tasks: freebsd.yml
|
||||||
when: '"FreeBSD" in OS.stdout'
|
when: '"FreeBSD" in OS.stdout'
|
||||||
|
|
||||||
|
- name: Arch pre-tasks
|
||||||
|
include_tasks: arch.yml
|
||||||
|
when: '"ARCH" in OS.stdout'
|
||||||
|
|
||||||
|
|
||||||
- include_tasks: facts/main.yml
|
- include_tasks: facts/main.yml
|
||||||
|
|
27
roles/common/tasks/arch.yml
Normal file
27
roles/common/tasks/arch.yml
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- set_fact:
|
||||||
|
tools: []
|
||||||
|
sysctl:
|
||||||
|
- item: net.ipv4.ip_forward
|
||||||
|
value: 1
|
||||||
|
- item: net.ipv4.conf.all.forwarding
|
||||||
|
value: 1
|
||||||
|
- item: net.ipv6.conf.all.forwarding
|
||||||
|
value: 1
|
||||||
|
sysctl_file: /etc/sysctl.d/99-sysctl.conf
|
||||||
|
tags:
|
||||||
|
- always
|
||||||
|
|
||||||
|
- name: Loopback for services configured
|
||||||
|
template: src=10-loopback-services.network.j2 dest=/etc/systemd/network/10-loopback-services.network
|
||||||
|
tags:
|
||||||
|
- always
|
||||||
|
|
||||||
|
- name: Networking restarted
|
||||||
|
systemd:
|
||||||
|
name: systemd-networkd
|
||||||
|
daemon_reload: yes
|
||||||
|
state: restarted
|
||||||
|
tags:
|
||||||
|
- always
|
|
@ -6,6 +6,10 @@
|
||||||
- include_tasks: freebsd.yml
|
- include_tasks: freebsd.yml
|
||||||
when: ansible_distribution == 'FreeBSD'
|
when: ansible_distribution == 'FreeBSD'
|
||||||
|
|
||||||
|
- include_tasks: arch.yml
|
||||||
|
when: ansible_distribution == 'Archlinux'
|
||||||
|
|
||||||
|
|
||||||
- name: Install tools
|
- name: Install tools
|
||||||
package: name="{{ item }}" state=present
|
package: name="{{ item }}" state=present
|
||||||
with_items:
|
with_items:
|
||||||
|
@ -14,7 +18,10 @@
|
||||||
- always
|
- always
|
||||||
|
|
||||||
- name: Sysctl tuning
|
- name: Sysctl tuning
|
||||||
sysctl: name="{{ item.item }}" value="{{ item.value }}"
|
sysctl:
|
||||||
|
name: "{{ item.item }}"
|
||||||
|
value: "{{ item.value }}"
|
||||||
|
sysctl_file: "{{ sysctl_file|default('/etc/sysctl.conf') }}"
|
||||||
with_items:
|
with_items:
|
||||||
- "{{ sysctl|default([]) }}"
|
- "{{ sysctl|default([]) }}"
|
||||||
tags:
|
tags:
|
||||||
|
|
7
roles/common/templates/10-loopback-services.network.j2
Normal file
7
roles/common/templates/10-loopback-services.network.j2
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
[Match]
|
||||||
|
Name=lo
|
||||||
|
|
||||||
|
[Network]
|
||||||
|
Label=lo:100
|
||||||
|
Address={{ local_service_ip }}/32
|
||||||
|
Address=FCAA::1/64
|
25
roles/dns_adblocking/tasks/arch.yml
Normal file
25
roles/dns_adblocking/tasks/arch.yml
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: Arch Linux | Install cronie
|
||||||
|
pacman:
|
||||||
|
name: cronie
|
||||||
|
|
||||||
|
- name: Arch Linux | Enable and start cronie
|
||||||
|
service:
|
||||||
|
name: cronie
|
||||||
|
state: started
|
||||||
|
enabled: yes
|
||||||
|
|
||||||
|
- name: Arch Linux | Enable systemd-networkd-wait-online
|
||||||
|
service:
|
||||||
|
name: systemd-networkd-wait-online
|
||||||
|
enabled: yes
|
||||||
|
|
||||||
|
|
||||||
|
- name: Arch Linux | The dnsmasq additional directories created
|
||||||
|
file:
|
||||||
|
dest: "{{ item }}"
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
with_items:
|
||||||
|
- "{{ config_prefix|default('/') }}etc/dnsmasq.d"
|
5
roles/dns_adblocking/tasks/arch_set_nogroup.yml
Normal file
5
roles/dns_adblocking/tasks/arch_set_nogroup.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: Arch Linux | Set nogroup
|
||||||
|
set_fact:
|
||||||
|
nogroup: nobody
|
|
@ -1,18 +1,20 @@
|
||||||
---
|
---
|
||||||
- block:
|
- block:
|
||||||
|
|
||||||
- name: The DNS tag is defined
|
- name: The DNS tag is defined
|
||||||
set_fact:
|
set_fact:
|
||||||
local_dns: true
|
local_dns: true
|
||||||
|
|
||||||
|
- include_tasks: arch_set_nogroup.yml
|
||||||
|
when: ansible_distribution == 'Archlinux'
|
||||||
|
|
||||||
- name: Dnsmasq installed
|
- name: Dnsmasq installed
|
||||||
package: name=dnsmasq
|
package: name=dnsmasq
|
||||||
|
|
||||||
- name: Ensure that the dnsmasq user exist
|
- name: Ensure that the dnsmasq user exist
|
||||||
user: name=dnsmasq groups=nogroup append=yes state=present
|
user: "name=dnsmasq groups={{ nogroup|default('nogroup') }} append=yes state=present"
|
||||||
|
|
||||||
- name: The dnsmasq directory created
|
- name: The dnsmasq directory created
|
||||||
file: dest=/var/lib/dnsmasq state=directory mode=0755 owner=dnsmasq group=nogroup
|
file: "dest=/var/lib/dnsmasq state=directory mode=0755 owner=dnsmasq group={{ nogroup|default('nogroup') }}"
|
||||||
|
|
||||||
- include_tasks: ubuntu.yml
|
- include_tasks: ubuntu.yml
|
||||||
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
|
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
|
||||||
|
@ -20,6 +22,9 @@
|
||||||
- include_tasks: freebsd.yml
|
- include_tasks: freebsd.yml
|
||||||
when: ansible_distribution == 'FreeBSD'
|
when: ansible_distribution == 'FreeBSD'
|
||||||
|
|
||||||
|
- include_tasks: arch.yml
|
||||||
|
when: ansible_distribution == 'Archlinux'
|
||||||
|
|
||||||
- name: Dnsmasq configured
|
- name: Dnsmasq configured
|
||||||
template:
|
template:
|
||||||
src: dnsmasq.conf.j2
|
src: dnsmasq.conf.j2
|
||||||
|
|
|
@ -104,7 +104,7 @@ server={{ host }}
|
||||||
# If you want dnsmasq to change uid and gid to something other
|
# If you want dnsmasq to change uid and gid to something other
|
||||||
# than the default, edit the following lines.
|
# than the default, edit the following lines.
|
||||||
user=nobody
|
user=nobody
|
||||||
group=nogroup
|
group={{ nogroup|default('nogroup') }}
|
||||||
|
|
||||||
# If you want dnsmasq to listen for DHCP and DNS requests only on
|
# If you want dnsmasq to listen for DHCP and DNS requests only on
|
||||||
# specified interfaces (and the loopback) give the name of the
|
# specified interfaces (and the loopback) give the name of the
|
||||||
|
|
6
roles/dns_encryption/tasks/arch.yml
Normal file
6
roles/dns_encryption/tasks/arch.yml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: Arch Linux | Install dnscrypt-proxy
|
||||||
|
pacman:
|
||||||
|
name: dnscrypt-proxy
|
||||||
|
state: latest
|
|
@ -7,6 +7,10 @@
|
||||||
include_tasks: freebsd.yml
|
include_tasks: freebsd.yml
|
||||||
when: ansible_distribution == 'FreeBSD'
|
when: ansible_distribution == 'FreeBSD'
|
||||||
|
|
||||||
|
- name: Include tasks for Arch Linux
|
||||||
|
include_tasks: arch.yml
|
||||||
|
when: ansible_distribution == 'Archlinux'
|
||||||
|
|
||||||
- name: dnscrypt-proxy configured
|
- name: dnscrypt-proxy configured
|
||||||
template:
|
template:
|
||||||
src: dnscrypt-proxy.toml.j2
|
src: dnscrypt-proxy.toml.j2
|
||||||
|
|
5
roles/ssh_tunneling/tasks/arch.yml
Normal file
5
roles/ssh_tunneling/tasks/arch.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: Arch Linux | Set sshd daemon name
|
||||||
|
set_fact:
|
||||||
|
ssh_service_name: sshd
|
|
@ -1,5 +1,9 @@
|
||||||
---
|
---
|
||||||
- block:
|
- block:
|
||||||
|
- name: Include tasks for Arch Linux
|
||||||
|
include_tasks: arch.yml
|
||||||
|
when: ansible_distribution == 'Archlinux'
|
||||||
|
|
||||||
- name: Ensure that the sshd_config file has desired options
|
- name: Ensure that the sshd_config file has desired options
|
||||||
blockinfile:
|
blockinfile:
|
||||||
dest: /etc/ssh/sshd_config
|
dest: /etc/ssh/sshd_config
|
||||||
|
|
|
@ -13,5 +13,8 @@
|
||||||
- name: restart iptables
|
- name: restart iptables
|
||||||
service: name=netfilter-persistent state=restarted
|
service: name=netfilter-persistent state=restarted
|
||||||
|
|
||||||
|
- name: restart iptables arch
|
||||||
|
service: name=iptables state=restarted
|
||||||
|
|
||||||
- name: rereadcrls
|
- name: rereadcrls
|
||||||
shell: ipsec rereadcrls; ipsec purgecrls
|
shell: ipsec rereadcrls; ipsec purgecrls
|
||||||
|
|
21
roles/vpn/tasks/arch.yml
Normal file
21
roles/vpn/tasks/arch.yml
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
---
|
||||||
|
- set_fact:
|
||||||
|
strongswan_additional_plugins: []
|
||||||
|
iptables_rules_v4: /etc/iptables/iptables.rules
|
||||||
|
iptables_rules_v6: /etc/iptables/ip6tables.rules
|
||||||
|
restart_iptables: restart iptables arch
|
||||||
|
ipencap: ipv4
|
||||||
|
|
||||||
|
- name: Archlinux | Install strongSwan
|
||||||
|
pacman:
|
||||||
|
name: strongswan
|
||||||
|
state: latest
|
||||||
|
|
||||||
|
- name: Archlinux | Enable services
|
||||||
|
service: name={{ item }} enabled=yes
|
||||||
|
with_items:
|
||||||
|
- strongswan
|
||||||
|
- iptables
|
||||||
|
|
||||||
|
- include_tasks: iptables.yml
|
||||||
|
tags: iptables
|
|
@ -8,9 +8,9 @@
|
||||||
group: root
|
group: root
|
||||||
mode: 0640
|
mode: 0640
|
||||||
with_items:
|
with_items:
|
||||||
- { src: rules.v4.j2, dest: /etc/iptables/rules.v4 }
|
- { src: rules.v4.j2, dest: "{{ iptables_rules_v4|default('/etc/iptables/rules.v4') }}" }
|
||||||
notify:
|
notify:
|
||||||
- restart iptables
|
- "{{ restart_iptables|default('restart iptables') }}"
|
||||||
|
|
||||||
- name: Iptables configured
|
- name: Iptables configured
|
||||||
template:
|
template:
|
||||||
|
@ -21,6 +21,6 @@
|
||||||
mode: 0640
|
mode: 0640
|
||||||
when: ipv6_support
|
when: ipv6_support
|
||||||
with_items:
|
with_items:
|
||||||
- { src: rules.v6.j2, dest: /etc/iptables/rules.v6 }
|
- { src: rules.v6.j2, dest: "{{ iptables_rules_v6|default('/etc/iptables/rules.v6') }}" }
|
||||||
notify:
|
notify:
|
||||||
- restart iptables
|
- "{{ restart_iptables|default('restart iptables') }}"
|
||||||
|
|
|
@ -12,6 +12,9 @@
|
||||||
- include_tasks: freebsd.yml
|
- include_tasks: freebsd.yml
|
||||||
when: ansible_distribution == 'FreeBSD'
|
when: ansible_distribution == 'FreeBSD'
|
||||||
|
|
||||||
|
- include_tasks: arch.yml
|
||||||
|
when: ansible_distribution == 'Archlinux'
|
||||||
|
|
||||||
- name: Install strongSwan
|
- name: Install strongSwan
|
||||||
package: name=strongswan state=present
|
package: name=strongswan state=present
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ COMMIT
|
||||||
# Allow new traffic to port 22 (SSH)
|
# Allow new traffic to port 22 (SSH)
|
||||||
-A INPUT -p tcp --dport 22 -m conntrack --ctstate NEW -j ACCEPT
|
-A INPUT -p tcp --dport 22 -m conntrack --ctstate NEW -j ACCEPT
|
||||||
# Allow any traffic from the VPN
|
# Allow any traffic from the VPN
|
||||||
-A INPUT -p ipencap -m policy --dir in --pol ipsec --proto esp -j ACCEPT
|
-A INPUT -p {{ ipencap|default('ipencap') }} -m policy --dir in --pol ipsec --proto esp -j ACCEPT
|
||||||
|
|
||||||
# TODO:
|
# TODO:
|
||||||
# The IP of the resolver should be bound to a DUMMY interface.
|
# The IP of the resolver should be bound to a DUMMY interface.
|
||||||
|
|
Loading…
Add table
Reference in a new issue