Skip to content

Set of import hooks so you can import Ansible modules in to Python code

License

Notifications You must be signed in to change notification settings

nrb/ansible_importer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ansible_importer

Ansible modules and plugins are typically pure Python, but often lack the structure necessary to import as Python code. This package is meant to allow programmers to import module code for testing purposes.

Installing

The code's up on PyPI

pip install ansible_importer

Usage

import ansible_importer
ansible_importer.install('/abs/path/to/ansible/code')

# Assuming above path has a playbooks/plugins/actions/my_plugin.py module
from playbooks.plugins.actions.my_plugin import ActionModule

# Assuming playbooks/library/glance
from playbooks.library.glance import ManageGlance

# Assuming playbooks/inventory/dynamic_inventory.py
from playbooks.inventory import dynamic_inventory

Credits

Thanks to Raphael Randschau for the idea of using the imp module, and Doug Hellman's Python Module of the Week post on import hooks for guidance in implementation.

About

Set of import hooks so you can import Ansible modules in to Python code

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages