This commit is contained in:
jaydee
2022-12-14 02:23:34 +01:00
parent fdcd79983a
commit 7385b59c72
43 changed files with 1729 additions and 0 deletions

View File

@ -0,0 +1,43 @@
- hosts: datacenter
name: Apt udate
become: true
tasks:
- name: Apt exclude linux-dtb-current-meson64
ansible.builtin.shell: 'apt-mark hold linux-dtb-current-meson64'
changed_when: false
# - name: Install K3S
# ansible.builtin.shell: 'apt-mark hold linux-image-current-meson64'
# changed_when: false
# - name: Install K3S
# ansible.builtin.shell: 'apt-mark hold linux-libc-dev'
# changed_when: false
# - name: Install K3S
# ansible.builtin.shell: 'apt-mark hold linux-u-boot-odroidc4-current'
# changed_when: false
# - name: Install K3S
# ansible.builtin.shell: 'apt-mark hold armbian-bsp-cli-odroidc4'
# changed_when: false
# - name: Install K3S
# ansible.builtin.shell: 'apt-mark hold armbian-config'
# changed_when: false
# - name: Install K3S
# ansible.builtin.shell: 'apt-mark hold armbian-firmware'
# changed_when: false
# - name: Install K3S
# ansible.builtin.shell: 'apt-mark hold armbian-zsh'
# changed_when: false
- name: Apt update
ansible.builtin.shell: 'apt update'
changed_when: false
- name: Apt upgrade
ansible.builtin.shell: 'apt -o Dpkg::Options::="--force-confnew" upgrade -y'
changed_when: false
# - name: Apt
# ansible.builtin.apt:
# update_cache: true
# upgrade: true
# dpkg_options: 'force-confold,force-confdef'
# - name: Get memory
# ansible.builtin.command: /usr/bin/free
# changed_when: false

View File

@ -0,0 +1,8 @@
- hosts: odroid_cluster
tasks:
- name: Set authorized key taken from file
ansible.posix.authorized_key:
user: jd
state: present
key: "{{ lookup('file', '/home/jd/.ssh/id_rsa.pub') }}"

11
playbooks/00_getmac.yml Normal file
View File

@ -0,0 +1,11 @@
- hosts: datacenter
name: Apt udate
become: true
tasks:
- name: Debug
ansible.builtin.debug:
msg: "{{ ansible_eth0.macaddress }}"
- name: Debug
ansible.builtin.debug:
msg: "olalalaaaa"
when: ansible_eth0.macaddress == "b8:27:eb:29:cb:d41"

View File

@ -0,0 +1,42 @@
- hosts: odroid_cluster
name: Run script
become: true
gather_facts: true
tasks:
- name: Reconfigure /root/.bashrc
ansible.builtin.lineinfile:
path: /root/.bashrc
line: "export HISTCONTROL=ignoreboth"
- name: Reconfigure /home/jd/.bashrc
ansible.builtin.lineinfile:
path: /home/jd/.bashrc
line: "export HISTCONTROL=ignoreboth"
- name: Set a hostname
ansible.builtin.hostname:
name: odroidc4-1
when: ansible_eth0.macaddress == "00:1e:06:48:b3:0c"
- name: Set a hostname
ansible.builtin.hostname:
name: odroidc4-2
when: ansible_eth0.macaddress == "00:1e:06:48:cd:86"
- name: Set a hostname
ansible.builtin.hostname:
name: odroidc4-3
when: ansible_eth0.macaddress == "00:1e:06:48:d0:01"
- name: Set a hostname
ansible.builtin.hostname:
name: odroidc4-4
when: ansible_eth0.macaddress == "00:1e:06:48:d0:00"
- name: Set a hostname
ansible.builtin.hostname:
name: odroidc4-5
when: ansible_eth0.macaddress == "00:1e:06:48:cd:8e"
- name: Iptables 1
ansible.builtin.command:
iptables -F
- name: Iptables 2
ansible.builtin.command:
update-alternatives --set iptables /usr/sbin/iptables-legacy
- name: Iptables 3
ansible.builtin.command:
update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy

View File

