Skip to content

Commit 90961d8

Browse files
committedJun 27, 2021
Update CLI docs to use explicit fact imports.
1 parent 7ace213 commit 90961d8

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed
 

‎docs/cli.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ pyinfra INVENTORY server.user pyinfra home=/home/pyinfra
2828
pyinfra INVENTORY exec -- echo "hello world"
2929

3030
# Run one or more facts on the inventory
31-
pyinfra INVENTORY fact linux_distribution [users]...
32-
pyinfra INVENTORY all-facts
31+
pyinfra INVENTORY fact server.LinuxName [server.Users]...
32+
pyinfra INVENTORY fact files.File path=/path/to/file...
3333

3434
# Debug (print) inventory hosts, groups and data
3535
pyinfra INVENTORY debug-inventory

‎docs/deploys.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,15 @@ Adding data to inventories was :ref:`described above <data-ref-label>` - you can
205205
Facts
206206
*****
207207

208-
Facts allow you to use information about the target host to change the operations you use. A good example is switching between `apt` & `yum` depending on the Linux distribution. Like data, facts are accessed using ``host.fact``:
208+
Facts allow you to use information about the target host to change the operations you use. A good example is switching between `apt` & `yum` depending on the Linux distribution. Facts are imported from ``pyinfra.facts.*`` modules:
209209

210210
.. code:: python
211211
212212
from pyinfra import host
213+
from pyinfra.facts.server import LinuxName
213214
from pyinfra.operations import yum
214215
215-
if host.fact.linux_name == 'CentOS':
216+
if host.get_fact(LinuxName) == 'CentOS':
216217
yum.packages(
217218
name='Install nano via yum',
218219
packages=['nano'],

‎pyinfra_cli/main.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ def cli(*args, **kwargs):
210210
211211
\b
212212
# Run one or more facts on the inventory
213-
pyinfra INVENTORY fact linux_distribution [users]...
214-
pyinfra INVENTORY all-facts
213+
pyinfra INVENTORY fact server.LinuxName [server.Users]...
214+
pyinfra INVENTORY fact files.File path=/path/to/file...
215215
'''
216216

217217
try:

0 commit comments

Comments
 (0)
Failed to load comments.