Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mz0/2ea3c1610eb024e88c2e2b66a4a4fc3a to your computer and use it in GitHub Desktop.
Save mz0/2ea3c1610eb024e88c2e2b66a4a4fc3a to your computer and use it in GitHub Desktop.
# push mode will look about like this:
if __name__ == '__main__':
inventory = TomlInventory("inventory/inventory.toml")
inventory.ssh([WebServerRole(), AnotherRole() ])
# if you want to run check mode, you can still access it, though it is not the default:
inventory.ssh([WebServers(), AnotherRole() ], check=True)
# if you want --check or --apply to be CLI options, it looks like the lines below
# if you don't supply --check or --apply the script will *not* activate this way
if __name__ == '__main__':
inventory = TomlInventory("inventory/inventory.toml", use_cli=True)
inventory.ssh([ WebServers(), AnotherRole() ])
# "ssh" is the name of a connection plugin. You will be able to add your own plugins.
# local mode is basically an inventory of just one host, with only one plugin
if __name__ == '__main__':
local = Local(use_cli=True)
local.run([ WebServers(), AnotherRole() ])
# the return structure from ".run" will be an object that contains meaningful data about the results of each
# host, and in Jupyter context should be some interesting widget, or have some helper functions to show it as
# a widget (TBD)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment