Skip to main content

Pluggable Infrastructure CLI as a wrapper around DevOps tools.

Project description

infra-cli

License Python Version

infra-cli is a pluggable infrastructure management tool designed to wrap common DevOps tools (Terragrunt, Ansible, Pulumi, Packer, Terraform, etc.) into a single, unified interface. It simplifies complex workflows through sensible conventions and centralized configuration, and helps learners follow best practices from day one (directory layout, config, and official-style docs).

🎓 DevOps Learning

Use infra to create learning projects that follow best-practice structure and include READMEs with official docs, tool best practices, and a step-by-step learning path from zero to advanced infrastructure engineer:

# Create a Python project (src layout, pyproject.toml, tests, README with learning path)
infra python -p learn-python

# Ansible: scaffold playbooks and structure
infra ansible -p learn-ansible --create

# Terragrunt: scaffold multi-env layout (account/region/env/name)
infra tg -e dev -p learn-tg -r us-east-1 -s vpc --create

Recommended order: PythonAnsibleTerraform / TerragruntPackerPulumi → (future K8s). See docs/LEARNING_PATH.md for the full path and links to official documentation.

🚀 Key Features

  • Unified Interface: A single command (infra) to manage multiple infrastructure tools.
  • Plugin Architecture: Easily extensible logic for different tools.
  • Convention over Configuration: Default directory structures that "just work."
  • Centralized Config: Manage all tool settings in one place (~/.infra/config.yaml).
  • AWS SSO Integration: Seamlessly handles authentication and profile generation.
  • Local Environment Setup: Automate the configuration of your macOS or Ubuntu dev environment.

🛠 Supported Plugins

  • python: Scaffold a best-practice Python project (src layout, pyproject.toml, README with official docs and learning path). Example: infra python -p learn-python.
  • setup: Bootstrap your local development environment (macOS/Ubuntu).
  • ansible: Wrapper for ansible-playbook with automatic project scaffolding (--create).
  • aws: AWS subcommands: login (SSO, default), sync (sync account/role profiles), whoami (caller identity), exec (run any AWS CLI command), env (print export AWS_PROFILE=... for eval).
  • packer: Build and validate machine images consistently.
  • terragrunt: Manage Terraform state and deployments with Terragrunt; --create scaffolds AWS-style layout.
  • terraform: Run native Terraform commands (plan, apply, etc.) with infra context.
  • pulumi: Infrastructure as Code using Pulumi.
  • github: Manage repository settings and scaffolding.
  • slack: Send notifications to Slack webhooks.

🏁 Quick Start

Installation

From PyPI (recommended):

brew install pipx
brew upgrade pipx
pipx install infra-cli
# or: pip install infra-cli

If you see "No matching distribution found" or "Requires-Python >=3.12", pipx may be using a Python < 3.12. Use the interpreter that satisfies the requirement:

pipx install --python python3.12 infra-cli
# or from your venv: pip install infra-cli

From source (development or unreleased version):

git clone https://github.com/hanyouqing/infra-cli.git
cd infra-cli
pipx install .
# or: pip install -e .

Source install uses Python 3.12+ (see pyproject.toml).

Basic Usage

# Setup your local environment
infra setup

# AWS: SSO login (default), whoami, or run CLI with profile
infra aws
infra aws whoami --profile sso
infra aws exec s3 ls
eval $(infra aws env --profile sso)

# Run an Ansible playbook
infra ansible site.yml

# Check configuration
infra config

⚙️ Configuration

infra-cli uses a YAML configuration file located at ~/.infra/config.yaml.

Managing Config via CLI

You can get or set configuration values directly:

# Set a default user name for the setup plugin
infra config setup.user_name=your_name

# View current configuration
infra config

Manual Configuration

The default config.yaml is generated on first run with sensible defaults. You can customize per-plugin settings like region, env, or extra_args.

Configurable Directory Tree (Terragrunt / Terraform)

For terragrunt and terraform plugins, the directory tree used by --create and path resolution is configurable via path_pattern:

terragrunt:
  path_pattern: ${account}/${region}/${env}/${name}   # default
  # Or your own layout, e.g.:
  # path_pattern: ${env}/${account}/${region}/${service}/${name}

Placeholders: ${env}, ${account}, ${region}, ${service}, ${name}. Map to CLI: -e→env, -p→account, -r→region, -s→service/name. Empty segments are omitted.

👩‍💻 Development

We welcome contributions! To set up your local development environment:

  1. Clone the repo: git clone https://github.com/hanyouqing/infra-cli.git
  2. Install dev dependencies: make dev-install (or for a reproducible env: pip install -r requirements.txt then pip install -e .)
  3. Optional – regenerate lock file: make lock (requires pip-tools; updates requirements.txt from pyproject.toml)
  4. Run linting: make lint
  5. Run tests: make test

For more details, see CONTRIBUTING.md.

📜 License

This project is licensed under the Apache-2.0 License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

infra_cli-0.1.2.tar.gz (120.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

infra_cli-0.1.2-py3-none-any.whl (150.6 kB view details)

Uploaded Python 3

File details

Details for the file infra_cli-0.1.2.tar.gz.

File metadata

  • Download URL: infra_cli-0.1.2.tar.gz
  • Upload date:
  • Size: 120.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for infra_cli-0.1.2.tar.gz
Algorithm Hash digest
SHA256 0acf7bd4c34c91b99a80f5c3ed8d1ba75bc5a639c61f9eebf97fb3ba8811ab0b
MD5 b51c67af708fd2f5d3723fa4194b9af3
BLAKE2b-256 2c6fee2255eab107591c6d89dff68530e996cb9ed41ee64eb20b00b6842228fc

See more details on using hashes here.

File details

Details for the file infra_cli-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: infra_cli-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 150.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for infra_cli-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3adb5be14e24c3690d841de3dddaca873d1ba139e940be90e07dd87eb266e87f
MD5 e481b901eaf6e618c5e3cb8a7449eca7
BLAKE2b-256 f0aa7444f575db7017c934ffeca8c0c171509a068c2096d25e68abef97a475e0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page