@ -0,0 +1,103 @@
- hosts: datacenter
name: Install omv
become: true
become_user: root
tasks:
- name: Install ldap packages
ansible.builtin.apt:
name:
- libpam-ldapd
- ldap-utils
- libnss-ldapd
# - name: Reconfigure ldap base
# ansible.builtin.lineinfile:
# path: /etc/ldap.conf
# regexp: "^base "
# line: "base dc=sectorq,dc=eu"
# - name: Reconfigure ldap uri
# ansible.builtin.lineinfile:
# path: /etc/ldap.conf
# regexp: "^uri ldap.*"
# line: "uri ldaps://ldap-server.loc/"
# - name: Reconfigure ldap version
# ansible.builtin.lineinfile:
# path: /etc/ldap.conf
# regexp: "^ldap_version.*"
# line: "ldap_version 3"
# - name: Reconfigure ldap rootbinddn
# ansible.builtin.lineinfile:
# path: /etc/ldap.conf
# regexp: "^rootbinddn.*"
# line: "rootbinddn cn=admin,dc=sectorq,dc=eu"
- name: Reconfigure common-session
ansible.builtin.lineinfile:
path: /etc/pam.d/common-session
regexp: "^session optional pam_mkhomedir.so.*"
line: "session optional pam_mkhomedir.so skel=/etc/skel umask=077"
- name: Reconfigure common-session
ansible.builtin.lineinfile:
path: /etc/pam.d/common-session
regexp: "^session.*pam_ldap.so.*"
line: "session [success=ok default=ignore] pam_ldap.so minimum_uid=1000"
- name: Reconfigure common-password
ansible.builtin.lineinfile:
path: /etc/pam.d/common-password
regexp: "^password.*success=1 user_unknown=ignore default=die.*"
line: "password [success=1 default=ignore] pam_ldap.so minimum_uid=1000 try_first_pass"
- name: Reconfigure nsswitch passwd
ansible.builtin.lineinfile:
path: /etc/nsswitch.conf
regexp: "^passwd:.*"
line: "passwd: compat systemd ldap"
- name: Reconfigure nsswitch group
ansible.builtin.lineinfile:
path: /etc/nsswitch.conf
regexp: "^group:.*"
line: "group: compat systemd ldap"
- name: Reconfigure nsswitch shadow
ansible.builtin.lineinfile:
path: /etc/nsswitch.conf
regexp: "^shadow:.*"
line: "shadow: compat ldap"
- name: Reconfigure nslcd uri
ansible.builtin.lineinfile:
path: /etc/nslcd.conf
regexp: "^uri ldap.*"
line: "uri ldaps://ldap-server.loc/"
- name: Reconfigure ldap base
ansible.builtin.lineinfile:
path: /etc/nslcd.conf
regexp: "^base "
line: "base dc=sectorq,dc=eu"
- name: Reconfigure nslcd binddn
ansible.builtin.lineinfile:
path: /etc/nslcd.conf
regexp: "^#binddn"
line: "binddn cn=admin,dc=sectorq,dc=eu"
- name: Reconfigure nslcd bindpw
ansible.builtin.lineinfile:
path: /etc/nslcd.conf
regexp: "^#bindpw"
line: "bindpw l4c1j4yd33Du5lo"
# - name: Reconfigure ldap base
# ansible.builtin.lineinfile:
# path: /etc/nslcd.conf
# regexp: "^#ssl"
# line: "ssl start_tls"
- name: Reconfigure nslcd tls_reqcert
ansible.builtin.lineinfile:
path: /etc/nslcd.conf
regexp: "^#tls_reqcert"
line: "tls_reqcert allow"
- name: Restart nslcd service
ansible.builtin.service:
name: nslcd.service
state: restarted

View File

@ -0,0 +1,26 @@
- hosts: omv
name: Install omv
become: true
become_user: root
tasks:
- name: Apt
ansible.builtin.apt:
update_cache: true
upgrade: true
- name: Install python + pip
ansible.builtin.apt:
name:
- python3
- python3-pip
- apt-transport-https
- mosquitto
state: present
- name: Install pip modules
ansible.builtin.pip:
name:
- wheel
- paho-mqtt
- ping3
- requests
- autorandr
- getmac

View File

@ -0,0 +1,7 @@
- hosts: odroid_cluster
name: Power off
become: true
gather_facts: false
tasks:
- name: Shut down
community.general.shutdown:

54
playbooks/00_test.yml Normal file
View File

@ -0,0 +1,54 @@
- hosts: odroid_master
name: Install k3s
become: true
tasks:
- name: Install deps...
ansible.builtin.apt:
name:
- python3-pip
- python3-dev
- name: Install bottle python package
ansible.builtin.pip:
name:
- RPLCD
- psutil
- smbus2
- uptime
- name: Upload led control scripts
ansible.builtin.copy:
src: scripts/lcd_control.py
dest: /usr/bin/lcd_control.py
- name: Upload led control service
ansible.builtin.copy:
src: services/lcd_control.service
dest: /etc/systemd/system/
- name: Upload led control scripts
ansible.builtin.copy:
src: scripts/lcd_control_restart.py
dest: /usr/bin/lcd_control_restart.py
- name: Upload led control service
ansible.builtin.copy:
src: services/lcd_control_restart.service
dest: /etc/systemd/system/
- name: Upload led control scripts
ansible.builtin.copy:
src: scripts/lcd_control_start.py
dest: /usr/bin/lcd_control_start.py
- name: Upload led control service
ansible.builtin.copy:
src: services/lcd_control_start.service
dest: /etc/systemd/system/
- name: reload systemctl
ansible.builtin.command: systemctl daemon-reload
- name: Enable service startup lcd_control
ansible.builtin.command: systemctl enable lcd_control.service
- name: Starting service lcd_control
ansible.builtin.command: systemctl start lcd_control.service
- name: Enable service startup lcd_control_restart.service
ansible.builtin.command: systemctl enable lcd_control_restart.service
- name: Enable service startup lcd_control_start.service
ansible.builtin.command: systemctl enable lcd_control_start.service
# - name: Start service lcd_control_restart.service
# ansible.builtin.command: systemctl start lcd_control_restart.service
# - name: start lcd script
# shell: cd /root; nohup python3 lcd_control.py >/dev/null 2>&1 &

