Merge branch 'homeserver_nat_dhcp'

This commit is contained in:
Tom Alexander 2022-12-03 01:41:18 -05:00
commit c55f5d735d
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
16 changed files with 98 additions and 2 deletions

View File

@ -22,6 +22,11 @@ jail_zfs_dataset_mountpoint: /jail/main
jail_canmount: "on"
jail_bemount: "on"
jail_list:
- name: nat_dhcp
dataset: zmass/unencrypted/jails
enabled: true
conf:
src: nat_dhcp
- name: cloak
conf:
src: cloak

View File

@ -1,2 +1,2 @@
[headless]
homeserver ansible_user=talexander ansible_host=192.168.1.123
homeserver ansible_user=talexander ansible_host=172.16.16.2

View File

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

View File

@ -1,2 +1,4 @@
[jail]
nat_dhcp ansible_connection=jail
homeserver_nat_dhcp ansible_ssh_host=nat_dhcp@172.16.16.2 ansible_connection=sshjail
nat_dhcp@172.16.16.2 ansible_connection=sshjail

View File

@ -32,8 +32,9 @@
- media
- kubernetes
- google_cloud_sdk
- ansible
- hosts: nat_dhcp
- hosts: nat_dhcp:homeserver_nat_dhcp
vars:
ansible_become: True
roles:

View File

@ -0,0 +1 @@
install_ansible: true

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,6 @@
- name: Install packages
package:
name:
- py39-ansible
- ansible-sshjail
state: present

View File

@ -0,0 +1,28 @@
# - 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:
- ansible
state: present
- name: Install sshjail plugin
ansible.builtin.get_url:
url: https://raw.githubusercontent.com/austinhyde/ansible-sshjail/e712c537ecdfc7a660f222fbac4172dd715fc130/sshjail.py
dest: /usr/share/ansible/plugins/connection_plugins/sshjail.py
mode: '0555'
checksum: sha512:730c887ae7bbf2de34da44fb10a45fdeff649e3f2447df821c93ef02a21ecbef7db2fd57f1fc85fcd0b5b86fa30aa2b9ef143865d1e5086620c7dbe0633207cd

View File

@ -0,0 +1,2 @@
- import_tasks: tasks/common.yaml
when: install_ansible

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

@ -15,6 +15,7 @@
state: present
- include_tasks: "tasks/{{graphics_driver}}.yaml"
when: install_graphics # TODO: Maybe this should be when graphics_driver is defined to support headless casting
- import_tasks: tasks/freebsd.yaml
when: 'os_flavor == "freebsd"'

View File

@ -2,6 +2,7 @@
name: per_user
- name: Create directories
when: install_graphics
file:
name: "{{ account_homedir.stdout }}/{{ item }}"
state: directory
@ -12,6 +13,7 @@
- ".config/mpv"
- name: Copy files
when: install_graphics
copy:
src: "files/{{ item.src }}"
dest: "{{ account_homedir.stdout }}/{{ item.dest }}"

View File

@ -24,6 +24,9 @@ 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 "${@}"
elif [ "$target" = "jail_homeserver_nat_dhcp" ]; then
ansible-playbook -v -i environments/jail playbook.yaml --diff --limit homeserver_nat_dhcp "${@}"
#
else
die 1 "Unrecognized target"
fi