Merge branch 'jail_dhcp'

This commit is contained in:
Tom Alexander 2022-12-02 20:47:11 -05:00
commit 74d31edae1
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
18 changed files with 139 additions and 1 deletions

View File

@ -0,0 +1 @@
os_flavor: "freebsd"

View File

@ -0,0 +1,2 @@
[jail]
nat_dhcp ansible_connection=jail

View File

@ -39,6 +39,11 @@ users:
devfs_rules: "odo_devfs.rules"
jail_zfs_dataset: zroot/freebsd/release/jails
jail_zfs_dataset_mountpoint: /jail/main
jail_list:
- name: nat_dhcp
enabled: true
conf:
src: nat_dhcp
bhyve_dataset: zroot/freebsd/release/vm
bhyve_list: []
efi_dev: /dev/gpt/EFI

View File

@ -1,4 +1,4 @@
- hosts: all
- hosts: all:!jail
vars:
ansible_become: True
roles:
@ -32,3 +32,9 @@
- media
- kubernetes
- google_cloud_sdk
- hosts: nat_dhcp
vars:
ansible_become: True
roles:
- jail_nat_dhcp

View File

@ -9,6 +9,7 @@
apply:
become: yes
become_user: "{{ initialize_user }}"
when: users is defined
loop: "{{ users | dict2items | community.general.json_query('[?value.initialize==`true`].key') }}"
loop_control:
loop_var: initialize_user

View File

@ -11,3 +11,9 @@ add path pf unhide
add path pflog unhide
add path pfsynv unhide
add path 'tun*' unhide
[tajaildhcp=14]
add include $devfsrules_hide_all
add include $devfsrules_unhide_basic
add include $devfsrules_unhide_login
add path 'bpf*' unhide

View File

@ -0,0 +1,11 @@
nat_dhcp {
path = "/jail/main/jails/nat_dhcp";
vnet;
vnet.interface += "host_link3";
devfs_ruleset = 14;
mount.devfs; # To expose tun device
exec.start += "/bin/sh /etc/rc";
exec.stop = "/bin/sh /etc/rc.shutdown jail";
exec.consolelog = "/var/log/jail_${name}_console.log";
}

View File

@ -0,0 +1,12 @@
# option definitions common to all supported networks...
option domain-name "home.arpa";
# option domain-name-servers ns1.home.arpa;
option subnet-mask 255.255.255.0;
default-lease-time 600;
max-lease-time 7200;
subnet 10.213.177.0 netmask 255.255.255.0 {
range 10.213.177.10 10.213.177.250;
option broadcast-address 10.213.177.255;
option routers 10.213.177.1;
}

View File

@ -0,0 +1,3 @@
ifconfig_host_link3="inet 10.213.177.254 netmask 255.255.255.0"
defaultrouter="10.213.177.1"
dhcpd_enable="YES"

View File

@ -0,0 +1,2 @@
search home.arpa
nameserver 10.213.177.1

View File

@ -0,0 +1,15 @@
- import_tasks: tasks/freebsd.yaml
when: 'os_flavor == "freebsd"'
- import_tasks: tasks/linux.yaml
when: 'os_flavor == "linux"'
- include_tasks:
file: tasks/peruser.yaml
apply:
become: yes
become_user: "{{ initialize_user }}"
when: users is defined
loop: "{{ users | dict2items | community.general.json_query('[?value.initialize==`true`].key') }}"
loop_control:
loop_var: initialize_user

View File

@ -0,0 +1,20 @@
- name: Install packages
package:
name:
- dhcpd
state: present
- name: Install Configuration
copy:
src: "files/{{ item.src }}"
dest: "{{ item.dest }}"
mode: 0644
owner: root
group: wheel
loop:
- src: rc.conf
dest: /etc/rc.conf
- src: dhcpd.conf
dest: /usr/local/etc/dhcpd.conf
- src: resolv.conf
dest: /etc/resolv.conf

View File

@ -0,0 +1,21 @@
# - name: Build aur packages
# register: buildaur
# become_user: "{{ build_user.name }}"
# command: "aurutils-sync --no-view {{ item }}"
# args:
# creates: "/var/cache/pacman/custom/{{ item }}-*.pkg.tar.*"
# loop:
# - foo
# - name: Update cache
# when: buildaur.changed
# pacman:
# name: []
# state: present
# update_cache: true
# - name: Install packages
# package:
# name:
# - foo
# state: present

View File

@ -0,0 +1,2 @@
- import_tasks: tasks/common.yaml
# when: foo is defined

View File

@ -0,0 +1,29 @@
- include_role:
name: per_user
# - name: Create directories
# file:
# name: "{{ account_homedir.stdout }}/{{ item }}"
# state: directory
# mode: 0700
# owner: "{{ account_name.stdout }}"
# group: "{{ group_name.stdout }}"
# loop:
# - ".config/foo"
# - name: Copy files
# copy:
# src: "files/{{ item.src }}"
# dest: "{{ account_homedir.stdout }}/{{ item.dest }}"
# mode: 0600
# owner: "{{ account_name.stdout }}"
# group: "{{ group_name.stdout }}"
# loop:
# - src: foo.conf
# dest: .config/foo/foo.conf
- import_tasks: tasks/peruser_freebsd.yaml
when: 'os_flavor == "freebsd"'
- import_tasks: tasks/peruser_linux.yaml
when: 'os_flavor == "linux"'

View File

@ -22,6 +22,8 @@ elif [ "$target" = "odolinux" ]; then
ansible-playbook -v -i environments/laptop playbook.yaml --diff --limit odolinux "${@}"
elif [ "$target" = "odofreebsd" ]; then
ansible-playbook -v -i environments/laptop playbook.yaml --diff --limit odofreebsd "${@}"
elif [ "$target" = "jail_nat_dhcp" ]; then
ansible-playbook -v -i environments/jail playbook.yaml --diff --limit nat_dhcp "${@}"
else
die 1 "Unrecognized target"
fi