https://github.com/teknoir/ansible
Run ansible playbooks on devices connected to Teknoir Platform
https://github.com/teknoir/ansible
Last synced: 4 months ago
JSON representation
Run ansible playbooks on devices connected to Teknoir Platform
- Host: GitHub
- URL: https://github.com/teknoir/ansible
- Owner: teknoir
- Created: 2021-05-06T12:45:12.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-10-30T18:36:17.000Z (11 months ago)
- Last Synced: 2025-04-12T05:37:04.712Z (6 months ago)
- Language: Python
- Size: 49.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Teknoir Ansible Inventory Plugin
The easiest way to start off is to clone and run the install script:
```bash
./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:
```bash
python3 inventory.py --list
```### List devices
```bash
ansible -i inventory.py --list-hosts all
```## List devices
```bash
ansible -i inventory.py --list-hosts
```## Ansible commands
Quick commands to manipulate devices### Synchronize (rsync) from host to local
```bash
ansible -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
```bash
ansible -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:
```bash
ansible-playbook -v -i inventory.py test-playbook.yaml --limit
```### Run for all devices in a namespace:
```bash
ansible-playbook -v -i inventory.py test-playbook.yaml --limit
```### Run for all devices with label:
```bash
ansible-playbook -v -i inventory.py test-playbook.yaml --limit
```# 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.