ansiburr 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ansiburr-0.0.1/.github/workflows/ci.yml +70 -0
- ansiburr-0.0.1/.gitignore +33 -0
- ansiburr-0.0.1/CHANGELOG.md +62 -0
- ansiburr-0.0.1/LICENSE +203 -0
- ansiburr-0.0.1/NOTICE +41 -0
- ansiburr-0.0.1/PKG-INFO +186 -0
- ansiburr-0.0.1/README.md +153 -0
- ansiburr-0.0.1/REFERENCE.md +33 -0
- ansiburr-0.0.1/examples/cert_rotation/fsm.py +206 -0
- ansiburr-0.0.1/examples/coffee_order_ansible/fsm.py +299 -0
- ansiburr-0.0.1/examples/config_drift/default.conf.j2 +9 -0
- ansiburr-0.0.1/examples/config_drift/fsm.py +243 -0
- ansiburr-0.0.1/examples/fact_driven_inspect/fsm.py +170 -0
- ansiburr-0.0.1/examples/hero.py +273 -0
- ansiburr-0.0.1/examples/localhost_disk_check.py +97 -0
- ansiburr-0.0.1/examples/log_triage/fsm.py +394 -0
- ansiburr-0.0.1/examples/mast_sre_agent/fsm.py +719 -0
- ansiburr-0.0.1/examples/plan_then_apply/fsm.py +302 -0
- ansiburr-0.0.1/examples/service_remediation/Dockerfile +39 -0
- ansiburr-0.0.1/examples/service_remediation/fsm.py +135 -0
- ansiburr-0.0.1/examples/service_remediation/setup.sh +20 -0
- ansiburr-0.0.1/examples/service_remediation/start.sh +27 -0
- ansiburr-0.0.1/examples/service_remediation/teardown.sh +4 -0
- ansiburr-0.0.1/examples/sidecar_lifecycle/fsm.py +212 -0
- ansiburr-0.0.1/examples/user_provisioning/fsm.py +219 -0
- ansiburr-0.0.1/pyproject.toml +72 -0
- ansiburr-0.0.1/src/ansiburr/__init__.py +76 -0
- ansiburr-0.0.1/src/ansiburr/_action.py +170 -0
- ansiburr-0.0.1/src/ansiburr/_convert.py +368 -0
- ansiburr-0.0.1/src/ansiburr/_host.py +247 -0
- ansiburr-0.0.1/src/ansiburr/_runner.py +148 -0
- ansiburr-0.0.1/src/ansiburr/_wait.py +136 -0
- ansiburr-0.0.1/src/ansiburr/py.typed +0 -0
- ansiburr-0.0.1/tests/__init__.py +0 -0
- ansiburr-0.0.1/tests/fixtures/playbook_register.yml +7 -0
- ansiburr-0.0.1/tests/fixtures/playbook_simple.yml +9 -0
- ansiburr-0.0.1/tests/fixtures/playbook_unsupported_block.yml +6 -0
- ansiburr-0.0.1/tests/fixtures/playbook_unsupported_loop.yml +9 -0
- ansiburr-0.0.1/tests/fixtures/playbook_unsupported_roles.yml +4 -0
- ansiburr-0.0.1/tests/fixtures/playbook_with_when.yml +14 -0
- ansiburr-0.0.1/tests/test_convert.py +54 -0
- ansiburr-0.0.1/tests/test_failures.py +221 -0
- ansiburr-0.0.1/tests/test_smoke.py +250 -0
- ansiburr-0.0.1/uv.lock +1416 -0
- ansiburr-0.0.1/vhs/hero.gif +0 -0
- ansiburr-0.0.1/vhs/hero.tape +13 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
quality:
|
|
12
|
+
name: lint, type-check, test
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
strategy:
|
|
15
|
+
fail-fast: false
|
|
16
|
+
matrix:
|
|
17
|
+
python-version: ["3.11", "3.12", "3.13"]
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- name: Check out repository
|
|
21
|
+
uses: actions/checkout@v4
|
|
22
|
+
|
|
23
|
+
- name: Install uv
|
|
24
|
+
uses: astral-sh/setup-uv@v5
|
|
25
|
+
with:
|
|
26
|
+
version: "0.5.x"
|
|
27
|
+
|
|
28
|
+
- name: Pin Python ${{ matrix.python-version }}
|
|
29
|
+
run: uv python install ${{ matrix.python-version }}
|
|
30
|
+
|
|
31
|
+
- name: Sync dependencies
|
|
32
|
+
run: uv sync --python ${{ matrix.python-version }}
|
|
33
|
+
|
|
34
|
+
- name: Ruff format check
|
|
35
|
+
run: uv run ruff format --check .
|
|
36
|
+
|
|
37
|
+
- name: Ruff lint
|
|
38
|
+
run: uv run ruff check .
|
|
39
|
+
|
|
40
|
+
- name: Mypy
|
|
41
|
+
run: uv run mypy src/ansiburr
|
|
42
|
+
|
|
43
|
+
- name: Pytest
|
|
44
|
+
# Tests that talk to ansible-runner need ansible-playbook on PATH;
|
|
45
|
+
# ansible-core (a runtime dep) provides it through uv sync. Skip
|
|
46
|
+
# the network-touching unreachable test in CI (RFC 5737 traffic
|
|
47
|
+
# behavior varies by network policy).
|
|
48
|
+
run: uv run pytest tests/ -v --deselect tests/test_failures.py::test_unreachable_host_sets_last_unreachable
|
|
49
|
+
|
|
50
|
+
build:
|
|
51
|
+
name: build wheel + sdist
|
|
52
|
+
runs-on: ubuntu-latest
|
|
53
|
+
needs: quality
|
|
54
|
+
steps:
|
|
55
|
+
- uses: actions/checkout@v4
|
|
56
|
+
|
|
57
|
+
- name: Install uv
|
|
58
|
+
uses: astral-sh/setup-uv@v5
|
|
59
|
+
with:
|
|
60
|
+
version: "0.5.x"
|
|
61
|
+
|
|
62
|
+
- name: Build distributions
|
|
63
|
+
run: uv build
|
|
64
|
+
|
|
65
|
+
- name: Upload artifacts
|
|
66
|
+
uses: actions/upload-artifact@v4
|
|
67
|
+
with:
|
|
68
|
+
name: dist
|
|
69
|
+
path: dist/*
|
|
70
|
+
retention-days: 7
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
*.egg
|
|
6
|
+
.eggs/
|
|
7
|
+
|
|
8
|
+
# Build artifacts
|
|
9
|
+
build/
|
|
10
|
+
dist/
|
|
11
|
+
.venv/
|
|
12
|
+
venv/
|
|
13
|
+
|
|
14
|
+
# Tooling caches
|
|
15
|
+
.mypy_cache/
|
|
16
|
+
.ruff_cache/
|
|
17
|
+
.pytest_cache/
|
|
18
|
+
|
|
19
|
+
# Demo SSH keys — regenerated per-clone by examples/service_remediation/setup.sh
|
|
20
|
+
examples/service_remediation/.demo_key
|
|
21
|
+
examples/service_remediation/.demo_key.pub
|
|
22
|
+
|
|
23
|
+
# Local demo state co-located with each example
|
|
24
|
+
examples/coffee_order_ansible/.queue/
|
|
25
|
+
examples/.hero-state/
|
|
26
|
+
|
|
27
|
+
# Burr local tracker output (project-relative if anyone re-roots HOME)
|
|
28
|
+
.burr/
|
|
29
|
+
|
|
30
|
+
# Editor / OS
|
|
31
|
+
.vscode/
|
|
32
|
+
.idea/
|
|
33
|
+
.DS_Store
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to ansiburr are documented in this file. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and this project adheres
|
|
5
|
+
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [0.0.1] - 2026-05-21
|
|
10
|
+
|
|
11
|
+
Initial alpha release.
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- `module_action` decorator wrapping `ansible-runner` as a Burr `@action`.
|
|
16
|
+
Supports `reads`, `writes`, `register`, `host`, `connection`, `become`,
|
|
17
|
+
`check_mode`, `diff`.
|
|
18
|
+
- `host()` factory plus `Host` dataclass for connection profiles. Captures
|
|
19
|
+
Ansible hostvars and `become` once; exposes shorthand decorators
|
|
20
|
+
(`.module`, `.service`, `.systemd`, `.shell`, `.command`, `.copy`,
|
|
21
|
+
`.template`, `.file`, `.find`, `.slurp`, `.uri`).
|
|
22
|
+
- `Host.gather_facts()` runs `ansible.builtin.setup` and flattens facts
|
|
23
|
+
into top-level State keys. `Host.initial_facts()` seeds placeholder
|
|
24
|
+
values so transitions can read fact keys before the gather has executed.
|
|
25
|
+
- Ambient sentinel state keys written by every `@module_action`:
|
|
26
|
+
`_last_action`, `_last_failed`, `_last_changed`, `_last_unreachable`,
|
|
27
|
+
`_last_msg`. `initial_sentinels()` provides placeholder seeds.
|
|
28
|
+
- `snapshot_sentinels(write="failure_reason")` pure-Python action that
|
|
29
|
+
preserves the current diagnostic into a durable state key, surviving
|
|
30
|
+
any recovery actions that overwrite the sentinels.
|
|
31
|
+
- `wait_until(name, check, condition_expr, max_attempts, interval_s,
|
|
32
|
+
on_success, on_timeout)` polling sub-graph builder. Returns a
|
|
33
|
+
`WaitGraph` to merge into an `ApplicationBuilder`. Each poll attempt
|
|
34
|
+
is a discrete Burr step.
|
|
35
|
+
- `from_playbook(path)` forward converter. Parses a YAML playbook and
|
|
36
|
+
returns a runnable `burr.core.Application`. Supports single play with
|
|
37
|
+
flat task list, `when:`, `register:`, `failed_when:`, `become:`,
|
|
38
|
+
`gather_facts:`, and play-level `vars:`. Raises
|
|
39
|
+
`UnsupportedPlaybookConstruct` for blocks, loops, handlers, includes,
|
|
40
|
+
roles, and multi-play structures.
|
|
41
|
+
- ControlPersist and pipelining enabled by default for SSH connection
|
|
42
|
+
reuse across modules targeting the same host.
|
|
43
|
+
- Eleven self-contained example FSMs in `examples/` spanning
|
|
44
|
+
`ansible.builtin`, `community.crypto`, `community.docker`,
|
|
45
|
+
`community.general`, and `ansible.posix`.
|
|
46
|
+
- VHS-recorded GIFs for two demos (`fact_driven_inspect`,
|
|
47
|
+
`plan_then_apply`) plus the tape sources.
|
|
48
|
+
- pytest suite with smoke, failure-mode, and converter coverage.
|
|
49
|
+
- GitHub Actions CI for Python 3.11, 3.12, 3.13 on Linux.
|
|
50
|
+
|
|
51
|
+
### Known gaps
|
|
52
|
+
|
|
53
|
+
- Single-host only. Multi-host inventories and parallel fan-out are not
|
|
54
|
+
yet supported; one Burr `Application` per host is the current pattern.
|
|
55
|
+
- No reverse converter. `from_playbook` covers the playbook-to-FSM
|
|
56
|
+
direction; FSM-to-playbook emission is on the roadmap.
|
|
57
|
+
- The Burr dependency is pinned to a tight range. Burr is incubating at
|
|
58
|
+
Apache, and an API change in a release ansiburr does not yet support
|
|
59
|
+
will break installs at version-resolution time rather than at runtime.
|
|
60
|
+
|
|
61
|
+
[0.0.1]: https://github.com/msradam/ansiburr/releases/tag/v0.0.1
|
|
62
|
+
[Unreleased]: https://github.com/msradam/ansiburr/compare/v0.0.1...HEAD
|
ansiburr-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
203
|
+
Copyright 2026 Adam Munawar Rahman
|
ansiburr-0.0.1/NOTICE
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
ansiburr
|
|
2
|
+
Copyright 2026 Adam Munawar Rahman
|
|
3
|
+
|
|
4
|
+
This product includes software developed under the Apache License, Version 2.0.
|
|
5
|
+
|
|
6
|
+
It depends on the following third-party software:
|
|
7
|
+
|
|
8
|
+
* ansible-runner (Apache License 2.0)
|
|
9
|
+
https://github.com/ansible/ansible-runner
|
|
10
|
+
Used as the supported Python API for invoking Ansible modules; directly
|
|
11
|
+
imported by ansiburr.
|
|
12
|
+
|
|
13
|
+
* Burr (Apache License 2.0)
|
|
14
|
+
https://github.com/apache/burr
|
|
15
|
+
Used as the state-machine substrate that ansiburr's @module_action
|
|
16
|
+
decorator produces actions for; directly imported by ansiburr.
|
|
17
|
+
|
|
18
|
+
* PyYAML (MIT License)
|
|
19
|
+
https://pyyaml.org/
|
|
20
|
+
Used to write Ansible playbook + inventory artifacts to the temporary
|
|
21
|
+
private_data_dir consumed by ansible-runner.
|
|
22
|
+
|
|
23
|
+
ansiburr also requires ansible-core at runtime, which is licensed under the
|
|
24
|
+
GNU General Public License, version 3 or later (GPL-3.0-or-later). ansiburr
|
|
25
|
+
does not import ansible-core's Python modules directly. ansible-runner
|
|
26
|
+
(Apache-2.0) invokes ansible-playbook as a separate subprocess; the
|
|
27
|
+
relationship to ansible-core is therefore tool-use rather than derivative
|
|
28
|
+
work. Users who redistribute an installed ansiburr environment should be
|
|
29
|
+
aware that the ansible-core component carries GPL-3.0+ obligations.
|
|
30
|
+
|
|
31
|
+
* ansible-core (GPL-3.0-or-later)
|
|
32
|
+
https://github.com/ansible/ansible
|
|
33
|
+
Invoked as a subprocess by ansible-runner; not imported by ansiburr.
|
|
34
|
+
|
|
35
|
+
The Ansible module collections that user FSMs actually call (ansible.builtin,
|
|
36
|
+
ansible.posix, community.crypto, community.docker, community.general, etc.)
|
|
37
|
+
have their own licenses, typically GPL-3.0-or-later for ansible.builtin
|
|
38
|
+
content and a mix of Apache-2.0 / GPL-3.0-or-later for community collections.
|
|
39
|
+
Refer to each collection's individual repository for the authoritative terms.
|
|
40
|
+
|
|
41
|
+
This notice is informational. It does not constitute legal advice.
|
ansiburr-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ansiburr
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Run Ansible modules as Burr state-machine actions in Python.
|
|
5
|
+
Project-URL: Homepage, https://github.com/msradam/ansiburr
|
|
6
|
+
Project-URL: Source, https://github.com/msradam/ansiburr
|
|
7
|
+
Project-URL: Issues, https://github.com/msradam/ansiburr/issues
|
|
8
|
+
Author-email: Adam Munawar Rahman <msrahmanadam@gmail.com>
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
License-File: NOTICE
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Framework :: Ansible
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: System Administrators
|
|
16
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
17
|
+
Classifier: Operating System :: MacOS
|
|
18
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
+
Classifier: Topic :: System :: Systems Administration
|
|
26
|
+
Classifier: Typing :: Typed
|
|
27
|
+
Requires-Python: <3.14,>=3.11
|
|
28
|
+
Requires-Dist: ansible-core<3,>=2.16
|
|
29
|
+
Requires-Dist: ansible-runner<3,>=2.4
|
|
30
|
+
Requires-Dist: burr[tracking]<0.41,>=0.40.2
|
|
31
|
+
Requires-Dist: pyyaml>=6
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# ansiburr
|
|
35
|
+
|
|
36
|
+
> *Pardon me, are you Ansi-Burr, Sir?*
|
|
37
|
+
|
|
38
|
+
Run Ansible modules as Burr state-machine actions in Python.
|
|
39
|
+
|
|
40
|
+
A single decorator wraps an Ansible module call as a Burr `@action`. The module runs through `ansible-runner` against the target host. Its result projects into Burr's `State`, and the action's `_last_failed`, `_last_changed`, and `_last_msg` flags become available to downstream transitions. The output is a standard Burr `Application` that runs, persists, traces, and serves like any other Burr graph.
|
|
41
|
+
|
|
42
|
+

|
|
43
|
+
|
|
44
|
+
## What you can build
|
|
45
|
+
|
|
46
|
+
- Self-healing service workflows that observe, decide, and remediate one Ansible module at a time, with every step visible in Burr's tracker.
|
|
47
|
+
- SRE agents where an LLM picks one label from a fixed allow-list of remediation actions and the FSM (not the model) enforces termination and retry policy.
|
|
48
|
+
- Cross-platform automation that gathers facts on the target up front and dispatches to the right modules based on the OS family, init system, or package manager.
|
|
49
|
+
- Plan-then-apply pipelines using Ansible's `--check` and `--diff` with a deterministic review gate before any change runs.
|
|
50
|
+
- Polling sub-graphs (port readiness, service health, file existence) where every poll attempt is a discrete step in the trace.
|
|
51
|
+
|
|
52
|
+
## Install
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
uv add ansiburr
|
|
56
|
+
# or
|
|
57
|
+
pip install ansiburr
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
`ansible-core` is pulled in transitively as a runtime requirement. Install additional collections via `ansible-galaxy`:
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
ansible-galaxy collection install community.general community.crypto community.docker ansible.posix
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Quickstart
|
|
67
|
+
|
|
68
|
+
An FSM that gathers facts from a remote host and dispatches to a distro-appropriate package inspection command:
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from burr.core import ApplicationBuilder, action, expr
|
|
72
|
+
from burr.tracking import LocalTrackingClient
|
|
73
|
+
from ansiburr import host, initial_sentinels
|
|
74
|
+
|
|
75
|
+
target = host(
|
|
76
|
+
"target",
|
|
77
|
+
ansible_host="server.example.com",
|
|
78
|
+
ansible_user="ops",
|
|
79
|
+
ansible_ssh_private_key_file="~/.ssh/id_ed25519",
|
|
80
|
+
become=True,
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
@target.shell(register="pkg_inspect")
|
|
85
|
+
def inspect_apt(state):
|
|
86
|
+
return {"cmd": "dpkg -l | wc -l"}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
@target.shell(register="pkg_inspect")
|
|
90
|
+
def inspect_dnf(state):
|
|
91
|
+
return {"cmd": "rpm -qa | wc -l"}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
@action(
|
|
95
|
+
reads=["ansible_distribution", "ansible_pkg_mgr", "pkg_inspect"],
|
|
96
|
+
writes=["report"],
|
|
97
|
+
)
|
|
98
|
+
def summarize(state):
|
|
99
|
+
count = (state["pkg_inspect"].get("stdout") or "0").strip()
|
|
100
|
+
return state.update(
|
|
101
|
+
report=f"{state['ansible_distribution']} ({state['ansible_pkg_mgr']}): {count} pkgs"
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
app = (
|
|
106
|
+
ApplicationBuilder()
|
|
107
|
+
.with_actions(
|
|
108
|
+
gather=target.gather_facts(),
|
|
109
|
+
inspect_apt=inspect_apt,
|
|
110
|
+
inspect_dnf=inspect_dnf,
|
|
111
|
+
summarize=summarize,
|
|
112
|
+
)
|
|
113
|
+
.with_transitions(
|
|
114
|
+
("gather", "inspect_apt", expr("ansible_pkg_mgr == 'apt'")),
|
|
115
|
+
("gather", "inspect_dnf", expr("ansible_pkg_mgr == 'dnf'")),
|
|
116
|
+
("inspect_apt", "summarize"),
|
|
117
|
+
("inspect_dnf", "summarize"),
|
|
118
|
+
)
|
|
119
|
+
.with_tracker(LocalTrackingClient(project="quickstart"))
|
|
120
|
+
.with_state(**initial_sentinels(), **target.initial_facts(), pkg_inspect={}, report="")
|
|
121
|
+
.with_entrypoint("gather")
|
|
122
|
+
.build()
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
_, _, final = app.run(halt_after=["summarize"])
|
|
126
|
+
print(final["report"])
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The same FSM works against Debian, RHEL, Fedora, Arch, or any other distro Ansible supports. The branch is taken by the gathered fact, not by hard-coded logic.
|
|
130
|
+
|
|
131
|
+
## Demo corpus
|
|
132
|
+
|
|
133
|
+
`examples/` contains eleven self-contained FSMs. Most run against a local Docker container set up by `examples/service_remediation/setup.sh`.
|
|
134
|
+
|
|
135
|
+
| Demo | What it shows | Collections used |
|
|
136
|
+
|---|---|---|
|
|
137
|
+
| `localhost_disk_check` | Linear chain, pure-Python branching on shell output | `ansible.builtin` |
|
|
138
|
+
| `service_remediation` | Retry loop with state counter, ssh plus become, escalate after N attempts | `ansible.builtin` |
|
|
139
|
+
| `cert_rotation` | Linear-with-skip, idempotent multi-step rotation, pure-Python date math | `community.crypto`, `ansible.builtin` |
|
|
140
|
+
| `config_drift` | Handler equivalent via `_last_changed`, validate-before-apply (`nginx -t`), rollback with reload-after-restore | `ansible.builtin` |
|
|
141
|
+
| `user_provisioning` | Iteration via state counter, mid-loop failure preserves partial state | `ansible.builtin`, `ansible.posix` |
|
|
142
|
+
| `sidecar_lifecycle` | Container lifecycle FSM running on the controller against local Docker | `community.docker` |
|
|
143
|
+
| `log_triage` | Ansible I/O wrapping a Python parser and a Granite-classifier with a deterministic validator gate | `ansible.builtin` |
|
|
144
|
+
| `mast_sre_agent` | MAST-aligned deep multi-module remediation (12 Ansible modules plus 7 Python actions) | `ansible.builtin`, `ansible.posix`, `community.general` |
|
|
145
|
+
| `coffee_order_ansible` | Burr's `coffee_order` topology with every action body swapped for an Ansible module operating on a filesystem queue | `ansible.builtin` |
|
|
146
|
+
| `fact_driven_inspect` | `gather_facts()` state expansion; transitions branch on `ansible_pkg_mgr` | `ansible.builtin` |
|
|
147
|
+
| `plan_then_apply` | check+diff plan, deterministic review gate, `wait_until` polling sub-graph, apply with verify | `ansible.builtin` |
|
|
148
|
+
|
|
149
|
+
Each example runs in seconds. Run an individual demo with `uv run python examples/<name>/fsm.py`.
|
|
150
|
+
|
|
151
|
+
The full library API and the Ansible-playbook-idiom mapping live in [REFERENCE.md](./REFERENCE.md).
|
|
152
|
+
|
|
153
|
+
## Dependencies and licensing
|
|
154
|
+
|
|
155
|
+
ansiburr is licensed under the Apache License 2.0. See `LICENSE` for the full text.
|
|
156
|
+
|
|
157
|
+
ansiburr imports only Apache-2.0 and MIT licensed code (`ansible-runner`, `burr`, `pyyaml`). At runtime it requires `ansible-core`, which is licensed under GPL-3.0-or-later and is invoked as a separate subprocess by `ansible-runner` rather than imported directly. Anyone redistributing an installed ansiburr environment should be aware that the bundled `ansible-core` component carries GPL-3.0+ obligations, and that individual Ansible collections in the user's `ansible_collections` path may have their own licenses.
|
|
158
|
+
|
|
159
|
+
The `NOTICE` file contains the canonical attribution and license summary.
|
|
160
|
+
|
|
161
|
+
This README is engineering documentation, not legal advice.
|
|
162
|
+
|
|
163
|
+
## Development
|
|
164
|
+
|
|
165
|
+
```sh
|
|
166
|
+
git clone https://github.com/msradam/ansiburr
|
|
167
|
+
cd ansiburr
|
|
168
|
+
uv sync
|
|
169
|
+
uv run pytest
|
|
170
|
+
uv run ruff check .
|
|
171
|
+
uv run mypy src/ansiburr
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Most examples require a small Docker container. `examples/service_remediation/setup.sh` builds the image and generates a per-clone SSH key; `examples/service_remediation/start.sh` runs the container.
|
|
175
|
+
|
|
176
|
+
ansiburr was developed with significant AI assistance (Anthropic's Claude). All changes were reviewed and committed by the project owner.
|
|
177
|
+
|
|
178
|
+
## Acknowledgements
|
|
179
|
+
|
|
180
|
+
- The Burr team (Apache Software Foundation) for the FSM substrate.
|
|
181
|
+
- The Ansible community for the module ecosystem.
|
|
182
|
+
- IBM Research and UC Berkeley for the MAST failure-mode taxonomy ([blog](https://huggingface.co/blog/ibm-research/itbenchandmast), [arXiv:2503.13657](https://arxiv.org/abs/2503.13657)).
|
|
183
|
+
|
|
184
|
+
## License
|
|
185
|
+
|
|
186
|
+
Apache License 2.0. See [LICENSE](./LICENSE) and [NOTICE](./NOTICE).
|