nateph
nateph

Reputation: 1187

Pyinfra missing positional argument

According to the docs, https://docs.pyinfra.com/en/1.x/facts/server.html#server-linuxname, I should be able to call host.get_fact(LinuxName) as it is, but when I do, it is complaining about a position argument.

Python 3.8.11 (default, Aug  6 2021, 08:56:27) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.26.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from pyinfra.facts.server import LinuxName
f
In [2]: from pyinfra import host

In [3]: host.get_fact(LinuxName)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-aea44d47c623> in <module>
----> 1 host.get_fact(LinuxName)

TypeError: get_fact() missing 1 required positional argument: 'name_or_cls'

What am I missing here?

Extra example from docs: https://docs.pyinfra.com/en/1.x/deploys.html#facts

Upvotes: 1

Views: 179

Answers (1)

nateph
nateph

Reputation: 1187

This must be ran with an inventory, or through the command line with @local, it won't work in ipython.

Upvotes: 1

Related Questions