diff --git a/hosts.yml b/hosts.yml index c3c18a8..21b92fc 100755 --- a/hosts.yml +++ b/hosts.yml @@ -5,12 +5,12 @@ datacenter: children: odroid_master: hosts: - 192.168.77.131: + 192.168.99.101: vars: testVar: 999 odroid_worker: hosts: - 192.168.77.13[2:5]: + 192.168.99.10[2:5]: vars: ansible_ssh_user: jd diff --git a/playbooks/00_initial_adjustments.yml b/playbooks/00_initial_adjustments.yml index e2ed4f2..6b75c84 100755 --- a/playbooks/00_initial_adjustments.yml +++ b/playbooks/00_initial_adjustments.yml @@ -1,7 +1,7 @@ - hosts: odroid_cluster name: Initial Adjustments become: true - gather_facts: yes + gather_facts: true vars: iface: "eth0" tasks: @@ -47,15 +47,46 @@ odroidc4-5 {%- endif -%} 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 ansible.builtin.command: iptables -F - ignore_errors: yes + ignore_errors: true - name: Iptables 2 ansible.builtin.command: update-alternatives --set iptables /usr/sbin/iptables-legacy - ignore_errors: yes + ignore_errors: true - name: Iptables 3 ansible.builtin.command: update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy - ignore_errors: yes \ No newline at end of file + ignore_errors: true \ No newline at end of file diff --git a/playbooks/00_setup_display.yml b/playbooks/00_setup_display.yml index a980553..ab5eb51 100755 --- a/playbooks/00_setup_display.yml +++ b/playbooks/00_setup_display.yml @@ -1,17 +1,25 @@ - hosts: odroid_master name: Setup info display become: true - gather_facts: no + gather_facts: false tasks: - name: Install deps... ansible.builtin.apt: name: - python3-pip - python3-dev + - python3-venv + - i2c-tools + update_cache: yes + - name: Remove file (delete file) ansible.builtin.file: path: /usr/lib/python3.11/EXTERNALLY-MANAGED 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 ansible.builtin.pip: @@ -20,6 +28,8 @@ - psutil - smbus2 - uptime + virtualenv: /opt/myenv + - name: Upload led control scripts ansible.builtin.copy: src: scripts/lcd_control.py diff --git a/playbooks/files/scripts/lcd_control.py b/playbooks/files/scripts/lcd_control.py index ad5acbf..c899a31 100755 --- a/playbooks/files/scripts/lcd_control.py +++ b/playbooks/files/scripts/lcd_control.py @@ -27,7 +27,7 @@ while True: myCmd = "" # Write a string on first line and move to next line 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]) cpu_load = round(psutil.getloadavg()[0],2) uptime_s = int(uptime()) diff --git a/playbooks/files/services/lcd_control.service b/playbooks/files/services/lcd_control.service index d9e25cc..6f9910a 100755 --- a/playbooks/files/services/lcd_control.service +++ b/playbooks/files/services/lcd_control.service @@ -7,7 +7,7 @@ After=network.target network-online.target Type=simple User=root #ExecStartPre=/bin/sleep 30 -ExecStart=/usr/bin/python3 /usr/bin/lcd_control.py +ExecStart=/opt/myenv/bin/python3 /usr/bin/lcd_control.py [Install] WantedBy=multi-user.target suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target diff --git a/roles/kubernetes/tasks/Rocky.yml b/roles/kubernetes/tasks/Rocky.yml index c815ca9..efcd501 100644 --- a/roles/kubernetes/tasks/Rocky.yml +++ b/roles/kubernetes/tasks/Rocky.yml @@ -58,6 +58,7 @@ - lvm2 - epel-release - git + - helm state: present - name: Add Kubernetes repo