Docker and Kubernetes setup playbooks + updates to older ones
This commit is contained in:
parent
a8315bedfc
commit
aae960166f
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@ ios_devices/device_backups
|
||||
linux-ubuntu/.DS_Store
|
||||
ios_devices/.DS_Store
|
||||
.DS_Store
|
||||
home_linux/downloads/*
|
||||
24
home_linux/config_files/status.sh
Normal file
24
home_linux/config_files/status.sh
Normal file
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
let upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
|
||||
let secs=$((${upSeconds}%60))
|
||||
let mins=$((${upSeconds}/60%60))
|
||||
let hours=$((${upSeconds}/3600%24))
|
||||
let days=$((${upSeconds}/86400))
|
||||
UPTIME=`printf "%d days, %02dh%02dm%02ds" "$days" "$hours" "$mins" "$secs"`
|
||||
|
||||
# get the load averages
|
||||
read one five fifteen rest < /proc/loadavg
|
||||
|
||||
echo "$(tput setaf 2)
|
||||
.~~. .~~. `date +"%A, %e %B %Y, %r"`
|
||||
'. \ ' ' / .' `uname -srmo`$(tput setaf 1)
|
||||
.~ .~~~..~.
|
||||
: .~.'~'.~. : Uptime.............: ${UPTIME}
|
||||
~ ( ) ( ) ~ Memory.............: `cat /proc/meminfo | grep MemFree | awk {'print $2'}`kB (Free) / `cat /proc/meminfo | grep MemTotal | awk {'print $2'}`kB (Total)
|
||||
( : '~'.~.'~' : ) Load Averages......: ${one}, ${five}, ${fifteen} (1, 5, 15 min)
|
||||
~ .~ ( ) ~. ~ Running Processes..: `ps ax | wc -l | tr -d " "`
|
||||
( : '~' : ) IP Addresses.......: `ip addr | grep inet | awk ' /'192'/ { print $2 }'` and `wget -q -O - http://ipecho.net/plain | tail`
|
||||
'~ .~~~. ~' Weather............: `curl -s "http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=EUR|UK|UK001|NAILSEA|" | sed -n '/Currently:/ s/.*: \(.*\): \([0-9]*\)\([CF]\).*/\2°\3, \1/p'`
|
||||
'~'
|
||||
$(tput sgr0)"
|
||||
17
home_linux/disable_swap.yml
Normal file
17
home_linux/disable_swap.yml
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
- name: Disable swap on Raspberries
|
||||
hosts: all
|
||||
roles:
|
||||
- common
|
||||
become: yes
|
||||
gather_facts: no
|
||||
|
||||
tasks:
|
||||
|
||||
- name: Disable swap
|
||||
ansible.builtin.shell: sudo swapoff -a
|
||||
|
||||
- name: Reboot
|
||||
ansible.builtin.reboot:
|
||||
test_command: uptime
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
roles:
|
||||
- common
|
||||
become: yes
|
||||
gather_facts: no
|
||||
|
||||
tasks:
|
||||
|
||||
@ -14,7 +15,7 @@
|
||||
- name: Copy the log files
|
||||
fetch:
|
||||
src: /var/log/{{ item }}
|
||||
dest: /mnt/c/Ansible/fetched_logs
|
||||
dest: ./downloads/{{ inventory_hostname }}/
|
||||
with_items: "{{ files_to_copy.stdout_lines }}"
|
||||
|
||||
|
||||
|
||||
@ -4,11 +4,20 @@
|
||||
roles:
|
||||
- common
|
||||
become: yes
|
||||
gather_facts: no
|
||||
|
||||
tasks:
|
||||
|
||||
- name: Ensure status script is present
|
||||
ansible.builtin.copy:
|
||||
src: ./config_files/status.sh
|
||||
dest: ./status.sh
|
||||
owner: "{{ ansible_user }}"
|
||||
group: "{{ ansible_user }}"
|
||||
mode: '0755'
|
||||
|
||||
- name: Get device information
|
||||
command: bash /home/vlad/status.sh
|
||||
command: ./status.sh
|
||||
register: status
|
||||
|
||||
- name: Print device information
|
||||
|
||||
@ -1,9 +1,16 @@
|
||||
home:
|
||||
hosts:
|
||||
192.168.0.50:
|
||||
192.168.0.51:
|
||||
192.168.0.52:
|
||||
192.168.0.53:
|
||||
192.168.0.54:
|
||||
all:
|
||||
children:
|
||||
kubernetes:
|
||||
hosts:
|
||||
192.168.0.51:
|
||||
192.168.0.52:
|
||||
192.168.0.53:
|
||||
docker:
|
||||
hosts:
|
||||
192.168.0.50:
|
||||
zero:
|
||||
hosts:
|
||||
192.168.0.54:
|
||||
192.168.0.55:
|
||||
vars:
|
||||
ansible_ssh_private_key_file = /home/vraducanu/.ssh/id_rsa
|
||||
|
||||
65
home_linux/install_docker.yml
Normal file
65
home_linux/install_docker.yml
Normal file
@ -0,0 +1,65 @@
|
||||
---
|
||||
- name: Install Docker on Raspberries
|
||||
hosts: docker
|
||||
roles:
|
||||
- common
|
||||
become: yes
|
||||
gather_facts: no
|
||||
|
||||
tasks:
|
||||
|
||||
- name: Download Docker install script
|
||||
ansible.builtin.get_url:
|
||||
url: https://test.docker.com/
|
||||
dest: ./get-docker.sh
|
||||
group: "{{ ansible_user }}"
|
||||
mode: '0755'
|
||||
|
||||
- name: Trigger script
|
||||
ansible.builtin.command:
|
||||
cmd: ./get-docker.sh >> get-docker.log
|
||||
|
||||
- name: Ensure group "docker" exists
|
||||
ansible.builtin.group:
|
||||
name: docker
|
||||
state: present
|
||||
|
||||
- name: Add user to "docker" group
|
||||
ansible.builtin.user:
|
||||
name: "{{ ansible_user }}"
|
||||
group: docker
|
||||
|
||||
- name: Reboot
|
||||
ansible.builtin.reboot:
|
||||
msg: "Reboot initiated by Ansible"
|
||||
|
||||
- name: Install python3 and pip3
|
||||
ansible.builtin.apt:
|
||||
pkg:
|
||||
- python3
|
||||
- python3-pip
|
||||
state: present
|
||||
|
||||
- name: Install docker-compose
|
||||
ansible.builtin.command:
|
||||
cmd: sudo pip3 install docker-compose
|
||||
|
||||
- name: Enable Docker service
|
||||
ansible.builtin.systemd:
|
||||
name: docker
|
||||
enabled: yes
|
||||
|
||||
- name: Run test container to ensure Docker works
|
||||
ansible.builtin.command:
|
||||
cmd: docker run hello-world
|
||||
register: result
|
||||
|
||||
- name: Show test result
|
||||
ansible.builtin.debug:
|
||||
var: result
|
||||
|
||||
- name: Cleanup install files
|
||||
ansible.builtin.command:
|
||||
cmd: sudo rm get-docker.*
|
||||
|
||||
|
||||
38
home_linux/install_microk8s.yml
Normal file
38
home_linux/install_microk8s.yml
Normal file
@ -0,0 +1,38 @@
|
||||
---
|
||||
- name: Install MicroK8s on Raspberries
|
||||
hosts: kubernetes
|
||||
roles:
|
||||
- common
|
||||
become: yes
|
||||
gather_facts: no
|
||||
|
||||
tasks:
|
||||
|
||||
- name: Install MicroK8s
|
||||
ansible.builtin.snap:
|
||||
channel: stable
|
||||
classic: true
|
||||
name: microk8s
|
||||
state: present
|
||||
register: result
|
||||
|
||||
- name: Display install outcome
|
||||
ansible.builtin.debug:
|
||||
var: result.stdout_lines
|
||||
|
||||
- name: Install kubectl
|
||||
ansible.builtin.snap:
|
||||
channel: stable
|
||||
classic: true
|
||||
name: kubectl
|
||||
state: present
|
||||
|
||||
- name: Create kubectl config folder
|
||||
ansible.builtin.file:
|
||||
path: ~/.kube
|
||||
state: directory
|
||||
mode: "0644"
|
||||
|
||||
- name: Populate kubectl config file
|
||||
ansible.builtin.command:
|
||||
cmd: sudo microk8s config > ~/.kube/config
|
||||
19
home_linux/remove_microk8s.yml
Normal file
19
home_linux/remove_microk8s.yml
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
- name: Remove MicroK8s from Raspberries
|
||||
hosts: kubernetes
|
||||
roles:
|
||||
- common
|
||||
become: yes
|
||||
gather_facts: no
|
||||
|
||||
tasks:
|
||||
|
||||
- name: Uninstall MicroK8s
|
||||
community.general.snap:
|
||||
name: microk8s
|
||||
state: absent
|
||||
register: result
|
||||
|
||||
- name: Display uninstall outcome
|
||||
ansible.builtin.debug:
|
||||
var: result.stdout_lines
|
||||
@ -36,7 +36,7 @@
|
||||
verbosity: 0
|
||||
|
||||
- name: Get interface configuration
|
||||
shell: "ifconfig"
|
||||
shell: "ip addr"
|
||||
register: my_interfaces
|
||||
|
||||
- name: Print interface information
|
||||
|
||||
Loading…
Reference in New Issue
Block a user