47
playbooks/00_tst.yml Normal file
View File

@ -0,0 +1,47 @@
- hosts: odroid_cluster
name: User creation
vars:
ansible_ssh_user: root
ansible_ssh_pass: 1234
myuser: "root"
mypassword: "lacijaydee"
mypassword2: "lacijaydee"
tasks:
- name: Change password
ansible.builtin.user:
name: "{{ myuser }}"
state: present
shell: /bin/bash
expires: -1
password: "{{ mypassword | password_hash('sha512') }}"
- name: Set locale
community.general.locale_gen:
name: en_US.UTF-8
state: present
- name: Create password
ansible.builtin.user:
name: "jd"
state: present
expires: -1
password: "{{ mypassword2 | password_hash('sha512') }}"
shell: /bin/bash
- name: Allow the jd user to run any commands
community.general.sudoers:
name: jd as sudo
state: present
user: jd
nopassword: true
commands: ALL
- name: Set timezone to Europe/Bratislava
community.general.timezone:
name: Europe/Bratislava
- name: Remove first login file
ansible.builtin.file:
state: absent
path: /root/.not_logged_in_yet
- name: Reconfigure logo
ansible.builtin.lineinfile:
path: /boot/armbianEnv.txt
line: "disp_mode=800x480"

8
playbooks/00_win.yml Normal file
View File

@ -0,0 +1,8 @@
- hosts: windows
name: Test
gather_facts: true
tasks:
- name: Run basic PowerShell script
win_file:
path: c:\lala
state: directory

View File

@ -0,0 +1,33 @@
- hosts: odroid_cluster
name: Install docker
become: true
become_user: root
tasks:
- name: Install docker
ansible.builtin.apt:
name: docker.io
state: present
- name: Install telnet
ansible.builtin.apt:
name: telnet
state: present
- name: Install net-tools
ansible.builtin.apt:
name: net-tools
state: present
- name: Install curl!
ansible.builtin.apt:
name: curl
state: present
- name: Install deps...
ansible.builtin.apt:
name:
- python3-pip
- python3-dev
- name: Install bottle python package
ansible.builtin.pip:
name:
- RPLCD
- psutil
- smbus2
- uptime

View File

