pyinfra v0.5
Changes in 0.5:
Vagrant connector:
# Run a deploy on all Vagrant machines (vagrant status list)
pyinfra @vagrant deploy.py
pyinfra @vagrant/vm_name deploy.py
# Can be used in tandem with other inventory:
pyinfra @vagrant,my-host.net deploy.py
pyinfra @vagrant,@local,my-host.net fact os
Consistent conditional branching:
- Add global
when
kwarg to all operations, similar tohosts
can be used to prevent operations executing on hosts based on a condition - Add
state.limit(hosts)
andstate.when(condition)
context managers to use in place ofif
statements within deploys @deploy
s and the context managers (state.limit
,state.when
) can all be nested as much as needed (although if you need to nest a lot, you're probably doing it wrong!)- Add
data_defaults
kwarg to@deploy
functions, meaning third party pyinfra packages can provide sensible defaults that the user can override individually - Display a large warning when imbalanced branches are detected, linking the user to the documentation for the above
Examples:
from pyinfra import host, state
from pyinfra.modules import server
# Replace if blocks with the state.when context
with state.when(host.name == 'my-host.net'):
server.shell('echo "my-host.net op!"')
...
# Use the when kwarg to achieve the same, for single operations
server.shell(
'echo "my-host.net op!"',
when=host.name == 'my-host.net',
)
with state.limit(inventory.get_host('my-host.net')):
server.shell('echo "my-host.net op!"')
...
server.shell(
'echo "my-host.net op!"',
limit=inventory.get_host('my-host.net'),
)
Note that if statements/etc still work as before but pyinfra will print out a warning explaining the implications and linking to the docs (http://pyinfra.readthedocs.io/page/using_python.html#conditional-branches).
- Hooks change: no longer loaded from deploy files, only from
config.py
, due to changes from0.4
(removal ofFakeState
nonsense) - Add
gpgkey
argument to theyum.repo
operation - Add
lsb_release
fact apt_sources
fact now supports apt repos with options ([arch=amd64]
)- Improved error output when connecting
- Update testing box from Ubuntu 15 to Ubuntu 16
- Ensure
~/.ssh
exists keyscanning inssh.keyscan
- Don't include tests during setup!
- Fix caching of local SHA1s on files