pyinfra-incus-kit 0.2.0__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.
@@ -0,0 +1,142 @@
1
+ # Project
2
+
3
+ # Byte-compiled / optimized / DLL files
4
+
5
+ __pycache__/
6
+ *.py[cod]
7
+ *$py.class
8
+
9
+ # C extensions
10
+ *.so
11
+
12
+ # Distribution / packaging
13
+ bin/
14
+ build/
15
+ develop-eggs/
16
+ dist/
17
+ eggs/
18
+ lib/
19
+ lib64/
20
+ parts/
21
+ sdist/
22
+ var/
23
+ wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+
28
+ # PyInstaller
29
+ # Usually these files are written by a python script from a template
30
+ # before PyInstaller builds the exe, so may not be in the repository.
31
+ *.manifest
32
+ *.spec
33
+
34
+ # Installer logs
35
+ pip-log.txt
36
+ pip-delete-this-directory.txt
37
+
38
+ # Unit test / coverage reports
39
+ htmlcov/
40
+ .tox/
41
+ .nosexy/
42
+ .nosetests/
43
+ .pytest_cache/
44
+ v/
45
+ .coverage
46
+ .coverage.*
47
+ .cache
48
+ nosetests.xml
49
+ coverage.xml
50
+ *.cover
51
+ .conftest_cache/
52
+ .pytype/
53
+ .hypothesis/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ target/
76
+
77
+ # Jupyter Notebook
78
+ .ipynb_checkpoints
79
+
80
+ # IPython
81
+ profile_default/
82
+ ipython_config.py
83
+
84
+ # pyenv
85
+ .python-version
86
+
87
+ # celery beat schedule file
88
+ celerybeat-schedule
89
+
90
+ # SageMath parsed files
91
+ *.sage.py
92
+
93
+ # Environments
94
+ .env
95
+ .venv
96
+ env/
97
+ venv/
98
+ ENV/
99
+ env.bak/
100
+ venv.bak/
101
+
102
+ # Spyder project settings
103
+ .spyderproject
104
+ .spyproject
105
+
106
+ # Rope project settings
107
+ .ropeproject
108
+
109
+ # mkdocs documentation
110
+ /site
111
+
112
+ # mypy
113
+ .mypy_cache/
114
+ .dmypy.json
115
+ dmypy.json
116
+
117
+ # Pyre type checker
118
+ .pyre/
119
+
120
+ # pytype static type analyzer
121
+ .pytype/
122
+
123
+ # Cython debug symbols
124
+ cython_debug/
125
+
126
+ # PyCharm / VS Code / Editors
127
+ .idea/
128
+ .vscode/
129
+ *.swp
130
+ *.swo
131
+ *~
132
+ .DS_Store
133
+
134
+ # Ruff
135
+ .ruff_cache/
136
+
137
+ # pyinfra specific
138
+ pyinfra-debug.log
139
+
140
+ # CI caches (see .gitlab-ci.yml)
141
+ .uv-cache/
142
+ .prek-cache/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Simon Maillard / Ogesta
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,272 @@
1
+ Metadata-Version: 2.5
2
+ Name: pyinfra-incus-kit
3
+ Version: 0.2.0
4
+ Summary: Incus connectors, operations, facts, and server deploy for pyinfra
5
+ Project-URL: Homepage, https://github.com/maisim/pyinfra-incus-kit
6
+ Project-URL: Repository, https://github.com/maisim/pyinfra-incus-kit
7
+ Project-URL: Issues, https://github.com/maisim/pyinfra-incus-kit/issues
8
+ Project-URL: Changelog, https://github.com/maisim/pyinfra-incus-kit/releases
9
+ Author-email: Simon Maillard <simon@ogesta.fr>
10
+ License: MIT
11
+ License-File: LICENSE
12
+ Keywords: incus,infrastructure,lxc,pyinfra
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: System Administrators
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Operating System :: POSIX :: Linux
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: <4.0,>=3.11
25
+ Requires-Dist: pyinfra<4,>=3.11
26
+ Requires-Dist: typing-extensions>=4.6
27
+ Description-Content-Type: text/markdown
28
+
29
+ # pyinfra-incus-kit
30
+
31
+ > **⚠️ ALPHA RELEASE**: This project is currently in the **Alpha** stage. The API, operation arguments, and features are subject to change at any time without backward compatibility. Do not use in production environments.
32
+
33
+ > **Packaging status**: this repository is the source of truth and is public. Install the latest
34
+ > release from PyPI; while the project is alpha, pin the version you use.
35
+
36
+ [![CI](https://github.com/maisim/pyinfra-incus-kit/actions/workflows/python-publish.yml/badge.svg)](https://github.com/maisim/pyinfra-incus-kit/actions/workflows/python-publish.yml)
37
+ [![PyPI](https://img.shields.io/pypi/v/pyinfra-incus-kit)](https://pypi.org/project/pyinfra-incus-kit/)
38
+ [![Python versions](https://img.shields.io/pypi/pyversions/pyinfra-incus-kit)](https://pypi.org/project/pyinfra-incus-kit/)
39
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
40
+
41
+ **pyinfra-incus-kit** provides connectors, operations, and facts to manage **Linux Containers (Incus / LXC)** using [pyinfra](https://pyinfra.com/).
42
+
43
+ It also includes a deploy script to **install and configure the Incus server** itself on Debian-based hosts.
44
+
45
+ ## Features
46
+
47
+ - **Connectors**:
48
+ - `@incus/instance`: Connect to local or remote Incus instances via `incus exec`.
49
+ - `@ssh/host/@incus/instance`: Chain through a remote host, running `incus` there instead of locally (requires the pyinfra fork; see below).
50
+ - `@lxc/instance`: Legacy LXC support.
51
+ - **Operations**: Manage Incus resources idempotently:
52
+ - Networks
53
+ - Storage Pools & Volumes
54
+ - Profiles
55
+ - Instances (Containers/VMs)
56
+ - Trusted client certificates, restricted to projects
57
+ - **Facts**: Query the state of Incus resources, and of the server itself.
58
+ - **Deploy**: Install Incus server on a Debian host.
59
+
60
+ ## Requirements
61
+
62
+ - Python 3.11–3.14 on the controller, and `pyinfra>=3.11,<4`.
63
+ - The `incus` CLI configured on the controller for `@incus` and `@lxc`.
64
+ - For `deploy_incus`: a Debian 13 host with root or sudo access.
65
+ - For `@ssh/.../@incus/...` chaining: the interim pyinfra fork (see below); public pyinfra 3.11
66
+ has no `@chain` connector yet.
67
+
68
+ ## Installation
69
+
70
+ ```bash
71
+ pip install pyinfra-incus-kit
72
+ # or
73
+ uv add pyinfra-incus-kit
74
+ ```
75
+
76
+ The PyPI name `pyinfra-incus` belongs to an unrelated project; install `pyinfra-incus-kit`.
77
+
78
+ ## Usage
79
+
80
+ ### 1. Connectors
81
+
82
+ #### Local Incus Client
83
+
84
+ If you have the `incus` CLI installed locally and configured (remotes, certificates):
85
+
86
+ ```bash
87
+ # Connect to a local instance
88
+ pyinfra @incus/my-container exec -- hostname
89
+
90
+ # Connect to a remote instance (configured in `incus remote list`)
91
+ pyinfra @incus/my-remote:my-container exec -- hostname
92
+
93
+ # Run on ALL instances of the local daemon
94
+ pyinfra @incus --limit 5 exec -- hostname
95
+
96
+ # Run on ALL instances of one remote
97
+ pyinfra @incus/my-remote: --limit 5 exec -- hostname
98
+ ```
99
+
100
+ #### Remote instances over SSH (requires the pyinfra fork)
101
+
102
+ Public pyinfra 3.11 has no `@chain` connector, so this syntax is not available out of the box. The
103
+ package itself runs on public pyinfra; only this feature needs the interim fork
104
+ ([pyinfra-dev/pyinfra#1780](https://github.com/pyinfra-dev/pyinfra/pull/1780)).
105
+
106
+ If you want to manage containers on a remote server **without** exposing the Incus API or installing the client locally, use `@incus` as an inner layer of the `@chain` connector - it then runs on the remote host rather than locally:
107
+
108
+ ```bash
109
+ # Syntax: @ssh/<ssh-host>/@incus/<instance-name>
110
+ # pyinfra will SSH to <ssh-host> and run `incus exec <instance-name>` there.
111
+ pyinfra @ssh/192.168.1.50/@incus/my-container exec -- hostname
112
+ ```
113
+
114
+ A chain segment is a host, not a URL, and both layers share that host's data - so the SSH user
115
+ and the project are passed as data rather than written into the target:
116
+
117
+ ```bash
118
+ pyinfra \
119
+ --data ssh_user=myuser \
120
+ --data incus_project=myproject \
121
+ @ssh/192.168.1.50/@incus/my-container exec -- hostname
122
+ ```
123
+
124
+ An `~/.ssh/config` entry for the host works too, and keeps the command short:
125
+
126
+ ```bash
127
+ pyinfra @ssh/myserver/@incus/my-container exec -- hostname
128
+ ```
129
+
130
+ > **Before pyinfra releases the chain connector**: upstream pyinfra has no `@chain` yet
131
+ > ([pyinfra-dev/pyinfra#1780](https://github.com/pyinfra-dev/pyinfra/pull/1780)). Until it does,
132
+ > install the fork wheel before this project:
133
+ >
134
+ > ```bash
135
+ > pip install https://github.com/maisim/pyinfra/releases/download/v3.11.2.post1/pyinfra-3.11.2.post1-py3-none-any.whl
136
+ > ```
137
+ >
138
+ > The wheel carries the same distribution name as pyinfra, so it replaces the upstream package.
139
+ > Remove it and install upstream pyinfra normally once #1780 ships. `uv` users can add the same
140
+ > URL as the `pyinfra` source in their project.
141
+
142
+ #### A remote daemon without SSH
143
+
144
+ Facts and operations address another server too, taking the remote from the host data - or from
145
+ `INCUS_REMOTE`, which the incus CLI reads as well. A deploy file then runs unchanged on a machine
146
+ that holds nothing but the client, with no daemon and no SSH:
147
+
148
+ ```bash
149
+ pyinfra --data incus_remote=my-remote --data incus_project=myproject @local deploy.py
150
+ ```
151
+
152
+ Every command is emitted as `incus ... my-remote:...`, so the remote is visible in the log. The
153
+ connector is the one exception: it reads the remote from its own data and never from the
154
+ inventory, so a chain layer cannot be redirected at a second server by host data.
155
+
156
+ ### 2. Operations (Manage Resources)
157
+
158
+ You can define your infrastructure (Networks, Profiles, Containers) using Python operations.
159
+
160
+ ```python
161
+ from pyinfra_incus_kit import operations
162
+
163
+ # Create a network
164
+ operations.network(
165
+ name="Ensure network incusbr0",
166
+ network="incusbr0",
167
+ config={
168
+ "ipv4.address": "auto",
169
+ "ipv4.nat": "true",
170
+ },
171
+ )
172
+
173
+ # Create a profile
174
+ operations.profile(
175
+ name="Ensure web-profile",
176
+ profile="web-profile",
177
+ devices={
178
+ "root": {
179
+ "type": "disk",
180
+ "pool": "default",
181
+ "path": "/",
182
+ },
183
+ "eth0": {
184
+ "type": "nic",
185
+ "network": "incusbr0",
186
+ "name": "eth0",
187
+ },
188
+ },
189
+ )
190
+
191
+ # Launch a container
192
+ operations.instance(
193
+ name="Ensure my-container exists",
194
+ instance="my-container",
195
+ image="images:debian/13",
196
+ profiles=["default", "web-profile"],
197
+ running=True,
198
+ )
199
+
200
+ # Trust a client certificate, confined to one project
201
+ operations.config_trust(
202
+ name="Trust the tenant certificate",
203
+ certificate=open("tenant.crt").read(),
204
+ certificate_name="myproject-ci",
205
+ restricted=True,
206
+ projects=("myproject",),
207
+ )
208
+ ```
209
+
210
+ `config_trust` replaces an entry whose certificate, restriction or project list has changed,
211
+ since `config trust edit` wants an editor and the fingerprint an entry is removed by changes with
212
+ its content. The certificate goes in over stdin, so it never appears in a process list.
213
+
214
+ See [examples/](examples/) for complete scenarios.
215
+
216
+ ### 3. Deploy (Install Incus Server)
217
+
218
+ To install the Incus server on a host (Debian only supported currently):
219
+
220
+ ```python
221
+ from pyinfra import host
222
+ from pyinfra_incus_kit.deploy_incus_host import deploy_incus
223
+
224
+ # This will install Incus, configure users, limits, and basic sysctl
225
+ deploy_incus()
226
+ ```
227
+
228
+ ## Inventory Data
229
+
230
+ You can configure the behavior via host data (in `inventory.py` or group data):
231
+
232
+ ```python
233
+ # For the Install Deploy
234
+ incus_config = {
235
+ "networks": {...}, # Default network config
236
+ }
237
+ limits_config = [...] # Security limits
238
+ sysctl_config = {...} # Kernel parameters
239
+
240
+ # For Connectors, Facts and Operations
241
+ incus_project = "myproject" # Target a specific Incus project (default: the daemon's default)
242
+ incus_remote = "my-remote" # Server to address, when it is not the local daemon
243
+ ```
244
+
245
+ `incus_remote` reaches a connector only through the target name (`@incus/my-remote:my-container`)
246
+ or its connector data; facts and operations read it from the host data, then from `INCUS_REMOTE`.
247
+
248
+ ## Development
249
+
250
+ See [examples/](examples/) for test scripts and use cases.
251
+
252
+ ```bash
253
+ uv sync --group dev
254
+ uv run pytest -q
255
+ uv run mypy --config-file=pyproject.toml src
256
+ uv run prek run --all-files
257
+ uv build
258
+ uvx twine check dist/*
259
+ ```
260
+
261
+ The integration tests (real `incus` daemon) skip when the CLI is absent; run them with
262
+ `uv run pytest -m integration` on a host that has it.
263
+
264
+ ## Links
265
+
266
+ - [Repository](https://github.com/maisim/pyinfra-incus-kit)
267
+ - [Issues](https://github.com/maisim/pyinfra-incus-kit/issues)
268
+ - [PyPI](https://pypi.org/project/pyinfra-incus-kit/)
269
+
270
+ ## License
271
+
272
+ MIT. See [LICENSE](LICENSE).
@@ -0,0 +1,244 @@
1
+ # pyinfra-incus-kit
2
+
3
+ > **⚠️ ALPHA RELEASE**: This project is currently in the **Alpha** stage. The API, operation arguments, and features are subject to change at any time without backward compatibility. Do not use in production environments.
4
+
5
+ > **Packaging status**: this repository is the source of truth and is public. Install the latest
6
+ > release from PyPI; while the project is alpha, pin the version you use.
7
+
8
+ [![CI](https://github.com/maisim/pyinfra-incus-kit/actions/workflows/python-publish.yml/badge.svg)](https://github.com/maisim/pyinfra-incus-kit/actions/workflows/python-publish.yml)
9
+ [![PyPI](https://img.shields.io/pypi/v/pyinfra-incus-kit)](https://pypi.org/project/pyinfra-incus-kit/)
10
+ [![Python versions](https://img.shields.io/pypi/pyversions/pyinfra-incus-kit)](https://pypi.org/project/pyinfra-incus-kit/)
11
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
12
+
13
+ **pyinfra-incus-kit** provides connectors, operations, and facts to manage **Linux Containers (Incus / LXC)** using [pyinfra](https://pyinfra.com/).
14
+
15
+ It also includes a deploy script to **install and configure the Incus server** itself on Debian-based hosts.
16
+
17
+ ## Features
18
+
19
+ - **Connectors**:
20
+ - `@incus/instance`: Connect to local or remote Incus instances via `incus exec`.
21
+ - `@ssh/host/@incus/instance`: Chain through a remote host, running `incus` there instead of locally (requires the pyinfra fork; see below).
22
+ - `@lxc/instance`: Legacy LXC support.
23
+ - **Operations**: Manage Incus resources idempotently:
24
+ - Networks
25
+ - Storage Pools & Volumes
26
+ - Profiles
27
+ - Instances (Containers/VMs)
28
+ - Trusted client certificates, restricted to projects
29
+ - **Facts**: Query the state of Incus resources, and of the server itself.
30
+ - **Deploy**: Install Incus server on a Debian host.
31
+
32
+ ## Requirements
33
+
34
+ - Python 3.11–3.14 on the controller, and `pyinfra>=3.11,<4`.
35
+ - The `incus` CLI configured on the controller for `@incus` and `@lxc`.
36
+ - For `deploy_incus`: a Debian 13 host with root or sudo access.
37
+ - For `@ssh/.../@incus/...` chaining: the interim pyinfra fork (see below); public pyinfra 3.11
38
+ has no `@chain` connector yet.
39
+
40
+ ## Installation
41
+
42
+ ```bash
43
+ pip install pyinfra-incus-kit
44
+ # or
45
+ uv add pyinfra-incus-kit
46
+ ```
47
+
48
+ The PyPI name `pyinfra-incus` belongs to an unrelated project; install `pyinfra-incus-kit`.
49
+
50
+ ## Usage
51
+
52
+ ### 1. Connectors
53
+
54
+ #### Local Incus Client
55
+
56
+ If you have the `incus` CLI installed locally and configured (remotes, certificates):
57
+
58
+ ```bash
59
+ # Connect to a local instance
60
+ pyinfra @incus/my-container exec -- hostname
61
+
62
+ # Connect to a remote instance (configured in `incus remote list`)
63
+ pyinfra @incus/my-remote:my-container exec -- hostname
64
+
65
+ # Run on ALL instances of the local daemon
66
+ pyinfra @incus --limit 5 exec -- hostname
67
+
68
+ # Run on ALL instances of one remote
69
+ pyinfra @incus/my-remote: --limit 5 exec -- hostname
70
+ ```
71
+
72
+ #### Remote instances over SSH (requires the pyinfra fork)
73
+
74
+ Public pyinfra 3.11 has no `@chain` connector, so this syntax is not available out of the box. The
75
+ package itself runs on public pyinfra; only this feature needs the interim fork
76
+ ([pyinfra-dev/pyinfra#1780](https://github.com/pyinfra-dev/pyinfra/pull/1780)).
77
+
78
+ If you want to manage containers on a remote server **without** exposing the Incus API or installing the client locally, use `@incus` as an inner layer of the `@chain` connector - it then runs on the remote host rather than locally:
79
+
80
+ ```bash
81
+ # Syntax: @ssh/<ssh-host>/@incus/<instance-name>
82
+ # pyinfra will SSH to <ssh-host> and run `incus exec <instance-name>` there.
83
+ pyinfra @ssh/192.168.1.50/@incus/my-container exec -- hostname
84
+ ```
85
+
86
+ A chain segment is a host, not a URL, and both layers share that host's data - so the SSH user
87
+ and the project are passed as data rather than written into the target:
88
+
89
+ ```bash
90
+ pyinfra \
91
+ --data ssh_user=myuser \
92
+ --data incus_project=myproject \
93
+ @ssh/192.168.1.50/@incus/my-container exec -- hostname
94
+ ```
95
+
96
+ An `~/.ssh/config` entry for the host works too, and keeps the command short:
97
+
98
+ ```bash
99
+ pyinfra @ssh/myserver/@incus/my-container exec -- hostname
100
+ ```
101
+
102
+ > **Before pyinfra releases the chain connector**: upstream pyinfra has no `@chain` yet
103
+ > ([pyinfra-dev/pyinfra#1780](https://github.com/pyinfra-dev/pyinfra/pull/1780)). Until it does,
104
+ > install the fork wheel before this project:
105
+ >
106
+ > ```bash
107
+ > pip install https://github.com/maisim/pyinfra/releases/download/v3.11.2.post1/pyinfra-3.11.2.post1-py3-none-any.whl
108
+ > ```
109
+ >
110
+ > The wheel carries the same distribution name as pyinfra, so it replaces the upstream package.
111
+ > Remove it and install upstream pyinfra normally once #1780 ships. `uv` users can add the same
112
+ > URL as the `pyinfra` source in their project.
113
+
114
+ #### A remote daemon without SSH
115
+
116
+ Facts and operations address another server too, taking the remote from the host data - or from
117
+ `INCUS_REMOTE`, which the incus CLI reads as well. A deploy file then runs unchanged on a machine
118
+ that holds nothing but the client, with no daemon and no SSH:
119
+
120
+ ```bash
121
+ pyinfra --data incus_remote=my-remote --data incus_project=myproject @local deploy.py
122
+ ```
123
+
124
+ Every command is emitted as `incus ... my-remote:...`, so the remote is visible in the log. The
125
+ connector is the one exception: it reads the remote from its own data and never from the
126
+ inventory, so a chain layer cannot be redirected at a second server by host data.
127
+
128
+ ### 2. Operations (Manage Resources)
129
+
130
+ You can define your infrastructure (Networks, Profiles, Containers) using Python operations.
131
+
132
+ ```python
133
+ from pyinfra_incus_kit import operations
134
+
135
+ # Create a network
136
+ operations.network(
137
+ name="Ensure network incusbr0",
138
+ network="incusbr0",
139
+ config={
140
+ "ipv4.address": "auto",
141
+ "ipv4.nat": "true",
142
+ },
143
+ )
144
+
145
+ # Create a profile
146
+ operations.profile(
147
+ name="Ensure web-profile",
148
+ profile="web-profile",
149
+ devices={
150
+ "root": {
151
+ "type": "disk",
152
+ "pool": "default",
153
+ "path": "/",
154
+ },
155
+ "eth0": {
156
+ "type": "nic",
157
+ "network": "incusbr0",
158
+ "name": "eth0",
159
+ },
160
+ },
161
+ )
162
+
163
+ # Launch a container
164
+ operations.instance(
165
+ name="Ensure my-container exists",
166
+ instance="my-container",
167
+ image="images:debian/13",
168
+ profiles=["default", "web-profile"],
169
+ running=True,
170
+ )
171
+
172
+ # Trust a client certificate, confined to one project
173
+ operations.config_trust(
174
+ name="Trust the tenant certificate",
175
+ certificate=open("tenant.crt").read(),
176
+ certificate_name="myproject-ci",
177
+ restricted=True,
178
+ projects=("myproject",),
179
+ )
180
+ ```
181
+
182
+ `config_trust` replaces an entry whose certificate, restriction or project list has changed,
183
+ since `config trust edit` wants an editor and the fingerprint an entry is removed by changes with
184
+ its content. The certificate goes in over stdin, so it never appears in a process list.
185
+
186
+ See [examples/](examples/) for complete scenarios.
187
+
188
+ ### 3. Deploy (Install Incus Server)
189
+
190
+ To install the Incus server on a host (Debian only supported currently):
191
+
192
+ ```python
193
+ from pyinfra import host
194
+ from pyinfra_incus_kit.deploy_incus_host import deploy_incus
195
+
196
+ # This will install Incus, configure users, limits, and basic sysctl
197
+ deploy_incus()
198
+ ```
199
+
200
+ ## Inventory Data
201
+
202
+ You can configure the behavior via host data (in `inventory.py` or group data):
203
+
204
+ ```python
205
+ # For the Install Deploy
206
+ incus_config = {
207
+ "networks": {...}, # Default network config
208
+ }
209
+ limits_config = [...] # Security limits
210
+ sysctl_config = {...} # Kernel parameters
211
+
212
+ # For Connectors, Facts and Operations
213
+ incus_project = "myproject" # Target a specific Incus project (default: the daemon's default)
214
+ incus_remote = "my-remote" # Server to address, when it is not the local daemon
215
+ ```
216
+
217
+ `incus_remote` reaches a connector only through the target name (`@incus/my-remote:my-container`)
218
+ or its connector data; facts and operations read it from the host data, then from `INCUS_REMOTE`.
219
+
220
+ ## Development
221
+
222
+ See [examples/](examples/) for test scripts and use cases.
223
+
224
+ ```bash
225
+ uv sync --group dev
226
+ uv run pytest -q
227
+ uv run mypy --config-file=pyproject.toml src
228
+ uv run prek run --all-files
229
+ uv build
230
+ uvx twine check dist/*
231
+ ```
232
+
233
+ The integration tests (real `incus` daemon) skip when the CLI is absent; run them with
234
+ `uv run pytest -m integration` on a host that has it.
235
+
236
+ ## Links
237
+
238
+ - [Repository](https://github.com/maisim/pyinfra-incus-kit)
239
+ - [Issues](https://github.com/maisim/pyinfra-incus-kit/issues)
240
+ - [PyPI](https://pypi.org/project/pyinfra-incus-kit/)
241
+
242
+ ## License
243
+
244
+ MIT. See [LICENSE](LICENSE).