@ -0,0 +1,155 @@
- hosts: rhasspy
name: Install rhasspy
become: true
become_user: root
tasks:
- name: Set a hostname
ansible.builtin.hostname:
name: rasp3-2
when: ansible_eth0.macaddress == "b8:27:eb:29:cb:d4"
- name: Set a hostname
ansible.builtin.hostname:
name: rasp3-1
when: ansible_eth0.macaddress == "b8:27:eb:53:79:11" or ansible_wlan0.macaddress == "B8:27:EB:06:2C:44"
# - name: Download package
# ansible.builtin.get_url:
# url: https://sectorq.eu/install/rhasspy_amd64.deb
# dest: /tmp/rhasspy_amd64.deb
# mode: '0777'
- name: Get keys for raspotify
ansible.builtin.shell:
curl -sSL https://dtcooper.github.io/raspotify/key.asc | sudo tee /usr/share/keyrings/raspotify_key.asc > /dev/null
changed_when: false
- name: Get keys for raspotify
ansible.builtin.file:
path: /usr/share/keyrings/raspotify_key.asc
mode: "0644"
- name: Get repo
ansible.builtin.shell: >-
echo 'deb [signed-by=/usr/share/keyrings/raspotify_key.asc] https://dtcooper.github.io/raspotify raspotify main' |
sudo tee /etc/apt/sources.list.d/raspotify.list
changed_when: false
- name: Update apt cache
ansible.builtin.apt:
update_cache: true
upgrade: true
ignore_errors: true
- name: Install curl,mosquitto ...
ansible.builtin.apt:
name:
- curl
# - libffi7
- apt-transport-https
- raspotify
- mosquitto
- python3-pip
state: present
- name: Reconfigure /etc/raspotify/conf
ansible.builtin.lineinfile:
path: /etc/raspotify/conf
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
loop:
- { regexp: '(^|^#)LIBRESPOT_NAME=', line: 'LIBRESPOT_NAME="rasp3-2"' }
- { regexp: '(^|^#)LIBRESPOT_BITRATE=', line: 'LIBRESPOT_BITRATE="160"' }
- { regexp: '(^|^#)LIBRESPOT_DEVICE=', line: 'LIBRESPOT_DEVICE="hw:CARD=Device,DEV=0"' }
- { regexp: '(^|^#)LIBRESPOT_PASSWORD=', line: 'LIBRESPOT_PASSWORD="l4c1j4yd33Du5lo"' }
- { regexp: '(^|^#)LIBRESPOT_USERNAME=', line: 'LIBRESPOT_USERNAME="jaydee67@sectorq.eu"' }
when: ansible_eth0.macaddress == "b8:27:eb:29:cb:d4"
- name: Reconfigure /etc/raspotify/conf
ansible.builtin.lineinfile:
path: /etc/raspotify/conf
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
loop:
- { regexp: '(^|^#)LIBRESPOT_NAME=', line: 'LIBRESPOT_NAME="rasp3-1"' }
- { regexp: '(^|^#)LIBRESPOT_BITRATE=', line: 'LIBRESPOT_BITRATE="160"' }
- { regexp: '(^|^#)LIBRESPOT_DEVICE=', line: 'LIBRESPOT_DEVICE="hw:CARD=Device,DEV=0"' }
- { regexp: '(^|^#)LIBRESPOT_PASSWORD=', line: 'LIBRESPOT_PASSWORD="l4c1j4yd33Du5lo"' }
- { regexp: '(^|^#)LIBRESPOT_USERNAME=', line: 'LIBRESPOT_USERNAME="jaydee67@sectorq.eu"' }
when: ansible_eth0.macaddress == "b8:27:eb:53:79:11"
# - name: Creating a symlink for libs
# ansible.builtin.file:
# src: "/usr/lib/aarch64-linux-gnu/libffi.so.7"
# dest: "/usr/lib/aarch64-linux-gnu/libffi.so.6"
# state: link
# - name: Install a rhasspy_amd64.deb
# ansible.builtin.apt:
# deb: /tmp/rhasspy_amd64.deb
# - name: Upload config
# ansible.builtin.copy:
# src: /etc/ansible/playbooks/files/services/rhasspy.service
# dest: /etc/systemd/system/rhasspy.service
# owner: root
# group: root
# mode: u=rwx,g=rx,o=rx
# - name: Just force systemd to reread configs (2.4 and above)
# ansible.builtin.systemd:
# daemon_reload: true
# - name: Restart service rhasspy, in all cases
# ansible.builtin.service:
# name: rhasspy
# state: restarted
# - name: Ensure rhasspy is in a running state
# ansible.builtin.service:
# name: rhasspy
# state: started
# register: myservice_details
# until: myservice_details.status.ActiveState == "active"
# retries: 15
# delay: 20
- name: Make sure destination dir exists
ansible.builtin.file:
path: "/home/jd/.config/rhasspy/profiles/en/"
state: directory
owner: jd
group: jd
mode: '0755'
- name: Upload config
ansible.builtin.copy:
src: /etc/ansible/playbooks/files/conf/rhasspy/profile.json
dest: /home/jd/.config/rhasspy/profiles/en/profile.json
owner: jd
group: jd
mode: u=rw,g=r,o=r
- name: Restart service raspotify, in all cases
ansible.builtin.service:
name: raspotify
state: restarted
- name: Install docker
ansible.builtin.shell:
curl -sSL https://get.docker.com | sh
ignore_errors: true
changed_when: false
- name: Add user to docker group
ansible.builtin.user:
name: jd
append: true
groups: docker
- name: Install pip modules
ansible.builtin.pip:
name: docker
- name: Pull image
community.docker.docker_image:
name: rhasspy/rhasspy
source: pull
- name: Create container
community.docker.docker_container:
name: rhasspy
image: rhasspy/rhasspy
command: --user-profiles /profiles --profile en
devices:
- "/dev/snd:/dev/snd"
restart_policy: unless-stopped
volumes:
- "/etc/localtime:/etc/localtime:ro"
- "/home/jd/.config/rhasspy/profiles:/profiles"
ports:
- "12101:12101"

View File

@ -0,0 +1,29 @@
- hosts: rhasspy
name: Install rhasspy
become: true
become_user: root
tasks:
- name: Install curl,mosquitto ...
ansible.builtin.apt:
name:
- python3-pip
- name: Install pip modules
ansible.builtin.pip:
name: docker
- name: Pull image
community.docker.docker_image:
name: rhasspy/rhasspy
source: pull
- name: Create container
community.docker.docker_container:
name: rhasspy
image: rhasspy/rhasspy
command: --user-profiles /profiles --profile en
devices:
- "/dev/snd:/dev/snd"
restart_policy: unless-stopped
volumes:
- "/etc/localtime:/etc/localtime:ro"
- "/home/jd/.config/rhasspy/profiles:/profiles"
ports:
- "12101:12101"

View File

@ -0,0 +1,7 @@
- hosts: odroid_cluster
become: true
tasks:
- name: Remove docker
apt:
name: docker.io
state: absent

View File

@ -0,0 +1,10 @@
- hosts: odroid_cluster
name: Install apparmor
become: true
tasks:
- name: Install apparmor
ansible.builtin.apt:
name:
- apparmor
- apparmor-utils
state: present

11
playbooks/11_reboot.yml Normal file
View File

