Merge branch 'jail_dhcp'
This commit is contained in:
commit
74d31edae1
1
ansible/environments/jail/host_vars/nat_dhcp
Normal file
1
ansible/environments/jail/host_vars/nat_dhcp
Normal file
@ -0,0 +1 @@
|
||||
os_flavor: "freebsd"
|
2
ansible/environments/jail/hosts
Normal file
2
ansible/environments/jail/hosts
Normal file
@ -0,0 +1,2 @@
|
||||
[jail]
|
||||
nat_dhcp ansible_connection=jail
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
11
ansible/roles/jail/files/jails/nat_dhcp.conf
Normal file
11
ansible/roles/jail/files/jails/nat_dhcp.conf
Normal 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";
|
||||
}
|
12
ansible/roles/jail_nat_dhcp/files/dhcpd.conf
Normal file
12
ansible/roles/jail_nat_dhcp/files/dhcpd.conf
Normal 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;
|
||||
}
|
3
ansible/roles/jail_nat_dhcp/files/rc.conf
Normal file
3
ansible/roles/jail_nat_dhcp/files/rc.conf
Normal 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"
|
2
ansible/roles/jail_nat_dhcp/files/resolv.conf
Normal file
2
ansible/roles/jail_nat_dhcp/files/resolv.conf
Normal file
@ -0,0 +1,2 @@
|
||||
search home.arpa
|
||||
nameserver 10.213.177.1
|
15
ansible/roles/jail_nat_dhcp/tasks/common.yaml
Normal file
15
ansible/roles/jail_nat_dhcp/tasks/common.yaml
Normal 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
|
20
ansible/roles/jail_nat_dhcp/tasks/freebsd.yaml
Normal file
20
ansible/roles/jail_nat_dhcp/tasks/freebsd.yaml
Normal 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
|
21
ansible/roles/jail_nat_dhcp/tasks/linux.yaml
Normal file
21
ansible/roles/jail_nat_dhcp/tasks/linux.yaml
Normal 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
|
2
ansible/roles/jail_nat_dhcp/tasks/main.yaml
Normal file
2
ansible/roles/jail_nat_dhcp/tasks/main.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
- import_tasks: tasks/common.yaml
|
||||
# when: foo is defined
|
29
ansible/roles/jail_nat_dhcp/tasks/peruser.yaml
Normal file
29
ansible/roles/jail_nat_dhcp/tasks/peruser.yaml
Normal 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"'
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user