Created ansible script to configure target controller
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
||||
# VS Code
|
||||
.vscode/browse.vc.db
|
||||
.vscode/browse.vc.db-shm
|
||||
.vscode/browse.vc.db-wal
|
||||
.vscode/c_cpp_properties.json
|
||||
|
||||
# colcon build artefacts
|
||||
build/
|
||||
install/
|
||||
log/
|
||||
|
||||
# Python
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*.egg-info/
|
||||
dist/
|
||||
@@ -0,0 +1,60 @@
|
||||
# Robot Setup — Ansible
|
||||
|
||||
Automates provisioning of the Raspbot V2 target (`raspbot-v2.local`).
|
||||
|
||||
## What it does
|
||||
|
||||
| Step | Detail |
|
||||
|---|---|
|
||||
| Enable SPI | Runs `raspi-config nonint do_spi 0` so the hardware interface is available at boot |
|
||||
| Install Docker | Uses the [`geerlingguy.docker`](https://galaxy.ansible.com/geerlingguy/docker) role |
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Ansible installed on your local machine (`pip install ansible`)
|
||||
- SSH access to `raspbot-v2.local` (key-based auth recommended)
|
||||
- The target is running Raspberry Pi OS
|
||||
|
||||
## Configuration
|
||||
|
||||
Before running the playbook, set `robot_user` in `inventory.ini` to the non-root user account on the robot (i.e. the username you configured during imaging):
|
||||
|
||||
```ini
|
||||
[raspbot:vars]
|
||||
robot_user=matt
|
||||
```
|
||||
|
||||
This user will be added to the `docker` group so that Docker commands can be run without `sudo`.
|
||||
|
||||
## Usage
|
||||
|
||||
**1. Install the required role:**
|
||||
|
||||
```bash
|
||||
ansible-galaxy install -r ansible/requirements.yml
|
||||
```
|
||||
|
||||
**2. Run the playbook:**
|
||||
|
||||
The playbook runs tasks as root (`become: true`), so Ansible needs the sudo password for the remote user. Always include `-K`:
|
||||
|
||||
```bash
|
||||
ansible-playbook -i ansible/inventory.ini ansible/setup_robot.yml -K
|
||||
```
|
||||
|
||||
If you haven't set up SSH key-based auth yet, also add `-k` to prompt for the SSH password:
|
||||
|
||||
```bash
|
||||
ansible-playbook -i ansible/inventory.ini ansible/setup_robot.yml -k -K
|
||||
```
|
||||
|
||||
The SSH user is taken from `robot_user` in `inventory.ini`, so there is no need to pass `-u` separately.
|
||||
|
||||
## Files
|
||||
|
||||
```
|
||||
ansible/
|
||||
├── inventory.ini # Defines the raspbot-v2.local host
|
||||
├── requirements.yml # Ansible Galaxy role dependencies
|
||||
└── setup_robot.yml # Main playbook
|
||||
```
|
||||
@@ -0,0 +1,5 @@
|
||||
[raspbot]
|
||||
raspbot-v2.local
|
||||
|
||||
[raspbot:vars]
|
||||
robot_user=matt
|
||||
@@ -0,0 +1,2 @@
|
||||
roles:
|
||||
- name: geerlingguy.docker
|
||||
@@ -0,0 +1,16 @@
|
||||
---
|
||||
- name: Setup robot
|
||||
hosts: raspbot
|
||||
become: true
|
||||
|
||||
vars:
|
||||
docker_users:
|
||||
- "{{ robot_user }}"
|
||||
|
||||
pre_tasks:
|
||||
- name: Enable SPI via raspi-config
|
||||
command: raspi-config nonint do_spi 0
|
||||
changed_when: false
|
||||
|
||||
roles:
|
||||
- geerlingguy.docker
|
||||
Reference in New Issue
Block a user