initial commit
This commit is contained in:
2
ansible/ansible-rpi-cluster/.gitignore
vendored
Executable file
2
ansible/ansible-rpi-cluster/.gitignore
vendored
Executable file
@@ -0,0 +1,2 @@
|
||||
.DS_Store
|
||||
hosts
|
||||
21
ansible/ansible-rpi-cluster/LICENSE
Executable file
21
ansible/ansible-rpi-cluster/LICENSE
Executable file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Pavlos Ratis
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
47
ansible/ansible-rpi-cluster/README.md
Executable file
47
ansible/ansible-rpi-cluster/README.md
Executable file
@@ -0,0 +1,47 @@
|
||||
# ansible-rpi-cluster
|
||||
|
||||
This is a basic collection of Ansible playbooks to perform common tasks in a Raspberry Pi cluster.
|
||||
|
||||
Feel free to contribute other common tasks that would be useful.
|
||||
|
||||
## Requirements
|
||||
|
||||
* [Ansible](http://www.ansible.com/)
|
||||
|
||||
## Installation
|
||||
|
||||
Clone the repository
|
||||
|
||||
git clone https://github.com/dastergon/ansible-rpi-cluster.git
|
||||
|
||||
Copy `hosts.sample` to `hosts`
|
||||
|
||||
cp hosts.sample hosts
|
||||
|
||||
Edit `hosts` file with your own topology. For example:
|
||||
|
||||
```
|
||||
[all:vars]
|
||||
ansible_user=pi
|
||||
ansible_ssh_pass=addyourpassword
|
||||
|
||||
[picluster]
|
||||
192.168.1.2
|
||||
192.168.1.3
|
||||
192.168.1.4
|
||||
192.168.1.5
|
||||
```
|
||||
|
||||
Run any of the playbooks.
|
||||
|
||||
## Shutdown
|
||||
|
||||
To shutdown all your RPis execute the following playbook:
|
||||
|
||||
ansible-playbook playbooks/shutdown.yml -i hosts
|
||||
|
||||
## Reboot
|
||||
|
||||
To shutdown all your RPis execute the following playbook:
|
||||
|
||||
ansible-playbook playbooks/reboot.yml -i hosts
|
||||
11
ansible/ansible-rpi-cluster/catalog-info.yaml
Normal file
11
ansible/ansible-rpi-cluster/catalog-info.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
apiVersion: backstage.io/v1alpha1
|
||||
kind: Component
|
||||
metadata:
|
||||
name: ansible-ansible-rpi-cluster
|
||||
title: Ansible-rpi-cluster (ansible)
|
||||
spec:
|
||||
type: service
|
||||
lifecycle: production
|
||||
owner: platform-team
|
||||
partOf:
|
||||
- ../catalog-info.yaml
|
||||
2
ansible/ansible-rpi-cluster/hosts.sample
Executable file
2
ansible/ansible-rpi-cluster/hosts.sample
Executable file
@@ -0,0 +1,2 @@
|
||||
[picluster]
|
||||
rpi-worker 192.168.1.123
|
||||
15
ansible/ansible-rpi-cluster/playbooks/reboot.yml
Executable file
15
ansible/ansible-rpi-cluster/playbooks/reboot.yml
Executable file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
- name: Playbook for rebooting the RPis
|
||||
hosts: picluster
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- name: 'Reboot RPi'
|
||||
shell: shutdown -r now
|
||||
async: 0
|
||||
poll: 0
|
||||
ignore_errors: true
|
||||
become: true
|
||||
|
||||
- name: "Wait for reboot to complete"
|
||||
local_action: wait_for host={{ ansible_host }} port=22 state=started delay=10
|
||||
become: false
|
||||
15
ansible/ansible-rpi-cluster/playbooks/shutdown.yml
Executable file
15
ansible/ansible-rpi-cluster/playbooks/shutdown.yml
Executable file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
- name: Playbook for shutting down the RPis
|
||||
hosts: picluster
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- name: 'Shutdown RPi'
|
||||
shell: shutdown -h now
|
||||
async: 0
|
||||
poll: 0
|
||||
ignore_errors: true
|
||||
become: true
|
||||
|
||||
- name: "Wait for shutdown to complete"
|
||||
local_action: wait_for host={{ ansible_host }} port=22 state=stopped
|
||||
become: false
|
||||
8
ansible/ansible-rpi-cluster/playbooks/update.yml
Executable file
8
ansible/ansible-rpi-cluster/playbooks/update.yml
Executable file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
- name: Playbook for managing the updates in RPi
|
||||
hosts: picluster
|
||||
tasks:
|
||||
- name: 'Update apt package cache'
|
||||
become: yes
|
||||
apt:
|
||||
update_cache=yes
|
||||
11
ansible/ansible-rpi-cluster/playbooks/upgrade.yml
Executable file
11
ansible/ansible-rpi-cluster/playbooks/upgrade.yml
Executable file
@@ -0,0 +1,11 @@
|
||||
---
|
||||
- name: Playbook for upgrading the RPis
|
||||
hosts: picluster
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- name: Update and upgrade apt packages
|
||||
become: true
|
||||
apt:
|
||||
upgrade: yes
|
||||
update_cache: yes
|
||||
cache_valid_time: 86400
|
||||
Reference in New Issue
Block a user