@ -0,0 +1,11 @@
- hosts: odroid_cluster
name: Install k3s
become: true
tasks:
- name: Reboot the server
tags: reboot
become: yes
become_user: root
shell: "sleep 5 && reboot"
async: 1
poll: 0

View File

@ -0,0 +1,30 @@
- hosts: odroid_master
name: Create rancher cluster
become: true
tasks:
- name: Create new cluster in rancher
ansible.builtin.shell: "curl -u 'token-wg66j:p26nwqs9ckqbth4h8gtfd2g7858g8smbtpgmxq9qr52w4795l5jvv9' -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{\"name\":\"odroid\"}' 'https://192.168.77.106:8543/v3/clusters' --insecure| jq .id"
changed_when: false
ignore_errors: true
register: cluster_id
- name: Just the Names
ansible.builtin.debug:
msg: "{{ cluster_id.stdout }}"
- name: Create new cluster in rancher
ansible.builtin.shell: "curl -u 'token-wg66j:p26nwqs9ckqbth4h8gtfd2g7858g8smbtpgmxq9qr52w4795l5jvv9' -X GET -H 'Accept: application/json' -H 'Content-Type: application/json' https://192.168.77.106:8543/v3/clusters/{{ cluster_id.stdout }}/clusterRegistrationTokens --insecure| jq .data[0].manifestUrl"
changed_when: false
ignore_errors: true
register: register_id
- name: Register Token
ansible.builtin.debug:
msg: "{{ register_id.stdout }}"
- name: "Register in Rancher"
ansible.builtin.shell: "curl --insecure -sfL {{ register_id.stdout }} |sed 's/rancher-agent:v2.6.7/rancher-agent:v2.6.7-linux-arm64/g'| sed 's%beta.kubernetes.io/os%kubernetes.io/os%g'| kubectl apply -f -"
changed_when: false
ignore_errors: true
#create cluster:
#curl -u "token-wg66j:p26nwqs9ckqbth4h8gtfd2g7858g8smbtpgmxq9qr52w4795l5jvv9" -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"name":"test-cluster"}' 'https://192.168.77.106:8543/v3/clusters' --insecure
#get registration token
# curl -u "token-wg66j:p26nwqs9ckqbth4h8gtfd2g7858g8smbtpgmxq9qr52w4795l5jvv9" -X GET -H 'Accept: application/json' -H 'Content-Type: application/json' https://192.168.77.106:8543/v3/clusters/c-xq5pv/clusterRegistrationTokens --insecure|jq

View File

@ -0,0 +1,14 @@
- hosts: odroid_master
become: true
tasks:
- name: Get token
shell: 'cat /var/lib/rancher/k3s/server/node-token'
register: K3S_TOKEN
- debug: var=K3S_TOKEN.stdout
- name: "Add K8S Token and Hash to dummy host"
add_host:
name: "K3S_TOKEN_HOLDER"
token: "{{ K3S_TOKEN.stdout }}"
- name: "print token"
debug:
msg: "[Master] K3S_TOKEN_HOLDER K8S token is {{ hostvars['K3S_TOKEN_HOLDER']['token'] }}"

View File

