Documentation for Temporary Container Experiment Playbook
Overview
- Playbook Name: Temporary Container Experiment
- Version: 0.8.1
- Description:
This playbook establishes an ephemeral storage environment using
device mapperandbtrfssubvolumes to manage systemd-nspawn containers. The playbook also ensures idempotency and deterministic naming conventions for loop devices, and generates theloop_device.targetfile to store thebtrfs subvolumesused to hold thevolume poolbtrfs subvolumes, which refer the pool of storage to be used inside another system.Storage Poolrefers the host or builder, theVolume Poolrefers to the target system or guest container
Usage
This playbook can be executed with these overridable values when running ansible-playbook playbooks/Sandbox/Temporary_Container_Experiment.yml ...
-e [container_name=<CONTAINER_NAME>][,container_collection=<COLLECTION_NAME>][,ephemeral_base_path=<EPHEMERAL_BASE_PATH>]'
Scope
The playbook broadens the category to instantiate device mapper-based storage setups, ensuring idempotent naming for loop devices.
Requirements
- Setup Storage Pool Target: Configure with the Storage role.
- Setup Volume Pool: This includes targeting a block device image through a loop device, which is specified by the
storage_loop_device_targetvariable. Here’s an example configuration:role: name: storage storage: loop_device: name: <LOOP_DEVICE_NAME> target: <LOOP_DEVICE_TARGET> - Create a role
orchestration_architect.Storage.loop_device:`*<LOOP_DEVICE_STATE>*`: present | absent | info | offline | online - Ensure Storage Role Specifics: Add functor details to the
loop_devicerole. - Deploy: Mount a
btrfssubvolume in the ephemeral storage pool withintmpfsusingnspawn. - Utilize
copy-on-writeMechanisms: Design composable overlays withbtrfs_subvolumes.
Playbook Steps
Pre-run Playbooks
Import a pre-run playbook to set up the environment:
- ansible.builtin.import_playbook: "../Meta/Setup_Environment"
Task Details
-
Prepare Var Assignments: Define key variables to be overridden if necessary.
vars: container_collection: "Sandbox" container_name: "Container_ALPHA" ephemeral_base_path: "/mnt/orchestration_architect/ephemeral" ephemeral_storage_pool: "{{ ephemeral_base_path }}/{{ container_collection }}/storage_pool" ephemeral_storage_pool_size: 4G container_base_size: 2G -
Create Ephemeral Storage Pool for Containers:
- Create mount point for ephemeral storage pool.
- name: Create Ephemeral Storage Pool for Containers include_role: name: storage vars: storage_mount_table: - source: tmpfs type: tmpfs options: "size={{ ephemeral_storage_pool_size }}" target: "{{ ephemeral_storage_pool }}" state: "mounted" -
Create Volume Storage:
- Directory creation for mount point and volume pool.
- File creation for block device image.
- Loop device setup.
btrfsfilesystem configuration and subvolume creation.
- name: Create Volume Storage tasks: - name: Create Ephemeral Storage Pool mount point ansible.builtin.file: path: "{{ ephemeral_mount_point }}" state: directory mode: '0700' - name: Create Ephemeral Storage Pool ansible.builtin.mount: path: "{{ ephemeral_mount_point }}" src: "tmpfs" fstype: "tmpfs" opts: "size={{ ephemeral_storage_pool_size }}" state: "mounted" - name: Create container volume pool mount point directory ansible.builtin.file: path: "{{ container_volume_pool_mount_point }}" state: directory mode: '0700' - name: Create file for volume collection block device image community.general.filesize: path: "{{ container_volume_pool_block_device_image }}" size: "{{ container_base_size }}" - name: Create loop device to expose the volume pool command: "losetup --find --nooverlap --show {{ container_volume_pool_block_device_image }}" register: loop_device_result - name: Generate Container Volumes ansible.builtin.include_role: "storage" vars: storage_loopback_device: name: "{{ oollection_name }}" - name: Create BTRFS filesystem on the loop device filesystem: path: "{{ loop_device_result.stdout }}" type: btrfs opts: "-n 16k" - name: Create BTRFS subvolume for @init command: btrfs subvolume create {{ container_volume_pool }}/@init - name: Create @base subvolume command: btrfs subvolume snapshot -r {{ container_volume_pool }}/@init {{ container_volume_pool }}/@base - name: Create @overlay subvolume for changes command: btrfs subvolume create {{ container_volume_pool }}/@overlay -
Overlay and Initial Snapshot Configuration:
- Directory configurations for overlay.
- Initial snapshot creation.
- name: Create overlay directories for nspawn ansible.builtin.file: path: "{{ ephemeral_storage_pool }}/overlay" state: directory mode: '0700' - name: Create initial snapshot for container command: btrfs subvolume snapshot {{ ephemeral_storage_pool }}/@base {{ ephemeral_storage_pool }}/@initial -
Systemd-nspawn Container Setup:
- Configuration and start of the systemd-nspawn container.
- name: Configure systemd-nspawn container community.general.systemd_nspawn: name: arch_container image: "{{ container_volume_pool }}/@base" machine: "arch_sandbox_container" command: /bin/zsh state: started boot: false
System Managed Regions
- 01_File_Header
This region is identified by the first
---marker matches the regex expression '^---$' - 02_Managed_Region_Before_Content
Managed block for pre-run steps. See
meta_playbooksspecification for more details. - 04_Managed_Region_After_Content Managed block for post-run steps (currently empty).
Orchestration Architect Overview
Tasks
Repository Structure
Branch 0.8.0-assets
Assets Branch - Stores assets and relevant metadata
This needs to be added to LFS and tied to assets branch.
Branch 0.8.0-seed
The minimal or last previous version required files to migrate/build the pristine environment. This process is to be automated with a CI/CD pipeline.
Branch 0.8.0-pristine
The workspace after bootstrapping the 0.8.0-seed branch. Updated via diffs between pristine and the bootstrapped 0.8.0-seed
Branch 0.8.0-dev
WIP filling this in