A butler CLI for assistance in managing Ansible projects
Project description
ansible-butler

Butler CLI for Ansible projects
Functions
| Object | Action | Description |
|---|---|---|
| directory | init | initialize an ansible directory |
| directory | clean | cleanup an ansible directory |
| ee | init | initialize an execution environment directory for ansible-builder |
| ee | inspect | quickly inpsect the python libraries and ansible collections in an execution environment |
| ee | dependencies[deps] | parse the dependency tree based on execution environment definition (or collection requirements) |
| role | list | list roles |
| role | dependencies[deps] | Build a dependency graph between roles in a specified directory [Example] |
| role | clean | clean role directory structure (remove empty yml files & dirs) |
| role | mk-readme | auto generate readme based on role meta and basic yml info |
| playbook | update | map legacy module names to FQCNs |
| playbook | list-collections[lc] | list collections used in a playbook (following include_* directives) |
| template | clone | clone a job template (including survey, schedules, and labels) |
Usage
Usage:
ansible-butler directory init [<dir>] [--config=PATH]
ansible-butler directory clean [<dir>] [--skip-roles]
ansible-butler ee init [<dir>] [--config=PATH]
ansible-butler ee inspect [<image>] [--config=PATH]
ansible-butler ee [dependencies|deps] [--config=PATH] [<name>]
ansible-butler role list [--roles-path=PATH] [<name> --recursive]
ansible-butler role [dependencies|deps] [--roles-path=PATH] [<master>]
ansible-butler role clean [--roles-path=PATH] [<name> --recursive]
ansible-butler role mk-readme [--roles-path=PATH] [<name> --recursive]
ansible-butler playbook update [--context=CONTEXT] [--config=PATH] [<name>] [--recursive] [--force]
ansible-butler playbook [list-collections|lc] [--context=CONTEXT] [--config=PATH] [<name>] [--recursive] [--force]
ansible-butler template clone <id> [<name>] [--config=PATH] [--dry-run]
Arguments:
name name of target (accepts glob patterns)
id resource id
image name of image
master name of master node in graph
dir path to directory [default: ./]
Options:
-h --help Show this screen
-r --recursive Apply glob recursively [default: False]
-f --force Make file changes in place
--dry-run Do not make any changes - report on action behavior
--config=PATH Path to config file
--roles-path=PATH Path to roles directory [default: ./roles]
--context=CONTEXT Path to context directory [default: ./]
--skip-roles Flag to skip cleaning roles
Examples
- Initialize Ansible Directory
ansible-butler directory init ./sandboxansible-butler directory init ./sandbox --config=~/configs/ansible-butler.yml
- Clean an Ansible Directory
ansible-butler directory clean ./sandboxansible-butler directory clean ./sandbox --skip-roles
- Initialize Execution Environment Directory
ansible-butler ee init ./ee-windowsansible-butler ee init ./ee-windows --config=~/configs/ansible-butler.yml
- Inspect an Execution Environment
ansible-butler ee inspect quay.io/zleblanc/ee-defaultansible-butler ee init quay.io/zleblanc/ee-default --config=~/configs/ansible-butler.yml
- Inspect Execution Environment Dependencies
ansible-butler ee dependencies execution-environment.ymlansible-butler ee deps requirements.yml --config=~/configs/ansible-butler.yml
- Clean Roles
ansible-butler role clean my-role-1ansible-butler role clean my-role-*
- List Roles
ansible-butler role listansible-butler role list ansible_collections/namespace/collection/roles
- Generate Dependency Graph
ansible-butler role depsansible-butler role deps ansible_collections/namespace/collection/roles
- Generate README
ansible-butler role mk-readme my-role-1ansible-butler role mk-readme my-role-*
- Update Playbooks
ansible-butler playbook update --context=./playbooks -ransible-butler playbook update legacy-*.ymlansible-butler playbook update -f
- List Collections
ansible-butler playbook list-collections --context=./playbooks -ransible-butler playbook lc example-playbook.yml
- Clone Job Template
ansible-butler template clone 1ansible-butler template clone 1 --dry-run
Configuration
Create an .ansible-butler.yml in one or more of the following locations:
/etc/ansible-butler/ ## least precedence
~/
./ ## highest precedence
You can also specify a specific path at runtime via the --config option.
# Example Configuration Schema
execution_environment:
inspect:
engine: auto # [auto,podman,docker]
format: yaml # [yaml,json]
init:
# Refer to full schema here:
# https://ansible.readthedocs.io/projects/builder/en/stable/definition/#overview
version: 3
additional_build_files:
- src: files/ansible.cfg
dest: configs
ee_base_image: registry.redhat.io/ansible-automation-platform-24/ee-minimal-rhel9:latest
dependencies:
system:
- ...
python:
- ...
collections:
- name: ansible.utils
version: ">=3.1.0"
- ...
additional_build_steps:
prepend_galaxy:
- ADD _build/configs/ansible.cfg ~/.ansible.cfg
directory:
init:
lint:
enabled: true
code_bot:
enabled: true
interval: weekly
vscode:
enabled: true
settings:
"files.trimTrailingWhitespace": true
"editor.renderFinalNewline": "on"
"files.trimFinalNewlines": true
folders:
- name: plugins
folders:
...
files:
- README.md
files:
- playbook.yml
role:
dependencies:
output_fmt: html # [html,json]
output_dest: graph.html
include_tests: false
master_node: role-common-setup
initial_direction: downstream
title: ansible-butler roles dependency graph
title_text_color: white
title_background_color: black
tree_options:
# Customize the color palette
circleStrokeColor: '#2b8f91'
linkStrokeColor: '#dddddd'
closedNodeCircleColor: '#9bd3d4'
openNodeCircleColor: white
cyclicNodeColor: '#FF4242'
missingNodeColor: '#CC0100'
maxDepthNodeColor: '#FF5850'
playbook:
update:
modules:
smart_device:
redirect: zjleblanc.kasa.smart_device
custom_module:
redirect: company.it.custom_module
template:
clone:
skip_labels: false
skip_survey: false
skip_schedules: false
auth:
verify_ssl: true
# controller_host: https://controller.example.com # Falls back to env CONTROLLER_HOST
# controller_username: admin # Falls back to env CONTROLLER_USERNAME
# controller_password: secret # Falls back to env CONTROLLER_PASSWORD
# controller_token: token # Falls back to env CONTROLLER_OAUTH_TOKEN
🔗 Default configuration file
🔗 Example adding test plugins directory
🔗 Example adding module redirects
🔗 Example customizing directory init configs
Troubleshooting
ansible-butler: command not found- check the $PATH environment variable and ensure that
~/.local/binis included
- check the $PATH environment variable and ensure that
License
GNU General Public License
Author Information
Zach LeBlanc
Red Hat
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ansible-butler-1.2.5.tar.gz.
File metadata
- Download URL: ansible-butler-1.2.5.tar.gz
- Upload date:
- Size: 82.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
847ae02c6226fecb174f3293fbfd1121ee8577a8ba9d424b3ed66d5095128f5e
|
|
| MD5 |
de63ae58dbd8622ac9a5a512ac2cc655
|
|
| BLAKE2b-256 |
b4e220eb7be7d3e873860952a20c62ae33a498c8c46044becabab126373326d0
|
File details
Details for the file ansible_butler-1.2.5-py3-none-any.whl.
File metadata
- Download URL: ansible_butler-1.2.5-py3-none-any.whl
- Upload date:
- Size: 83.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8cfd6924d6f15dab82cb6d8a223e06f04ce2e51db55b770053bd005379a62f8
|
|
| MD5 |
fea9c52803ff0231cc8cee86fd87225f
|
|
| BLAKE2b-256 |
a83c1f425eb929425f725b51eeb81caf2310c5bec386d7cac057bf4052473d26
|