mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-09 12:17:13 +00:00
An inventory group web-app-cst-<name> with applications.<id>.custom: true and
a pinned source {url, version, path} is pulled into roles/ before the play,
read raw (Jinja, Ansible tags and credential URLs refused), placed through a
staging directory under an exclusive lock, and owned by a marker that names
its own directory, so a pull or roles-clean never replaces or removes a
directory it did not place and a failed pull leaves roles/ as it was.
Directory inventories, host lists and non-UTF-8 files behave as Ansible
reads them; generated test deploys pass --skip-pull. make roles-pull,
roles-clean and roles list, INFINITO_EXTRA_MOUNTS for local sources, the
web-app-cst category, the reserved prefix lint and a central
repository_files() that also yields the gitignored custom roles let every
lint scan them like in-tree roles. Supersedes the uncommitted 045 External
Roles draft and reuses its fetch, sync and mount design.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
import contextlib
|
|
import io
|
|
import unittest
|
|
from unittest import mock
|
|
|
|
import cli.administration.roles.clean.__main__ as clean_main
|
|
|
|
|
|
class TestCleanMain(unittest.TestCase):
|
|
def test_reports_the_roles_it_removed_and_the_entries_it_left(self):
|
|
lines = [
|
|
"web-app-cst-a: removed",
|
|
"web-app-cst-hand: left in place, the pull did not place it",
|
|
]
|
|
with (
|
|
mock.patch.object(clean_main, "clean", return_value=lines) as clean,
|
|
contextlib.redirect_stdout(io.StringIO()) as out,
|
|
):
|
|
self.assertEqual(0, clean_main.main([]))
|
|
clean.assert_called_once_with(clean_main.ROLES_DIR, clean_main.WORK_DIR)
|
|
self.assertEqual(
|
|
"custom role web-app-cst-a: removed\n"
|
|
"custom role web-app-cst-hand: left in place, the pull did not place it\n",
|
|
out.getvalue(),
|
|
)
|
|
|
|
def test_a_filesystem_error_exits_with_it(self):
|
|
with (
|
|
mock.patch.object(clean_main, "clean", side_effect=OSError("busy")),
|
|
self.assertRaises(SystemExit) as exit_,
|
|
):
|
|
clean_main.main([])
|
|
self.assertIn("busy", str(exit_.exception.code))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|