Python Fallback
Spage includes a Python fallback mechanism that allows it to execute Ansible modules and plugins that haven't been ported to Go yet. This ensures compatibility with the broader Ansible ecosystem while maintaining Spage's performance benefits.
Note that the Python fallback acts as a last resort and is only used if the module is not found in Spage's native Go modules. Where possible,
you should port the module to Go to avoid the dependency of the ansible-playbook
command.
How It Works
When Spage encounters a module or plugin that isn't implemented natively in Go, it can fall back to executing the original Python-based Ansible implementation. This happens transparently to the user.
Prerequisites
To use Python fallback, you need to have the ansible-playbook
executable available in your path.
Supported Use Cases
Custom Ansible Modules
If you have custom Ansible modules written in Python:
- name: Use custom Python module
my_custom_module:
param1: value1
param2: value2
Spage will automatically detect that my_custom_module
isn't available in Go and use the Python fallback.
Inventory Plugins
Python-based inventory plugins are supported:
plugin: community.general.cobbler
url: http://cobbler.example.com/cobbler_api
user: cobbler
password: cobbler
cache: false
Considerations When Using Python Fallback
While Python fallback ensures compatibility, it comes with performance trade-offs:
Performance Impact
- Startup overhead: Python interpreter initialization
- Module loading: Loading Ansible and module dependencies
- Serialization: Converting between Go and Python data structures
- Process spawning: Creating new processes for each Python module
Compatibility
- Requires compatible Ansible version
- Some advanced Ansible features may not work
- Module-specific quirks may not be handled