Learning paths › Automation › Roles, imports and writing your own module
Roles, imports and writing your own module
Packaging and extending: a role laid out where Ansible will find it and published for installation by version, a task file loaded dynamically or statically with the difference visible in --list-tasks, a role looped or expanded up front, and several playbooks composed into one run — then writing your own module, beginning as a plain Python CSV report, wrapped in AnsibleModule, fed hostvars, and returning a clear failure instead of a traceback — and finally RESTCONF driven through the uri module, with a recorded working request first, PUT's scope seen, routes merged without loss and one loopback deleted by key. Explanation and checks; four written exercises.
Lessons
- Lay out a role Ansible can find
- Publish a role others can install by version
- Load a task file dynamically or statically
- See which tasks appear in --list-tasks
- Loop a role or expand it up front
- Compose several playbooks into one run
- Decide when to write your own module
- Write a plain Python CSV report first
- Wrap the report function with AnsibleModule
- Return a clear failure instead of a traceback
- Feed hostvars into the module's report schema
- Explore YANG models before building requests
- Prove NETCONF and RESTCONF reachability separately
- Address device data over HTTP
- Record a working request before you automate it
- Fetch interface data with the uri module
- Retrieve the whole native configuration tree
- Replace a resource and see what PUT removes
- Send a mapping or a raw JSON string
- Create a child resource that must not exist
- Merge new routes without losing existing ones
- Delete one loopback by its key
- Invoke a save operation over RESTCONF
- Deploy AWX on a local Kubernetes cluster
More in Automation
- First scripts that configure devices
- NAPALM: structured data across vendors
- Concurrency, and the Python types device output returns
- Parsing show output and testing conditions
- Readable code, branching and loops
- Build the workstation and the toolchain
- Files, CSV, JSON and pickle
- Paramiko: SSH to devices from Python
- Netmiko at fleet scale
- Tuples, sets and dictionaries for device records
- Exceptions and your first classes
- Plan and build the automation lab
- Files, formatting and regular expressions
- Addresses, functions, modules and classes
- CSV inventories, logging and scheduling
- Netmiko, SCP and structured parsing
- Agents, async and model-driven workflows
- NETCONF, YANG and RESTCONF
- NX-API, pyATS and Genie
- A small GenAI app, end to end
- macOS, Linux and the virtual lab
- Agile delivery and Python fundamentals
- REST APIs, authentication and requests
- Flask, Docker and Jenkins
- Managing a router with NETCONF and RESTCONF
- Ansible: inventory, ad-hoc commands and first playbooks
- Roles and zero-touch provisioning for Linux switches
- Installing the controller and applying a project
- Setting up Python 3
- The Ansible lab and the controller
- Vault, variables and config changes
- Parsing output and knowing which variable wins
- Jinja filters and PAN-OS automation
- Loops, callbacks, strategy and run control
- Running playbooks from AWX