A Skeleton Dev Container preconfigured with the OpenNebula CLI, and Ansible
OpenNebula is an Open Source Cloud & Edge Computing Platform.
A development container allows you to use a container as an isolated, full-featured development environment.
Pocket Nebula provides an instant isolated environment for OpenNebula operations (host and guest config and management).
This repository provides a clean starting point for OpenNebula automation projects. It includes:
- DevContainer: Complete development environment with Ansible and OpenNebula tools
- Ansible Structure: Basic inventory and playbook examples
- Documentation: Setup guides and usage examples
This guide walks you through setting up Pocket Nebula from scratch to running your first automation.
Before starting, ensure you have:
- Git: For cloning the repository
- VS Code: With the Dev Containers Extension
- Docker: For running the development container
- OpenNebula Access: Your OpenNebula instance URL and credentials
- SSH Keys: For Ansible host access (optional but recommended)
Run these commands on your HOST system (not in the container):
# Clone the repository
git clone https://github.com/your-username/pocket-nebula.git
cd pocket-nebula
# Verify the repository structure
ls -la
# Expected: .devcontainer/, inventory/, roles/, README.md, etc.
vscode β /workspaces/pocket-nebula (main) $
, you're already inside the dev container! Exit to your host system first.
Run these commands on your HOST system (not in the container):
Set up your OpenNebula credentials on your host system:
# Add to your shell profile (~/.bashrc, ~/.zshrc, etc.)
export ONE_USERNAME=your-opennebula-username
export ONE_PASSWORD=your-opennebula-password
export ONE_URL=https://your-opennebula-host/RPC2 # RPC API endpoint
export ONEFLOW_URL=https://your-opennebula-host:2474 # OneFlow endpoint (optional)
# Optional: Override CLI version (see CLI Version Management section)
export OPENNEBULA_CLI_VERSION_OVERRIDE="~> 6.10.0"
# Optional: Ansible vault password for encrypted files
export ANSIBLE_VAULT_PASSWORD=your-vault-password
# Reload your shell profile
source ~/.bashrc # or ~/.zshrc
Run these commands on your HOST system (not in the container):
For OpenNebula CLI authentication:
# Create OpenNebula credentials directory
mkdir -p ~/.one
# Create authentication file
echo "your-username:your-password" > ~/.one/one_auth
chmod 600 ~/.one/one_auth
# Verify the file was created
ls -la ~/.one/
Run these commands on your HOST system (not in the container):
For encrypted sensitive data:
# Create vault directory
mkdir -p ~/.ansible-vault
# Create vault password file
echo "your-vault-password" > ~/.ansible-vault/.vault-file
chmod 600 ~/.ansible-vault/.vault-file
# Verify the setup
ls -la ~/.ansible-vault/
Run these commands on your HOST system (not in the container):
# Open VS Code in the project directory
code .
# In VS Code:
# 1. Press Ctrl+Shift+P (Cmd+Shift+P on Mac)
# 2. Type "Dev Containers: Reopen in Container"
# 3. Select the command
# 4. Wait for the container to build (first time may take 5-10 minutes)
β
Success: You'll know you're in the container when you see the prompt change to vscode β /workspaces/pocket-nebula (main) $
Run these commands INSIDE the dev container (you should see vscode β /workspaces/pocket-nebula (main) $
):
Once the container is running, verify everything is working:
# Check environment variables are loaded
env | grep ONE
# Expected output:
# ONE_USERNAME=your-username
# ONE_PASSWORD=your-password
# ONE_URL=https://your-opennebula-host/RPC2
# ONEFLOW_URL=https://your-opennebula-host:2474
# Test OpenNebula CLI
onevm list
# Should show your VMs or an empty list
# Test Ansible installation
ansible --version
# Should show Ansible version and configuration
# Test ansible-lint
ansible-lint --version
# Should show ansible-lint version
# Check mounted directories
ls -la ~/.ssh/ # Should show your SSH keys
ls -la ~/.one/ # Should show OpenNebula credentials
ls -la ~/.ansible-vault/ # Should show vault files
Run these commands INSIDE the dev container (you should see vscode β /workspaces/pocket-nebula (main) $
):
# View the available inventory
ansible-inventory --inventory inventory/opennebula --graph
# Run the example playbook
ansible-playbook --inventory inventory/opennebula catalog-guests.yml
# Check the playbook output
cat catalog-guests.yml
This devcontainer automatically detects your OpenNebula server version and installs compatible CLI tools.
The devcontainer uses the one.system.version
XML-RPC method to detect your server version:
# Check what version was detected
.devcontainer/detect-opennebula-version.sh
# See the CLI version specifier that would be used
.devcontainer/detect-opennebula-version.sh cli-spec
You can override the automatic detection by setting OPENNEBULA_CLI_VERSION_OVERRIDE
in your host environment or .devcontainer/devcontainer.env
:
# Force install 6.8.x compatible tools
OPENNEBULA_CLI_VERSION_OVERRIDE="~> 6.8.0"
# Install exact version
OPENNEBULA_CLI_VERSION_OVERRIDE="6.10.0"
# Install latest 7.x tools (if working with newer servers)
OPENNEBULA_CLI_VERSION_OVERRIDE="~> 7.0.0"
After changing the override, rebuild your devcontainer for the changes to take effect.
# Show full server version
.devcontainer/detect-opennebula-version.sh
# Show CLI gem version specifier for compatibility
.devcontainer/detect-opennebula-version.sh cli-spec
# Show CLI version number
.devcontainer/detect-opennebula-version.sh cli-version
# Show configuration status
.devcontainer/show-opennebula-config.sh
- OpenNebula 6.x servers: Compatible CLI tools (6.8, 6.10, etc.)
- OpenNebula 7.x servers: Compatible CLI tools (7.0+)
- Fallback: If detection fails, defaults to 6.10.x tools
The devcontainer supports multiple configuration sources in order of precedence:
-
OpenNebula Credentials:
ONE_USERNAME
andONE_PASSWORD
: Your OpenNebula credentialsONE_URL
: XML-RPC endpoint (required)ONEFLOW_URL
: OneFlow endpoint (optional)OPENNEBULA_CLI_VERSION_OVERRIDE
: Force specific CLI version (optional)
-
Ansible Configuration:
ANSIBLE_VAULT_PASSWORD
: Vault password (highest priority)~/.ansible-vault/.vault-file
: Vault password file (mounted from host)vault_password_file
setting inansible.cfg
Note: The OPENNEBULA_USER_PASS
variable in devcontainer.env
is a template and not used by default. Your actual OpenNebula credentials should be set via the ONE_USERNAME
and ONE_PASSWORD
environment variables, which take precedence.
The container automatically mounts these directories from your host:
~/.ssh
β/home/vscode/.ssh
(SSH keys for Ansible)~/.one
β/home/vscode/.one
(OpenNebula CLI credentials)~/.ansible-vault
β/home/vscode/.ansible-vault
(Ansible vault files)
All commands below should be run INSIDE the dev container (you should see vscode β /workspaces/pocket-nebula (main) $
):
# List all VMs
onevm list
# List networks
onevnet list
# List hosts
onehost list
# List users
oneuser list
# Get VM details
onevm show <vm-id>
# Create a VM from template
onevm create <template-name>
# View inventory structure
ansible-inventory --inventory inventory/opennebula --graph
# Run playbook with inventory
ansible-playbook --inventory inventory/opennebula catalog-guests.yml
# Run with vault password
ansible-playbook --inventory inventory/opennebula your-playbook.yml --ask-vault-pass
# Test connectivity to hosts
ansible all --inventory inventory/opennebula -m ping
# Run ad-hoc commands
ansible all --inventory inventory/opennebula -m shell -a "uptime"
# Lint your Ansible playbooks
ansible-lint catalog-guests.yml
# Check syntax
ansible-playbook --syntax-check catalog-guests.yml
# Dry run (check mode)
ansible-playbook --inventory inventory/opennebula catalog-guests.yml --check
The devcontainer provides a complete development environment with:
- Ansible: Latest version with pipx isolation
- ansible-lint: Code quality and best practices checking
- OpenNebula CLI: Ruby-based command-line tools
- pyone: Python library for API integration
- VS Code Extensions: Docker and Ansible support
pocket-nebula/
βββ .devcontainer/ # Development container configuration
β βββ Dockerfile # Container image definition
β βββ devcontainer.json # VS Code devcontainer config
β βββ devcontainer.env # Environment variables template
β βββ setup.sh # Container setup script
βββ inventory/ # Ansible inventory files
β βββ opennebula/ # OpenNebula-specific inventory
βββ roles/ # Ansible roles (add your own)
β βββ requirements.yml # Role dependencies
βββ catalog-guests.yml # Example playbook
βββ ansible.cfg # Ansible configuration
This is a skeleton repository. Customize it for your specific needs:
- Add Your Roles: Create Ansible roles in the
roles/
directory - Configure Inventory: Update
inventory/opennebula/opennebula.yml
with your hosts - Create Playbooks: Add your automation playbooks
- Environment Variables: Set up your specific OpenNebula instance details
- CA Certificates: Add your own CA certificates if needed for your OpenNebula instance
SSL Certificate Issues:
# Add your CA certificate to the Dockerfile if needed
# Edit .devcontainer/Dockerfile and add:
# COPY your-ca.crt /usr/local/share/ca-certificates/
# RUN update-ca-certificates
Authentication Problems:
# Verify your OpenNebula credentials (run INSIDE container)
env | grep ONE
# Test OpenNebula connection (run INSIDE container)
onevm list
Ansible Connection Issues:
# Check SSH key permissions (run INSIDE container)
ls -la ~/.ssh/
# Test host connectivity (run INSIDE container)
ansible all --inventory inventory/opennebula -m ping
Vault Issues:
# Verify vault password is accessible (run INSIDE container)
ls -la ~/.ansible-vault/
# Test vault password (run INSIDE container)
echo $ANSIBLE_VAULT_PASSWORD
Container Build Issues:
# Rebuild the container from scratch (takes a few minutes)
# In VS Code: Ctrl+Shift+P β "Dev Containers: Rebuild Container without Cache"
Wrong Terminal Location:
- If you see
vscode β /workspaces/pocket-nebula (main) $
but need to run host commands, exit the container first - If you don't see that prompt but need to run container commands, make sure you're in the dev container
This is a skeleton repository. Feel free to:
- Fork and customize for your projects
- Submit improvements to the devcontainer setup
- Add example playbooks and roles
- Improve documentation
This project is provided as-is for educational and development purposes.