Your First Productive Polycrate Workspace: A Checklist for Getting Started
TL;DR A well-named, clearly structured Polycrate workspace is half the battle: a consistent name …
Diese Serie zeigt Schritt für Schritt, wie Ansible mit Polycrate zu einer strukturierten, teilbaren und compliance-fähigen Automatisierungsplattform wird – von den Grundlagen bis zu Enterprise-Szenarien.
curl command – no pip, no virtualenv, no local Ansible installation required.webserver within it.nginx on a Linux host.For many admins and engineers, Ansible has long been the Swiss Army knife for automation: configurations, patches, deployments, Windows management, networking – everything is possible with playbooks.
You might know the problem from everyday life:
ansible installed only in an old virtualenvansible.cfg settings and scattered inventoriesPolycrate addresses these issues without replacing Ansible:
ssh, optionally kubectl, helm, etc.). Your host only needs Polycrate, nothing else.block.poly), defined actions, and a reusable structure.ansible-playbook commands, you use simple actions like polycrate run webserver install. Even colleagues without deep Ansible knowledge can execute this.In this post, we will go through the following steps:
webserverIf you want to continue after this: Later posts will delve deeper into topics like block versioning, registry, and workspace encryption. You will lay the groundwork today.
Polycrate comes with its own containerized toolchain. So you do not install Ansible directly on your system, but only the Polycrate CLI, which takes care of everything else.
The current installation instructions can be found in the
Installation Documentation.
Typically, installation on Linux and macOS boils down to a one-liner with curl. The pattern looks like this:
curl -sSfL https://<current-install-url-from-docs> | sudo bashImportant:
<current-install-url-from-docs> with the URL from the official documentation.sudo is necessary if Polycrate is to be installed system-wide (e.g., to /usr/local/bin).polycrate should be in the PATH.Then quickly check your installation:
polycrate versionYou should see output similar to this:
polycrate version vX.Y.ZYour local machine is now ready. Ansible, Python, etc., will be provided in the container, not on your host.
A Polycrate workspace is your project folder for automation – comparable to a Git repo, but with clear structure and metadata.
First, create a new directory and navigate into it:
mkdir acme-corp-automation
cd acme-corp-automationNow initialize the workspace:
polycrate workspace initPolycrate will ask you for a name for the workspace and then create the base files. The name is written into workspace.poly and serves as a logical identifier in larger setups.
Why this step is important:
Details on workspaces can be found in the
Workspace Documentation.
After polycrate workspace init, your directory typically looks like this:
.
├── workspace.poly
├── blocks/
├── artifacts/
│ └── secrets/
└── CHANGELOG.polyThe most important elements:
workspace.poly
Central manifest of the workspace. Here you define which blocks are active in this workspace, which workflows exist, and you can store workspace-wide configurations.
blocks/
This is where your local blocks are located. Each block is a subfolder with at least one block.poly and the associated files (e.g., Ansible playbooks).
artifacts/secrets/
Storage location for sensitive files, e.g., kubeconfigs or later encrypted secrets. Polycrate supports workspace encryption with age, allowing you to work securely even in regulated environments (see Workspace Encryption).
CHANGELOG.poly
Optional but helpful for traceability. Here you can document changes to blocks and workflows – useful for compliance and audits.
Take a quick look at workspace.poly. Right after the init, it might look like this:
name: acme-corp-automationWe will soon expand this file with our first block.
Before we build the first block, Ansible needs a target host. Polycrate always uses a YAML inventory in the workspace root as the default.
Create a file inventory.yml in the workspace root:
touch inventory.ymlFill it in like this:
all:
hosts:
web01.acme-corp.com:
ansible_user: ubuntuExplanations:
all.hosts.web01.acme-corp.com is your target host. Replace it with the real FQDN or IP of your server.ansible_user is the SSH user, e.g., ubuntu for Ubuntu cloud images.How exactly Polycrate gets your SSH keys and connections into the container is described in the
SSH Documentation. For this tutorial, we assume you can set up SSH access to the host.
Important: The inventory is always located in the workspace root and named inventory.yml. Polycrate automatically sets the environment variable ANSIBLE_INVENTORY to this file.
webserverNow it gets concrete. We are building a block that:
nginx on your hostCreate the block folder:
mkdir -p blocks/webserver
cd blocks/webserverblock.polyIn each block, there is a block.poly that describes:
Create blocks/webserver/block.poly with the following content:
name: webserver
kind: ansible
config:
package_name: "nginx"
actions:
- name: install
description: "Installs nginx, starts the service, and checks the status"
playbook: install.ymlKey points:
name
The logical name of the block. We will later reference it in the workspace as webserver.
kind: ansible
Tells Polycrate that this block executes Ansible playbooks.
config
Configurable values of the block. Here, for example, which package is installed. Later, you can also define port numbers, paths, etc., and use them in the playbook as Jinja2 variables.
actions
List of actions this block offers. Each action has at least:
name: Identifier for polycrate run <block> <action>description: Documentationplaybook: the Ansible playbook to execute (relative to the block folder)More on blocks: Block Documentation and
Best Practices.
install.ymlNow comes our first meaningful Hello-World playbook. Create blocks/webserver/install.yml:
- name: Deploy webserver with nginx
hosts: all
become: true
gather_facts: true
vars:
webserver_package: "{{ block.config.package_name }}"
tasks:
- name: Update package cache (Debian/Ubuntu)
ansible.builtin.apt:
update_cache: true
when: ansible_os_family == "Debian"
- name: Install nginx
ansible.builtin.package:
name: "{{ webserver_package }}"
state: present
- name: Ensure nginx service is running and enabled
ansible.builtin.service:
name: "{{ webserver_package }}"
state: started
enabled: true
- name: Retrieve nginx status
ansible.builtin.command: systemctl status "{{ webserver_package }}"
register: nginx_status
changed_when: false
- name: Output nginx status
ansible.builtin.debug:
msg: "{{ nginx_status.stdout_lines }}"What happens here?
hosts: all
All hosts from inventory.yml. Polycrate ensures the inventory is available in the container.
become: true
Ansible uses sudo to install packages and manage services.
vars.webserver_package
Value from block.config.package_name (our config block from block.poly). This allows you to use the same block for different web server packages later without changing the playbook.
Tasks:
nginx (or the configured package name)systemctl status – so you can see in the output if everything is okayAnsible is idempotent: If nginx is already installed and started, no unnecessary changes are made. Polycrate fully benefits from this strength.
To let Polycrate know that this block exists, you need to register it in the workspace.
Navigate back to the workspace root:
cd ../../Open workspace.poly and add the block entry:
name: acme-corp-automation
blocks:
- name: webserver
from: webserver
config:
package_name: "nginx"Explanation:
blocks
List of all block instances in this workspace.
name: webserver
Name of the instance in the workspace. It doesn’t have to be, but can be the same as the block name.
from: webserver
Path to your local block. For blocks from a registry (e.g., PolyHub), a URL with an explicit version would be here, e.g.,
from: cargo.ayedo.cloud/ayedo/infra/nginx:0.3.1
– we will cover versioning and sharing in a later post in this series.
config
Workspace-specific configuration for this instance. These values end up in the playbook as block.config.*.
Polycrate deliberately separates:
block.poly in the block folder)blocks: in workspace.poly)This allows you to use the same block multiple times with different configurations.
Now comes the moment of truth: We execute our block.
In the workspace root:
polycrate run webserver installWhat happens:
workspace.poly and finds the block `websTL;DR A well-named, clearly structured Polycrate workspace is half the battle: a consistent name …
TL;DR Plain Ansible is a powerful tool for ad-hoc automation, quick scripts, and simple setups – but …
TL;DR Most environments are hybrid: Windows servers for AD, file services, and specialized …