@ -0,0 +1,71 @@
- hosts: odroid_master
name: Install k3s
become: true
tasks:
- name: Install K3S
ansible.builtin.shell: 'curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE="644" INSTALL_K3S_VERSION="v1.24.1+k3s1" sh -s -'
changed_when: false
- name: Get token
ansible.builtin.command: 'cat /var/lib/rancher/k3s/server/node-token'
register: k3s_token
changed_when: false
- name: Print token
ansible.builtin.debug: var=k3s_token.stdout
- name: "Add K8S Token and Hash to dummy host"
ansible.builtin.add_host:
name: "K3S_TOKEN_HOLDER"
token: "{{ k3s_token.stdout }}"
- name: Print token
ansible.builtin.debug:
msg: "[Master] K3S_TOKEN_HOLDER K8S token is {{ hostvars['K3S_TOKEN_HOLDER']['token'] }}"
- name: Grant cluster role
ansible.builtin.command: kubectl create clusterrolebinding cluster-admin-binding --clusterrole cluster-admin --user root
changed_when: false
ignore_errors: yes
- name: Reboot the server
tags: reboot
become: yes
become_user: root
shell: "sleep 5 && reboot"
async: 1
poll: 0
- name: (reboot) Wait for server to restart
wait_for_connection:
delay: 75
- name: Wait for service 'myservice' to be running
service_facts:
register: result
until: result.ansible_facts.services['k3s.service'].state == 'running'
retries: 10
delay: 5
#create cluster:
#curl -u "token-wg66j:p26nwqs9ckqbth4h8gtfd2g7858g8smbtpgmxq9qr52w4795l5jvv9" -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"name":"test-cluster"}' 'https://192.168.77.106:8543/v3/clusters' --insecure
#get registration token
# curl -u "token-wg66j:p26nwqs9ckqbth4h8gtfd2g7858g8smbtpgmxq9qr52w4795l5jvv9" -X GET -H 'Accept: application/json' -H 'Content-Type: application/json' https://192.168.77.106:8543/v3/clusters/c-xq5pv/clusterRegistrationTokens --insecure|jq
- name: Create new cluster in rancher
ansible.builtin.shell: "curl -u 'token-wg66j:p26nwqs9ckqbth4h8gtfd2g7858g8smbtpgmxq9qr52w4795l5jvv9' -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{\"name\":\"odroid\"}' 'https://192.168.77.106:8543/v3/clusters' --insecure| jq .id"
changed_when: false
ignore_errors: true
register: cluster_id
- name: Just the Names
ansible.builtin.debug:
msg: "{{ cluster_id.stdout }}"
- name: Create new cluster in rancher
ansible.builtin.shell: "curl -u 'token-wg66j:p26nwqs9ckqbth4h8gtfd2g7858g8smbtpgmxq9qr52w4795l5jvv9' -X GET -H 'Accept: application/json' -H 'Content-Type: application/json' https://192.168.77.106:8543/v3/clusters/{{ cluster_id.stdout }}/clusterRegistrationTokens --insecure| jq .data[0].manifestUrl"
changed_when: false
ignore_errors: true
register: register_id
- name: Register Token
ansible.builtin.debug:
msg: "{{ register_id.stdout }}"
- name: "Register in Rancher"
ansible.builtin.shell: "curl --insecure -sfL {{ register_id.stdout }} |sed 's/rancher-agent:v2.6.7/rancher-agent:v2.6.7-linux-arm64/g'| sed 's%beta.kubernetes.io/os%kubernetes.io/os%g'| kubectl apply -f -"
changed_when: false
ignore_errors: true
# - name: "Register in Rancher"
# ansible.builtin.shell: curl --insecure -sfL https://192.168.77.106:8543/v3/import/f5679ncdtx68489nqj2rntk8bwv6lcsq4j5qdtnxswkbfbtttn5s5q_c-lq4j4.yaml |sed 's/rancher-agent:v2.6.7/rancher-agent:v2.6.7-linux-arm64/g'| sed 's%beta.kubernetes.io/os%kubernetes.io/os%g'| kubectl apply -f -
# changed_when: false
# ignore_errors: true

View File

@ -0,0 +1,6 @@
- hosts: odroid_master
become: true
tasks:
- name: Uninstall K3S
shell: '/usr/local/bin/k3s-uninstall.sh'

View File

@ -0,0 +1,5 @@
- hosts: odroid_worker
become: true
tasks:
- name: Uninstall K3S Agent
shell: /usr/local/bin/k3s-agent-uninstall.sh

View File

@ -0,0 +1,23 @@
- hosts: odroid_worker
name: Setup k3s
become: true
tasks:
- name: Print token
ansible.builtin.debug:
msg: "[Master] K3S_TOKEN_HOLDER K8S token is {{ hostvars['K3S_TOKEN_HOLDER']['token'] }}"
- name: Print msg
ansible.builtin.debug:
msg: "{{ hostvars['K3S_TOKEN_HOLDER']['token'] }}"
- name: Get hostname
ansible.builtin.command: uname -n
register: result
changed_when: false
- name: Print hostname
ansible.builtin.debug:
msg: "{{ result.stdout }}"
- name: Install K3S Worker
ansible.builtin.shell: >-
curl -sfL https://get.k3s.io
| K3S_TOKEN={{ hostvars['K3S_TOKEN_HOLDER']['token'] }}
K3S_URL="https://192.168.77.161:6443" K3S_NODE_NAME="{{ result.stdout }}" INSTALL_K3S_VERSION="v1.24.1+k3s1" sh -
changed_when: false

View File

@ -0,0 +1,20 @@
- hosts: odroid_worker
name: Another task
become: true
tasks:
- name: Print token
ansible.builtin.debug:
msg: "[Master] K3S_TOKEN_HOLDER K3S token is {{ hostvars['K3S_TOKEN_HOLDER']['token'] }}"
- name: Print token
ansible.builtin.debug:
msg: "{{ hostvars['K3S_TOKEN_HOLDER']['token'] }}"
- name: Reconfigure K3S Worker
ansible.builtin.lineinfile:
path: /etc/systemd/system/k3s-agent.service.env
regexp: '^K3S_TOKEN='
line: K3S_TOKEN=\'{{ hostvars['K3S_TOKEN_HOLDER']['token'] }}\'
changed_when: false
- name: Restart K3S Worker
ansible.builtin.service:
name: k3s-agent
state: restarted

View File

@ -0,0 +1,10 @@
- hosts: odroid_cluster
name: Run script
become: true
gather_facts: true
tasks:
- name: Reconfigure logo
ansible.builtin.lineinfile:
path: /etc/update-motd.d/10-armbian-header
regexp: "(^#|^)TERM="
line: "TERM=linux toilet -f standard -F metal $(hostname)"

View File

