<commit_before>Webserver
=========

The idea is that the webserver lives in its own jail and receives all HTTP traffic and then redirects the requests as required to the individual jails.

The webserver jail itself will host a simple website that lists and links the available services.

The website will be in a dedicated ZFS that will be mounted into the jail, so let's start with creating this.

In ``etc/ploy.conf`` from the quickstart you should have the following ezjail master::

	[ez-master:jailhost]
	instance = ploy-demo
	roles =
	    dhcp_host
	    jails_host


ZFS mounting
------------

To set up the ZFS layout we will replace the inline roles with a dedicated playbook, so let's delete the ``roles =`` entry and create a top-level file names ``jailhost.yml`` with the following contents::

	---
	- hosts: jailhost
	  user: root
	  roles:
	    - dhcp_host
	    - jails_host

Once we have a playbook in place, it becomes easy to add custom tasks::

	  tasks:
	    - name: ensure ZFS file systems are in place
	      zfs: name={{ item }} state=present
	      with_items:
	      - tank/htdocs
	      tags: zfs-layout

To apply the playbook it's easiest to call the ``configure`` command again.
While Ansible is smart enough to only apply those parts that actually need to be applied again that process can become quite slow, as playbooks grow in size.
So here, we tag the new task with ``zfs-layout``, so we can call it explicitly::

	ploy configure jailhost -t zfs-layout

.. note:: You should see an ``INFO`` entry in the output that tells you which playbook the ``configure`` command has used.


Exercise
--------

In the quickstart, we've created a demo jail which conveniently already contains a webserver.

Repurpose it to create a jail named ``webserver`` which has nginx installed into it.

Do this by first terminating the demo jail, *then* renaming it, otherwise we will have an 'orphaned' instance which would interfere with the new jail::

	ploy terminate demo_jail

Now we can mount the website ZFS into it like so::

	[ez-instance:webserver]
	master = jailhost
	ip = 10.0.0.2
	mounts =<commit_msg>bugfix: set mountpoint in tutorial<commit_after>Webserver
=========

The idea is that the webserver lives in its own jail and receives all HTTP traffic and then redirects the requests as required to the individual jails.

The webserver jail itself will host a simple website that lists and links the available services.

The website will be in a dedicated ZFS that will be mounted into the jail, so let's start with creating this.

In ``etc/ploy.conf`` from the quickstart you should have the following ezjail master::

	[ez-master:jailhost]
	instance = ploy-demo
	roles =
	    dhcp_host
	    jails_host


ZFS mounting
------------

To set up the ZFS layout we will replace the inline roles with a dedicated playbook, so let's delete the ``roles =`` entry and create a top-level file names ``jailhost.yml`` with the following contents::

	---
	- hosts: jailhost
	  user: root
	  roles:
	    - dhcp_host
	    - jails_host

Once we have a playbook in place, it becomes easy to add custom tasks::

	  tasks:
	    - name: ensure ZFS file systems are in place
	      zfs: name={{ item }} state=present mountpoint=/{{ item }}
	      with_items:
	      - tank/htdocs
	      tags: zfs-layout

To apply the playbook it's easiest to call the ``configure`` command again.
While Ansible is smart enough to only apply those parts that actually need to be applied again that process can become quite slow, as playbooks grow in size.
So here, we tag the new task with ``zfs-layout``, so we can call it explicitly::

	ploy configure jailhost -t zfs-layout

.. note:: You should see an ``INFO`` entry in the output that tells you which playbook the ``configure`` command has used.


Exercise
--------

In the quickstart, we've created a demo jail which conveniently already contains a webserver.

Repurpose it to create a jail named ``webserver`` which has nginx installed into it.

Do this by first terminating the demo jail, *then* renaming it, otherwise we will have an 'orphaned' instance which would interfere with the new jail::

	ploy terminate demo_jail

Now we can mount the website ZFS into it like so::

	[ez-instance:webserver]
	master = jailhost
	ip = 10.0.0.2
	mounts =
{'fraction_non_alphanumeric': 0.07346082089552239, 'fraction_numerical': 0.0023320895522388058, 'mean_word_length': 3.4817136886102404, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2104512', 'n_tokens_mistral': 1237, 'n_tokens_neox': 1163, 'n_words': 626}