computer-playbook/docs/guides/developer/Ansible_Directory_Guide.md

6.8 KiB

📖 CyMaIS.Cloud Ansible & Python Directory Guide

This document provides a decision matrix for when to use each default Ansible plugin and module directory in the context of CyMaIS.Cloud development with Ansible and Python. It links to official docs, explains use-cases, and points back to our conversation.



🛠️ Repo Layout & Default Directories

ansible-repo/
├── library/                # 📦 Custom Ansible modules
├── filter_plugins/         # 🔍 Custom Jinja2 filters
├── lookup_plugins/         # 👉 Custom lookup plugins
├── module_utils/           # 🛠️ Shared Python helpers for modules
├── action_plugins/         # ⚙️ Task-level orchestration logic
├── callback_plugins/       # 📣 Event callbacks (logging, notifications)
├── inventory_plugins/      # 🌐 Dynamic inventory sources
├── strategy_plugins/       # 🧠 Task execution strategies
└── ...                     # Other plugin dirs (connection, cache, etc.)

🎯 Decision Matrix: Which Folder for What?

Folder Type Use-Case Example (CyMaIS.Cloud) Emoji
library/ Module Write idempotent actions cloud_network.py: manage VPCs, subnets 📦
filter_plugins/ Filter plugin Jinja2 data transforms in templates/vars to_camel_case.py: convert keys for API calls 🔍
lookup_plugins/ Lookup plugin Fetch external/secure data at runtime vault_lookup.py: pull secrets from CyMaIS Vault 👉
module_utils/ Utility library Shared Python code for modules cymais_client.py: common API client base class 🛠️
action_plugins/ Action plugin Complex task orchestration wrappers deploy_stack.py: sequence Terraform + Ansible steps ⚙️
callback_plugins/ Callback plugin Customize log/report behavior notify_slack.py: send playbook status to Slack 📣
inventory_plugins/ Inventory plugin Dynamic host/group sources azure_inventory.py: list hosts from Azure tags 🌐
strategy_plugins/ Strategy plugin Control task execution order/parallelism rolling_batch.py: phased rollout of VMs 🧠

📝 Detailed Guidance

  1. library/ 📦

  2. filter_plugins/ 🔍

  3. lookup_plugins/ 👉

  4. module_utils/ 🛠️

  5. action_plugins/ ⚙️

  6. callback_plugins/ 📣

  7. inventory_plugins/ 🌐

  8. strategy_plugins/ 🧠


🚀 CyMaIS.Cloud Best Practices

  • Organize modules by service under library/cloud/ (e.g., vm, network, storage).
  • Shared client code in module_utils/cymais/ for authentication, request handling.
  • Secrets lookup via lookup_plugins/vault_lookup.py pointing to CyMaIS Vault.
  • Filters to normalize data formats from cloud APIs (e.g., snake_to_camel).
  • Callbacks to stream playbook results into CyMaIS Monitoring.

Use this matrix as your single source of truth when extending Ansible for CyMaIS.Cloud! 👍


This matrix was created with the help of ChatGPT 🤖—see our conversation here.