@ -0,0 +1,3 @@
---
- import_playbook: 70_get_k3s_token.yml
- import_playbook: 72_register_k3s_worker.yml

10
playbooks/97_test.yml Normal file
View File

@ -0,0 +1,10 @@
---
- hosts: "{{ working_host | default('nas') }}"
become: false
gather_facts: False
tasks:
- debug:
msg: play1
- name: Test
command: free

View File

@ -0,0 +1,5 @@
---
- import_playbook: 71_uninstall_k3s_agent.yml
name: Uninstall k3s agent
- import_playbook: 71_uninstall_k3s.yml
name: Uninstall k3a

View File

@ -0,0 +1,16 @@
---
- hosts: datacenter
become: true
tasks:
- debug:
msg: play1
- name: Upgrade system
import_playbook: 00_apt_upgrade.yml
- name: Install docker
import_playbook: 05_install_docker.yml
- name: Install apparmor
import_playbook: 10_install_apparmor.yml

View File

@ -0,0 +1,23 @@
---
- name: Change creds
import_playbook: 00_tst.yml
- name: Initial
import_playbook: 00_initial_adjustments.yml
- name: Apt update
import_playbook: 00_apt_upgrade.yml
- name: Activate display
import_playbook: 00_test.yml
- name: Install LDAP
import_playbook: 00_install_ldap_client.yml
- name: Install Docker
import_playbook: 05_install_docker.yml
- name: Install apparmor
import_playbook: 10_install_apparmor.yml
- name: Change logo
import_playbook: 80_change_logo.yml
- name: Install k3s
import_playbook: 70_install_k3s.yml
- name: Install worker
import_playbook: 72_install_k3s_worker.yml
- name: Reboot All
import_playbook: 11_reboot.yml

View File

@ -0,0 +1,9 @@
---
- name: Change creds
import_playbook: 00_tst.yml
- name: Apt update
import_playbook: 00_apt_upgrade.yml
- name: Install Docker
import_playbook: 05_install_docker.yml
- name: Deploy Rhasspy
import_playbook: 05_pullimage.yml

View File

@ -0,0 +1,49 @@
{
"dialogue": {
"system": "rhasspy"
},
"handle": {
"system": "hass"
},
"home_assistant": {
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIwZjAyMjE5ZWVlZTI0MzYyODYzNTM0YTY4NTg4NDBhMiIsImlhdCI6MTY2MzA2MzAwNywiZXhwIjoxOTc4NDIzMDA3fQ.N8Y4EzCppgKbc4tCj6S8UXu1hIUJ8W0QGOXvJTuVwwc",
"handle_type": "event",
"url": "https://ha.sectorq.eu"
},
"intent": {
"system": "fsticuffs"
},
"microphone": {
"arecord": {
"device": "default:CARD=Device"
},
"system": "arecord"
},
"mqtt": {
"enabled": "true",
"host": "192.168.77.106",
"password": "jaydee1",
"username": "jaydee"
},
"sounds": {
"aplay": {
"device": "default:CARD=Device"
},
"system": "aplay"
},
"speech_to_text": {
"system": "pocketsphinx"
},
"text_to_speech": {
"nanotts": {
"language": "en-GB"
},
"system": "nanotts"
},
"wake": {
"porcupine": {
"keyword_path": "alexa_raspberry-pi.ppn"
},
"system": "porcupine"
}
}

View File

@ -0,0 +1,31 @@
MODE="worker"
mac=`ifconfig eth0 |grep ether|awk '{ print $2 }'`
echo $mac
syst=9
case $mac in
"00:1E:06:48:CE:E7")
syst=1
MODE="master"
;;
"00:1e:06:48:cd:86")
syst=2
;;
"00:1e:06:48:d0:01")
syst=3
;;
"00:1e:06:48:d0:00")
syst=4
;;
"00:1e:06:48:cd:8e")
syst=5
;;
esac
echo "lala" > /tmp/check.log
hostnamectl hostname odroidc4-${syst}
sed -i 's/^TERM=/#TERM=/g' /etc/update-motd.d/10-armbian-header
sed -i '32 i TERM=linux toilet -f standard -F metal $(hostname)' /etc/update-motd.d/10-armbian-header
TERM=linux toilet -f standard -F metal $(hostname)
nmcli con mod "Wired connection 1" ipv4.addresses "192.168.77.16${syst}/24" ipv4.gateway "192.168.77.1" ipv4.dns "192.168.77.1" ipv4.method "manual"
iptables -F
update-alternatives --set iptables /usr/sbin/iptables-legacy
update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy

View File

