gighiveThis document explains how the key Ansible configuration files work together to provision and configure GigHive VMs.
GigHive supports multiple VM configurations (e.g., gighive, gighive2):
gighive is the primary group name, gighive2 group can be used for testing a second vm if needed.ansible.cfg - Global Ansible configurationinventories/inventory_*.yml - Host and group definitionsinventories/group_vars/all.yml - Global group variablesinventories/group_vars/*.yml - Group-specific variablesplaybooks/site.yml - Main playbook with task orchestrationansible-playbook -i ansible/inventories/inventory_bootstrap.yml ansible/playbooks/site.yml
↓
┌─────────────────────────────────────────────────────────────────────┐
│ 1. ansible.cfg (Global Settings) │
│ - inventory = ansible/inventories (directory to scan) │
│ - roles_path = ansible/roles │
│ - collections_path = ansible/collections:~/.ansible/collections │
│ - Various SSH, logging, and performance settings │
└─────────────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────────────┐
│ 2. inventory_bootstrap.yml (Host Definitions) │
│ - Defines group: gighive │
│ - Defines host: gighive_vm (192.168.1.248) │
│ - Makes gighive a child of target_vms │
│ - Sets ansible_user, ansible_host, SSH options │
└─────────────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────────────┐
│ 3. group_vars/all.yml (Global Group Variables) │
│ - repo_root: base path of the repo │
│ - roles_dir: "/ansible/roles" │
│ - cloud_init_files_dir: "/cloud_init/files" │
│ - Other shared convenience paths │
└─────────────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────────────┐
│ 4. group_vars/gighive.yml (Auto-loaded Variables) │
│ - vm_name: "gighive" │
│ - hostname: "gighive" │
│ - static_ip: "" │
│ - app_flavor: gighive │
│ - database_full: false │
│ - All passwords, paths, and configuration variables │
└─────────────────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────────────────┐
│ 5. playbooks/site.yml (Task Execution) │
│ Play 1: hosts: gighive(:gighive2) → VM Provisioning (VirtualBox) │
│ Play 2: hosts: gighive(:gighive2) → Cloud-init Disable │
│ Play 3: hosts: target_vms → Main Configuration (Docker, etc.) │
└─────────────────────────────────────────────────────────────────────┘
Location: /home/sodo/scripts/gighive/ansible.cfg
Purpose: Global Ansible configuration that applies to all playbook runs.
Key Settings:
[defaults]
inventory = ansible/inventories # Where to find inventory files
roles_path = ansible/roles # Where to find roles
collections_path = ansible/collections:~/.ansible/collections:/usr/share/ansible/collections
log_path = ~/.ansible/ansible.log # Logging location
host_key_checking = False # Disable SSH host key checking
stdout_callback = yaml # Output format
callbacks_enabled = timer, profile_tasks, vars_trace
[ssh_connection]
pipelining = True # Faster SSH execution
ssh_args = -o ControlMaster=auto -o ControlPersist=60s
Important Notes:
$GIGHIVE_HOME)ansible-playbook commands from $GIGHIVE_HOMELocation: /home/sodo/scripts/gighive/ansible/playbooks/site.yml
Purpose: Main orchestration playbook that defines what tasks run on which hosts.
Key Plays:
# Play 1: VM Provisioning (runs on Ansible controller)
- name: Provision VM in VirtualBox
hosts: gighive(:gighive2) # Matches either group
connection: local # Runs on controller, not VM
tags: [ vbox_provision,cloud_init ]
roles:
- cloud_init
# Play 2: Cloud-init Disable (runs inside VM after creation)
- name: Disable Cloud-Init inside VM
hosts: gighive(:gighive2) # Matches either group
become: yes
tags: [ vbox_provision,cloud_init_disable ]
roles:
- cloud_init_disable
# Play 3: Main Configuration (runs on all target VMs)
- name: Configure target VM
hosts: target_vms # Parent group containing gighive/gighive2
become: true
roles:
- base
- docker
- security_basic_auth
- post_build_checks
- validate_app
- mysql_backup
Host Pattern Syntax:
gighive:gighive2 - Matches hosts in EITHER group (colon = OR)target_vms - Matches all hosts in the target_vms group (includes both gighive and gighive2)Location: /home/sodo/scripts/gighive/ansible/inventories/
Purpose: Define hosts, groups, and their relationships.
Example: inventory_bootstrap.yml
all:
children:
target_vms: # Parent group
children:
gighive: {} # Child group
gighive: # Group definition
hosts:
gighive_vm: # Host label (arbitrary)
ansible_host: 192.168.1.248 # Actual IP address
ansible_user: ubuntu # SSH user
ansible_python_interpreter: /usr/bin/python3
ansible_ssh_common_args: '-o StrictHostKeyChecking=no'
Key Concepts:
gighive_vm): Arbitrary name Ansible uses internallygighive): Must match playbook hosts: patternsgighive is a child of target_vmsAvailable Inventories:
inventory_bootstrap.yml - Primary gighive VM (e.g. 192.168.1.248)inventory_gighive2.yml - Optional secondary/test VM (gighive2)inventory_baremetal.yml - For bare metal Ubuntu hostsinventory_azure.yml - For Azure cloud deploymentsLocation: /home/sodo/scripts/gighive/ansible/inventories/group_vars/
Purpose: Define variables that automatically apply to specific groups.
Auto-loading Rules:
group_vars/all.yml is loaded for all hosts in all inventoriesgighive, Ansible automatically loads group_vars/gighive.ymlgighive2, Ansible automatically loads group_vars/gighive2.ymlLocation: /home/sodo/scripts/gighive/ansible/inventories/group_vars/all.yml
Purpose: Provide global convenience variables and path roots shared by all environments.
Key Settings:
# One true repo root
repo_root: ""
# Convenience paths
roles_dir: "/ansible/roles"
cloud_init_files_dir: "/cloud_init/files"
These values are referenced by other group vars (for example, cloud_image_dir, cloud_image_vmdk, and nocloud_iso in group_vars/gighive.yml) and by roles such as cloud_init.
Example usage in group_vars/gighive.yml:
# vmdk/vdi specs for local vm
cloud_image_dir: ""
cloud_image_vmdk: "/-server-cloudimg-amd64-.vmdk"
cloud_image_vdi: "/-server-cloudimg-amd64-.vdi"
nocloud_iso: "/seed-.iso"
Example: group_vars/gighive.yml
# VM Identity
hostname: "gighive"
vm_name: "gighive"
static_ip: "" # References inventory value
# VirtualBox Configuration
disk_size_mb: 64000
bridge_iface: "enp8s0"
gateway: "192.168.1.1"
# Application Configuration
app_flavor: gighive # Determines which overlay files to use
database_full: false # Use sample database (not full dataset)
# Media Sync Configuration
sync_video: true
reduced_video: true # Use reduced video set from assets/
sync_audio: true
reduced_audio: true # Use reduced audio set from assets/
# Docker Rebuild Control
rebuild_mysql: false # Preserve MySQL data
rebuild_mysql_data: false # Don't wipe database
# Authentication
admin_user: admin
viewer_user: viewer
uploader_user: uploader
gighive_admin_password:
gighive_viewer_password
gighive_uploader_password:
# Paths (derived from site.yml pre_tasks)
gighive_htpasswd_host_path: "/apache/externalConfigs/gighive.htpasswd"
mysql_backup_script_dir: ""
mysql_backups_dir: "/backups"
# Upload Limits
upload_max_bytes: 6442450944 # 6GB
upload_max_mb: 6144
ansible-playbook -i ansible/inventories/inventory_bootstrap.yml \
ansible/playbooks/site.yml \
--ask-become-pass \
--skip-tags blobfuse2
ansible.cfg
ansible/roles for rolesansible/inventories for inventory filesinventory_bootstrap.yml
gighivegighive_vm at 192.168.1.248gighive2 is a child of target_vmsgroup_vars/all.yml
repo_root, roles_dir, and cloud_init_files_dir are setgroup_vars/gighive.yml
gighivevm_name, hostname, app_flavor are now setAnsible executes site.yml plays in order:
Play 1: Provision VM in VirtualBox
hosts: gighive(:gighive2) matches both the gighive and gighive2 groupsconnection: local means run on controller (not VM)cloud_init role to create VM in VirtualBoxgroup_vars/gighive.ymlPlay 2: Disable Cloud-Init inside VM
hosts: gighive(:gighive2) matches both the gighive and gighive2 groups192.168.1.248cloud_init_disable rolePlay 3: Configure target VM
hosts: target_vms matches because gighive is a childgroup_vars/gighive.ymlThe playbook primarily targets the gighive VM, but can optionally support a second gighive2 VM:
ansible-playbook -i ansible/inventories/inventory_bootstrap.yml \
ansible/playbooks/site.yml \
--ask-become-pass
group_vars/gighive.ymlansible-playbook -i ansible/inventories/inventory_gighive2.yml \
ansible/playbooks/site.yml \
--ask-become-pass
group_vars/gighive2.yml# Match single group
hosts: gighive
# Match multiple groups (OR logic)
hosts: gighive:gighive2
# Match parent group (includes all children)
hosts: target_vms
# Match all hosts
hosts: all
# Match with wildcards
hosts: gighive*
-e on command line)host_vars/)group_vars/) ← Most common for GigHiveSymptom:
[WARNING]: Could not match supplied host pattern, ignoring: gighive
Cause: Playbook references a group name that doesn’t exist in the inventory.
Solution:
playbooks/site.yml hosts: lines match group names in inventoryhosts: gighive:gighive2 to support both configurationsSymptom: Playbook fails with undefined variable errors.
Cause: Group vars file doesn’t match the group name in inventory.
Solution:
gighive → Must have group_vars/gighive.ymlgighive2 → Must have group_vars/gighive2.ymlSymptom: Ansible connects to wrong host or can’t connect.
Cause: ansible_host in inventory doesn’t match actual VM IP.
Solution:
VBoxManage guestproperty enumerate <vm-name> | grep IPansible_host in inventory file to match$GIGHIVE_HOME)
ansible.cfg are relative to repo rootgighive, gighive2, prod, etc.group_vars/*.ymltarget_vms contains common configuration for all VMsgighive, gighive2) contain specific overrides$GIGHIVE_HOME/
├── ansible.cfg # Global Ansible config
├── ansible/
│ ├── inventories/
│ │ ├── inventory_bootstrap.yml # gighive group (192.168.1.248)
│ │ ├── inventory_gighive2.yml # gighive2 group (192.168.1.254)
│ │ ├── inventory_baremetal.yml # Bare metal hosts
│ │ ├── inventory_azure.yml # Azure cloud hosts
│ │ └── group_vars/
│ │ ├── all.yml # Variables for all hosts
│ │ ├── gighive.yml # Variables for gighive group
│ │ ├── gighive2.yml # Variables for gighive2 group
│ │ ├── prod.yml # Variables for prod group
│ │ └── ubuntu.yml # Variables for ubuntu group
│ ├── playbooks/
│ │ └── site.yml # Main orchestration playbook
│ └── roles/
│ ├── cloud_init/ # VM provisioning role
│ ├── cloud_init_disable/ # Cloud-init cleanup role
│ ├── base/ # Base system configuration
│ ├── docker/ # Docker and containers
│ └── ... # Other roles
└── docs/
└── ANSIBLE_FILE_INTERACTION.md # This document