Ansible integration
qbee Ansible Integration¶
Overview¶
qbee integrates with Ansible through the qbee-cli
tool, enabling secure SSH access to device fleets via port forwarding. The integration includes qbee-devices-ansible.py
for automatic Ansible inventory generation based on qbee device groups or tags.
Prerequisites¶
- Active qbee-cli session (
qbee-cli login
) - SSH public keys distributed to target devices via qbee
Inventory Generation¶
Generate Ansible inventory files using one of two methods:
Group-Based Organization¶
qbee-cli devices list --json --limit <n> | python3 qbee-devices-ansible.py --by-groups > ansible_inventory.yml
Tag-Based Organization¶
qbee-cli devices list --json --limit <n> | python3 qbee-devices-ansible.py --by-tags > ansible_inventory.yml
Generated Inventory Structure¶
The tool generates YAML inventory files with the following structure:
example_tag_1:
hosts:
636f6e04f254592cc99a7324f2ba07f2abe3755d5f5c4fd941379c6e5094afd5:
ansible_ssh_common_args: -o StrictHostKeyChecking=no -o ProxyCommand="qbee-cli
connect -d 636f6e04f254592cc99a7324f2ba07f2abe3755d5f5c4fd941379c6e5094afd5
-t stdio:localhost:22"
Example Playbook¶
Sample playbook for reading MOTD from RaspberryPi devices:
---
- name:
gather_facts: false
hosts: example_tag_1
tasks:
- name: get motd
ansible.builtin.command: cat /etc/motd
register: mymotd
- name: debug motd
debug:
msg: "This is my motd: {{ mymotd }}"
Execute the playbook:
ansible-playbook -i ansible_inventory.yml --user pi ansible_playbook.yml
Technical Implementation¶
- Uses qbee-cli's port forwarding functionality for secure device access
- Automatically configures SSH ProxyCommand for each device
- Supports both group and tag-based device organization
- Devices are identified by unique qbee IDs in the inventory
Resources¶
- qbee-cli repository: https://github.com/qbee-io/qbee-cli