@ -0,0 +1,54 @@
# Import LCD library
from RPLCD import i2c
import psutil
import datetime
import os
from uptime import uptime
# Import sleep library
from time import sleep
# constants to initialise the LCD
lcdmode = 'i2c'
cols = 20
rows = 4
charmap = 'A00'
i2c_expander = 'PCF8574'
# Generally 27 is the address;Find yours using: i2cdetect -y 1
address = 0x27
port = 0 # 0 on an older Raspberry Pi
# Initialise the LCD
lcd = i2c.CharLCD(i2c_expander, address, port=port, charmap=charmap,
cols=cols, rows=rows)
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"]
eth0_ip = (net_sum[0][1])
cpu_load = round(psutil.getloadavg()[0],2)
uptime_s = int(uptime())
uptime_f = str(datetime.timedelta(seconds=uptime_s))
line1 = f'{"Mem: " + str(mem_data.percent): <20}'
line2 = f'{"IP : " + str(eth0_ip): <20}'
line4 = f'{"CPU: " + str(cpu_load): <20}'
print(cpu_load)
lcd.backlight_enabled = True
lcd.cursor_pos = (0, 0)
lcd.write_string(line1)
lcd.crlf()
lcd.write_string(line2)
lcd.crlf()
lcd.write_string('Up : ' + str(uptime_f))
lcd.crlf()
lcd.write_string(line4)
sleep(5)
#lcd.clear()
# Switch off backlight
#lcd.backlight_enabled = False
#sleep(3)
# Clear the LCD screen
#lcd.close(clear=True)

View File

@ -0,0 +1,43 @@
# Import LCD library
from RPLCD import i2c
import subprocess
import sys
import os
pid = os.getpid()
cmnd = "ps -ef|grep lcd_control|grep -v grep |grep -v {}|wc -l".format(pid)
status, output = subprocess.getstatusoutput(cmnd)
print(output)
if int(output) > 0:
print("Running already!")
#sys.exit()
# constants to initialise the LCD
lcdmode = 'i2c'
cols = 20
rows = 4
charmap = 'A00'
i2c_expander = 'PCF8574'
# Generally 27 is the address;Find yours using: i2cdetect -y 1
address = 0x27
port = 0 # 0 on an older Raspberry Pi
# Initialise the LCD
lcd = i2c.CharLCD(i2c_expander, address, port=port, charmap=charmap,
cols=cols, rows=rows)
line1 = f'{"####": <20}'
line2 = f'{"Restarting.....": <20}'
line3 = f'{"####": <20}'
line4 = f'{"####": <20}'
lcd.backlight_enabled = True
lcd.cursor_pos = (0, 0)
lcd.write_string(line1)
lcd.crlf()
lcd.write_string(line2)
lcd.crlf()
lcd.write_string(line3)
lcd.crlf()
lcd.write_string(line4)

View File

@ -0,0 +1,35 @@
# Import LCD library
from RPLCD import i2c
# constants to initialise the LCD
lcdmode = 'i2c'
cols = 20
rows = 4
charmap = 'A00'
i2c_expander = 'PCF8574'
# Generally 27 is the address;Find yours using: i2cdetect -y 1
address = 0x27
port = 0 # 0 on an older Raspberry Pi
# Initialise the LCD
lcd = i2c.CharLCD(i2c_expander, address, port=port, charmap=charmap,
cols=cols, rows=rows)
lcd.clear()
line1 = f'{"####": <20}'
line2 = f'{"Starting....": <20}'
line3 = f'{"####": <20}'
line4 = f'{"####": <20}'
lcd.backlight_enabled = True
lcd.cursor_pos = (0, 0)
lcd.write_string(line1)
lcd.crlf()
lcd.write_string(line2)
lcd.crlf()
lcd.write_string(line3)
lcd.crlf()
lcd.write_string(line4)
lcd.crlf()
lcd.clear()
lcd.close(clear=True)

View File

@ -0,0 +1,13 @@
[Unit]
Description=Led Control service
Wants=network-online.target
After=network.target network-online.target
[Service]
Type=simple
User=root
#ExecStartPre=/bin/sleep 30
ExecStart=/usr/bin/python3 /usr/bin/lcd_control.py
[Install]
WantedBy=multi-user.target suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target

View File

@ -0,0 +1,14 @@
[Unit]
Description=Run my custom task at shutdown only
DefaultDependencies=no
Before=poweroff.target halt.target shutdown.target reboot.target
Requires=poweroff.target
[Service]
Type=oneshot
ExecStartPre=systemctl stop lcd_control.service
ExecStart=/usr/bin/python3 /usr/bin/lcd_control_restart.py
RemainAfterExit=yes
[Install]
WantedBy=shutdown.target

View File

@ -0,0 +1,11 @@
[Unit]
Description=Run my custom task at shutdown only
After=syslog.target
[Service]
Type=oneshot
ExecStart=/usr/bin/python3 /usr/bin/lcd_control_start.py
RemainAfterExit=yes
[Install]
WantedBy=basic.target

View File

@ -0,0 +1,16 @@
[Unit]
Description=Rhasspy Autostart
After=network-online.target
[Service]
Type=simple
User=jd
WorkingDirectory=/home/jd
ExecStart=/bin/bash -lc '/usr/bin/rhasspy --profile en 2>&1 | cat'
StandardOutput=inherit
StandardError=inherit
Restart=always
RestartSec=20
[Install]
WantedBy=multi-user.target