Small Ansible - Minimal Ansible-compatible runner for Windows and Linux
Project description
Sansible
A minimal, pure-Python Ansible runner for Windows and Linux
Sansible runs Ansible playbooks natively on Windows without WSL, targeting both Windows (WinRM) and Linux (SSH) hosts. It delivers 80% of Ansible's value with 20% of the code.
โจ Highlights
- ๐ช Windows Native โ Run as a control node on Windows, no WSL required
- ๐ Pure Python โ Ships as
py3-none-anywheel, no compiled extensions - ๐ Fast Setup โ
pip install sansibleand you're ready - ๐ฆ Ansible Compatible โ Uses the same playbook/inventory syntax
- ๐ฏ 63 Modules โ Core modules for real-world automation
- ๐ Galaxy FQCN Support โ Use
ansible.builtin.*andansible.windows.*FQCNs
๐ Quick Start
Installation
# Basic installation (local execution only)
pip install sansible
# With SSH support (Linux/Unix targets)
pip install "sansible[ssh]"
# With WinRM support (Windows targets)
pip install "sansible[winrm]"
# Full installation (all transports)
pip install "sansible[all]"
Your First Playbook
Create hello.yml:
---
- name: Hello World
hosts: localhost
gather_facts: false
tasks:
- name: Say hello
debug:
msg: "Hello from Sansible!"
- name: Run a command
command: echo "It works!"
register: result
- name: Show result
debug:
var: result.stdout
Run it:
sansible-playbook -i localhost, hello.yml
๐ Module Compatibility Matrix
โ Tested and Working (Live System Verified)
All modules have been tested on live Linux (RHEL 8.5) and Windows (Server 2019) systems.
Linux Modules
| Module | Status | Notes |
|---|---|---|
ping |
โ Tested | Returns pong |
debug |
โ Tested | msg, var output |
command |
โ Tested | Execute commands |
shell |
โ Tested | Shell expansion works |
raw |
โ Tested | Raw command execution |
copy |
โ Tested | content, src/dest |
file |
โ Tested | directory, touch, absent |
stat |
โ Tested | File info retrieval |
slurp |
โ Tested | Read file content (base64) |
template |
โ Tested | Jinja2 templating |
lineinfile |
โ Tested | Line management |
blockinfile |
โ Tested | Block management |
replace |
โ Tested | Regex replacement |
find |
โ Tested | File discovery |
tempfile |
โ Tested | Create temp files |
set_fact |
โ Tested | Variable setting |
assert |
โ Tested | Condition assertion |
fail |
โ Tested | Intentional failure |
wait_for |
โ Tested | Port/file waiting |
pause |
โ Tested | Execution pause |
include_vars |
โ Tested | Load YAML vars |
meta |
โ Tested | noop action |
setup |
โ Tested | Fact gathering |
service |
โ Tested | Service management (check mode) |
user |
โ Tested | User management (check mode) |
group |
โ Tested | Group management (check mode) |
script |
โ ๏ธ Partial | Requires local script file |
fetch |
โ Tested | Download files from remote |
get_url |
โ Available | Download from URL |
uri |
โ Available | HTTP requests |
apt |
โ Available | Debian package management |
yum |
โ Available | RedHat package management |
dnf |
โ Available | Fedora package management |
pip |
โ Available | Python package management |
git |
โ Available | Git operations |
cron |
โ Available | Cron job management |
systemd |
โ Available | Systemd service management |
hostname |
โ Available | Hostname management |
known_hosts |
โ Available | SSH known hosts |
unarchive |
โ Available | Archive extraction |
add_host |
โ Available | Dynamic inventory |
group_by |
โ Available | Dynamic grouping |
getent |
โ Available | Name service lookup |
reboot |
โ Available | System reboot |
wait_for_connection |
โ Available | Connection waiting |
Windows Modules
| Module | Status | Notes |
|---|---|---|
win_ping |
โ Tested | Returns pong |
win_command |
โ Tested | Execute commands |
win_shell |
โ Tested | PowerShell execution |
win_copy |
โ Tested | File copy with content |
win_file |
โ Tested | directory, absent states |
win_stat |
โ Tested | File info retrieval |
win_slurp |
โ Tested | Read file content |
win_lineinfile |
โ Tested | Line management |
win_service |
โ Tested | Service management |
win_wait_for |
โ Tested | Port/file waiting |
win_template |
โ ๏ธ Partial | Requires local template |
win_reboot |
โ Tested | System reboot (check mode) |
win_user |
โ Available | User management |
win_group |
โ Available | Group management |
win_get_url |
โ Available | Download from URL |
Galaxy FQCN Support
Sansible supports Fully Qualified Collection Names (FQCNs):
| FQCN Pattern | Status | Notes |
|---|---|---|
ansible.builtin.* |
โ Tested | Maps to native modules |
ansible.windows.* |
โ Tested | Maps to native win_* modules |
ansible.posix.* |
โ Tested | Remote execution on Linux |
community.general.* |
โ Available | Remote execution on Linux |
# All these work identically:
- ansible.builtin.copy:
content: "hello"
dest: /tmp/test.txt
- copy:
content: "hello"
dest: /tmp/test.txt
See docs/GALAXY.md for full Galaxy support details.
๐ง Playbook Features
โ Fully Working
| Feature | Status | Live Tested |
|---|---|---|
| Multiple plays | โ | Yes |
Variables (vars, vars_files) |
โ | Yes |
Conditionals (when) |
โ | Yes |
Loops (loop, with_items) |
โ | Yes |
| Register results | โ | Yes |
changed_when / failed_when |
โ | Yes |
ignore_errors |
โ | Yes |
Fact gathering (gather_facts) |
โ | Yes |
Handlers (notify) |
โ | Yes |
Check mode (--check) |
โ | Yes |
Diff mode (--diff) |
โ | Yes |
Extra vars (-e) |
โ | Yes |
Tags (--tags, --skip-tags) |
โ | Yes |
Limit (--limit, -l) |
โ | Yes |
Verbose (-v, -vv, -vvv) |
โ | Yes |
JSON output (--json) |
โ | Yes |
โ Working with Notes
| Feature | Status | Notes |
|---|---|---|
become (sudo) |
โ | Requires ansible_become_password |
delegate_to |
โ | Tested with localhost |
include_tasks / import_tasks |
โ | Task file inclusion |
include_role / import_role |
โ | Role inclusion |
block/rescue/always |
โ ๏ธ | Block works, rescue needs review |
Vault (--vault-password-file) |
โ | Requires cryptography |
| Roles | โ | tasks, defaults, vars, handlers |
| Dynamic inventory | โ | JSON format scripts |
โ Not Supported
| Feature | Reason |
|---|---|
async / poll |
Complexity, limited use |
| Galaxy collections install | Out of scope |
| Callbacks/Plugins | Architecture |
| Molecule testing | External tool |
sansible / sansible-inventory CLIs |
Ad-hoc/inventory entrypoints currently placeholders |
๐ Jinja2 Filters
โ Available Filters
| Filter | Example | Status |
|---|---|---|
default / d |
{{ var | default('fallback') }} |
โ |
lower |
{{ name | lower }} |
โ |
upper |
{{ name | upper }} |
โ |
trim |
{{ text | trim }} |
โ |
replace |
{{ text | replace('a', 'b') }} |
โ |
to_json |
{{ dict | to_json }} |
โ |
to_yaml |
{{ dict | to_yaml }} |
โ |
bool |
{{ 'yes' | bool }} |
โ |
int |
{{ '42' | int }} |
โ |
string |
{{ 42 | string }} |
โ |
length |
{{ list | length }} |
โ |
join |
{{ list | join(',') }} |
โ |
first |
{{ list | first }} |
โ |
last |
{{ list | last }} |
โ |
basename |
{{ path | basename }} |
โ |
dirname |
{{ path | dirname }} |
โ |
regex_replace |
{{ text | regex_replace('pattern', 'replace') }} |
โ |
b64decode |
{{ encoded | b64decode }} |
โ |
b64encode |
{{ text | b64encode }} |
โ |
๐งช Test Results
Unit Tests: 269 Passed โ
tests/unit/test_become.py - 8 tests โ
tests/unit/test_block.py - 5 tests โ
tests/unit/test_block_execution.py - 6 tests โ
tests/unit/test_check_diff_mode.py - 10 tests โ
tests/unit/test_executor_linear.py - 12 tests โ
tests/unit/test_galaxy.py - 32 tests โ
tests/unit/test_handlers.py - 8 tests โ
tests/unit/test_include_tasks.py - 5 tests โ
tests/unit/test_inventory.py - 9 tests โ
tests/unit/test_lineinfile_module.py - 10 tests โ
tests/unit/test_playbook_parse.py - 12 tests โ
tests/unit/test_playbook_roles.py - 7 tests โ
tests/unit/test_runner.py - 6 tests โ
tests/unit/test_stat_module.py - 6 tests โ
tests/unit/test_tags_limit.py - 8 tests โ
tests/unit/test_templating.py - 25 tests โ
tests/unit/test_vault.py - 12 tests โ
tests/unit/test_wait_for_module.py - 6 tests โ
tests/unit/test_win_service.py - 8 tests โ
... and more
Live System Tests
Linux (RHEL 8.5, 192.168.10.181)
- SSH Connection: โ
- Command modules: โ
- File modules: โ
- gather_facts: โ
- Handlers: โ
- Galaxy FQCN: โ
Windows (Server 2019, 192.168.100.3)
- WinRM Connection: โ
- win_* modules: โ
- gather_facts: โ
- Galaxy FQCN: โ
๐ Examples
The examples/playbooks/ directory contains runnable examples:
| Playbook | Features |
|---|---|
| 01_basics.yml | debug, set_fact, command, shell |
| 02_conditionals.yml | when, loop, register |
| 03_file_management.yml | file, copy, stat, lineinfile |
| 04_handlers.yml | handlers, notify |
| 05_blocks.yml | block, rescue, always |
| 06_become.yml | become (sudo) |
| 07_gather_facts.yml | gather_facts, setup |
| win_01_basics.yml | win_command, win_shell |
| win_02_services.yml | win_service |
| win_03_files.yml | win_stat, win_lineinfile |
sansible-playbook -i examples/playbooks/inventory.ini examples/playbooks/01_basics.yml
๐ CLI Reference
sansible-playbook -i INVENTORY PLAYBOOK [OPTIONS]
Options:
-i, --inventory FILE Inventory file (required)
-l, --limit PATTERN Limit to matching hosts
-t, --tags TAGS Only run tagged tasks
--skip-tags TAGS Skip tagged tasks
-e, --extra-vars VARS Extra variables (JSON or key=value)
-f, --forks N Parallel limit (default: 5)
-C, --check Dry-run mode
--diff Show file changes
--json JSON output
--vault-password-file Vault password file
--ask-vault-pass Prompt for vault password
-v/-vv/-vvv Verbosity
Examples
# Basic execution
sansible-playbook -i inventory.ini playbook.yml
# Limit to hosts
sansible-playbook -i inventory.ini playbook.yml -l webservers
# Check mode with diff
sansible-playbook -i inventory.ini playbook.yml --check --diff
# Extra variables
sansible-playbook -i inventory.ini playbook.yml -e '{"version": "2.0"}'
# JSON output
sansible-playbook -i inventory.ini playbook.yml --json
๐ Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 2 | Host failure(s) |
| 3 | Parse/syntax error |
| 4 | Unsupported feature |
๐ง Development
# Clone
git clone https://github.com/small-ansible/sansible.git
cd sansible
# Install with dev dependencies
pip install -e ".[dev]"
# Run tests
pytest tests/unit/ -v
# Build wheel
pip wheel . -w dist/
Quick Dev Setup with uv
Linux:
curl -LsSf https://astral.sh/uv/install.sh | sh
git clone https://github.com/small-ansible/sansible.git && cd sansible
uv venv && source .venv/bin/activate
uv pip install -e ".[dev,ssh,winrm]"
pytest tests/unit/ -q --tb=no
Windows (PowerShell):
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
git clone https://github.com/small-ansible/sansible.git; cd sansible
uv venv; .\.venv\Scripts\Activate.ps1
uv pip install -e ".[dev,ssh,winrm]"
pytest tests/unit/ -q --tb=no
AI Agent Testing
For automated testing with AI agents, use the prompts in .github/:
| Prompt | Use Case |
|---|---|
| AGENT_TEST_PROMPT.md | Windows control node |
| AGENT_TEST_PROMPT_LINUX.md | Linux control node |
# Fetch and follow the prompt:
curl -s https://raw.githubusercontent.com/small-ansible/sansible/main/.github/AGENT_TEST_PROMPT_LINUX.md
๐ Documentation
- Architecture โ System design
- Compatibility โ Feature matrix
- Galaxy Support โ FQCN and collections
- Testing โ Test instructions
- Contributing โ Development guide
๐ License
MIT License โ See LICENSE for details.
Made with โค๏ธ for DevOps engineers who need to run playbooks on Windows.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sansible-0.4.1.tar.gz.
File metadata
- Download URL: sansible-0.4.1.tar.gz
- Upload date:
- Size: 133.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82b8faf3952d13937342e6872b0297a12c80ae0c71bc31aed8bca1d269844d52
|
|
| MD5 |
f47c3bd2b195412fe8088edc29635ee7
|
|
| BLAKE2b-256 |
c9f8ca935a97a1e8f7ad68414758f6c624e6127325a4bc52526688f45ae61715
|
File details
Details for the file sansible-0.4.1-py3-none-any.whl.
File metadata
- Download URL: sansible-0.4.1-py3-none-any.whl
- Upload date:
- Size: 178.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a27834cad762745a1785d17be1790fe1067fdad0ea9b585e04b86bab98338e9
|
|
| MD5 |
d69a8f74a87d0058d4a856b2ed82d618
|
|
| BLAKE2b-256 |
2c32712dfe593cc4dabba279a8fd54375c83d1881632d81a04b22d1b7ca6384a
|