mirror of
https://gitlab.sectorq.eu/jaydee/ansible.git
synced 2026-03-16 14:40:00 +01:00
This commit is contained in:
@@ -5,12 +5,12 @@ datacenter:
|
|||||||
children:
|
children:
|
||||||
odroid_master:
|
odroid_master:
|
||||||
hosts:
|
hosts:
|
||||||
192.168.77.131:
|
192.168.99.101:
|
||||||
vars:
|
vars:
|
||||||
testVar: 999
|
testVar: 999
|
||||||
odroid_worker:
|
odroid_worker:
|
||||||
hosts:
|
hosts:
|
||||||
192.168.77.13[2:5]:
|
192.168.99.10[2:5]:
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
ansible_ssh_user: jd
|
ansible_ssh_user: jd
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
- hosts: odroid_cluster
|
- hosts: odroid_cluster
|
||||||
name: Initial Adjustments
|
name: Initial Adjustments
|
||||||
become: true
|
become: true
|
||||||
gather_facts: yes
|
gather_facts: true
|
||||||
vars:
|
vars:
|
||||||
iface: "eth0"
|
iface: "eth0"
|
||||||
tasks:
|
tasks:
|
||||||
@@ -47,15 +47,46 @@
|
|||||||
odroidc4-5
|
odroidc4-5
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
when: ansible_default_ipv4.interface == "end0"
|
when: ansible_default_ipv4.interface == "end0"
|
||||||
|
|
||||||
|
- name: Read armbianEnv.txt
|
||||||
|
ansible.builtin.slurp:
|
||||||
|
path: /boot/armbianEnv.txt
|
||||||
|
register: armbian_env
|
||||||
|
|
||||||
|
- name: Extract current overlays safely
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
current_overlays: >-
|
||||||
|
{{
|
||||||
|
((armbian_env.content | b64decode)
|
||||||
|
| regex_findall('^overlays=(.*)', multiline=True) | first | default(''))
|
||||||
|
}}
|
||||||
|
|
||||||
|
- name: Build merged overlay list
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
merged_overlays: >-
|
||||||
|
{{
|
||||||
|
(current_overlays.split() +
|
||||||
|
['sm1-odroid-c4-i2c1','sm1-odroid-c4-i2c0'])
|
||||||
|
| unique
|
||||||
|
| join(' ')
|
||||||
|
}}
|
||||||
|
|
||||||
|
- name: Ensure overlays line exists with required modules
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: /boot/armbianEnv.txt
|
||||||
|
regexp: '^overlays='
|
||||||
|
line: "overlays={{ merged_overlays }}"
|
||||||
|
backup: yes
|
||||||
|
|
||||||
- name: Iptables 1
|
- name: Iptables 1
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
iptables -F
|
iptables -F
|
||||||
ignore_errors: yes
|
ignore_errors: true
|
||||||
- name: Iptables 2
|
- name: Iptables 2
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
update-alternatives --set iptables /usr/sbin/iptables-legacy
|
update-alternatives --set iptables /usr/sbin/iptables-legacy
|
||||||
ignore_errors: yes
|
ignore_errors: true
|
||||||
- name: Iptables 3
|
- name: Iptables 3
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
|
update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
|
||||||
ignore_errors: yes
|
ignore_errors: true
|
||||||
@@ -1,17 +1,25 @@
|
|||||||
- hosts: odroid_master
|
- hosts: odroid_master
|
||||||
name: Setup info display
|
name: Setup info display
|
||||||
become: true
|
become: true
|
||||||
gather_facts: no
|
gather_facts: false
|
||||||
tasks:
|
tasks:
|
||||||
- name: Install deps...
|
- name: Install deps...
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name:
|
name:
|
||||||
- python3-pip
|
- python3-pip
|
||||||
- python3-dev
|
- python3-dev
|
||||||
|
- python3-venv
|
||||||
|
- i2c-tools
|
||||||
|
update_cache: yes
|
||||||
|
|
||||||
- name: Remove file (delete file)
|
- name: Remove file (delete file)
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: /usr/lib/python3.11/EXTERNALLY-MANAGED
|
path: /usr/lib/python3.11/EXTERNALLY-MANAGED
|
||||||
state: absent
|
state: absent
|
||||||
|
- name: Create virtual environment
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: python3 -m venv /opt/myenv
|
||||||
|
creates: /opt/myenv/bin/activate
|
||||||
|
|
||||||
- name: Install bottle python package
|
- name: Install bottle python package
|
||||||
ansible.builtin.pip:
|
ansible.builtin.pip:
|
||||||
@@ -20,6 +28,8 @@
|
|||||||
- psutil
|
- psutil
|
||||||
- smbus2
|
- smbus2
|
||||||
- uptime
|
- uptime
|
||||||
|
virtualenv: /opt/myenv
|
||||||
|
|
||||||
- name: Upload led control scripts
|
- name: Upload led control scripts
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: scripts/lcd_control.py
|
src: scripts/lcd_control.py
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ while True:
|
|||||||
myCmd = ""
|
myCmd = ""
|
||||||
# Write a string on first line and move to next line
|
# Write a string on first line and move to next line
|
||||||
mem_data = psutil.virtual_memory()
|
mem_data = psutil.virtual_memory()
|
||||||
net_sum = psutil.net_if_addrs()["eth0"]
|
net_sum = psutil.net_if_addrs()["end0"]
|
||||||
eth0_ip = (net_sum[0][1])
|
eth0_ip = (net_sum[0][1])
|
||||||
cpu_load = round(psutil.getloadavg()[0],2)
|
cpu_load = round(psutil.getloadavg()[0],2)
|
||||||
uptime_s = int(uptime())
|
uptime_s = int(uptime())
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ After=network.target network-online.target
|
|||||||
Type=simple
|
Type=simple
|
||||||
User=root
|
User=root
|
||||||
#ExecStartPre=/bin/sleep 30
|
#ExecStartPre=/bin/sleep 30
|
||||||
ExecStart=/usr/bin/python3 /usr/bin/lcd_control.py
|
ExecStart=/opt/myenv/bin/python3 /usr/bin/lcd_control.py
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target
|
WantedBy=multi-user.target suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target
|
||||||
|
|||||||
@@ -58,6 +58,7 @@
|
|||||||
- lvm2
|
- lvm2
|
||||||
- epel-release
|
- epel-release
|
||||||
- git
|
- git
|
||||||
|
- helm
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Add Kubernetes repo
|
- name: Add Kubernetes repo
|
||||||
|
|||||||
Reference in New Issue
Block a user