Skip to content

Run ansible playbooks on devices connected to Teknoir Platform

Notifications You must be signed in to change notification settings

teknoir/ansible

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Teknoir Ansible Inventory Plugin

The easiest way to start off is to clone and run the install script:

./install.sh

Ofc you need to have Ansible installed! ... and kubernetes python packages

Limitations

  • As namespaces/labels become groups, and Ansible do not support namespaces/labels with dashes(-).
    • Dashes(-) will be replaced with underscores(_), remember that when using them!!!
  • You have to set kubectl context before running ansible commands.
  • Start tunneling for the device manually, and disable tunneling when done, all from the teknoir cloud console.

Namespaces & labels become ansible groups

To see all ansible groups use the inventory command below.

Dashes(-) will be replaced with underscores(), remember that when limiting playbooks Device labels are concatenated with underscore i.e. f"{key}{value}" to create an ansible group name

Inventory

Creates an inventory so you are able to connect to any device in any namespace. To see inventory run:

python3 inventory.py --list

List devices

ansible -i inventory.py --list-hosts all

List devices

ansible -i inventory.py --list-hosts <namespace>

Ansible commands

Quick commands to manipulate devices

Synchronize (rsync) from host to local

ansible <device_name> -m synchronize -a "src=/path/to/source/dir/ dest=/path/to/local/target/dir/ use_ssh_args=yes mode=pull"

Synchronize does not work with "become"(sudo)

Syncronize (rsync) from local to host

ansible <device_name> -m synchronize -a "src=/path/to/local/source/dir/ dest=/path/to/target/dir/ use_ssh_args=yes"

Synchronize does not work with "become"(sudo)

Run playbook examples

Run for one device:

ansible-playbook -v -i inventory.py test-playbook.yaml --limit <device_name>

Run for all devices in a namespace:

ansible-playbook -v -i inventory.py test-playbook.yaml --limit <namespace>

Run for all devices with label:

ansible-playbook -v -i inventory.py test-playbook.yaml --limit <label>

CHANGELOG

2024-09-08

  • Removed become=yes from inventory.py, so it is possible to run synchronize module, but it also means that you are no longer able to run commands that require sudo by default.

About

Run ansible playbooks on devices connected to Teknoir Platform

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published