Fora
  • Getting Started
  • Outlining the differences
  • Frequently Asked Questions
  • Usage
    • Introduction
      • Inventories
      • Hosts & Groups
      • Scripts
    • Best practices
  • API
    • Operations Index
    • Fora API
      • fora.connectors
        • connectors.connector
        • connectors.local
        • connectors.ssh
        • connectors.tunnel_connector
        • connectors.tunnel_dispatcher
      • fora.operations
        • operations.api
        • operations.apt
        • operations.files
        • operations.git
        • operations.local
        • operations.pacman
        • operations.pip
        • operations.portage
        • operations.postgres
        • operations.system
        • operations.systemd
        • operations.utils
      • fora.connection
      • fora.example_deploys
      • fora.inventory_wrapper
      • fora.loader
      • fora.logger
      • fora.main
      • fora.remote_settings
      • fora.types
      • fora.utils
      • fora.version
  • Examples
    • Managing dotfiles
    • Using secrets
  • Links
    • Fora on GitHub
Powered by GitBook
On this page
  • Use name="..." on everything.
  • Never modify host or group variables in your scripts.
  • Use the type checked API.
  1. Usage

Best practices

Use name="..." on everything.

All operations support the name= parameter which allows you to describe what it is doing. This will make following the output much easier.

Never modify host or group variables in your scripts.

This will lead to a strange coupling between an inventory and scripts. If you need to track global state, please create an additional python module just for this purpose, or avoid it in the first place.

Use the type checked API.

Fora is fully typed. While it is more verbose, this allows you to use certain typed variables from an imported wrapper instead of implicitly defined globals to allow for proper type-checking with mypy or similar tools.

from fora import script

#@Params       # Implicitly defined, no type available to type-checkers.
@script.Params # Properly typed.
class params:
	#...
# The host variable will always be the current host while loading.
from fora import host as this

#print(groups) <-- unchecked
print(this.groups)
from fora import group as this

#print(name) <-- unchecked
print(this.name)
PreviousScriptsNextOperations Index

Last updated 3 years ago