Browse Source

Kopieren der Scripts in inipi.yml

pi witd in blini.yml zur gpio Group geadded.
master 0.3
Olli Graf 4 years ago
parent
commit
f1f5bd1b4a
  1. 22
      bin/blini.py
  2. 10
      bin/showtemp
  3. 21
      bin/updatesys
  4. 12
      hosts
  5. 15
      roles/blini/tasks/main.yml
  6. 22
      roles/initpi/tasks/main.yml

22
blini.py → bin/blini.py

@ -7,13 +7,27 @@ import blinkt
blinkt.set_clear_on_exit() blinkt.set_clear_on_exit()
waitstate = 0.75 waitstate = 0.75
for i in range(3): from_led = 0
blinkt.set_pixel(2,255,150,0) to_led=6
def pixel_on():
for i in range(from_led,to_led):
blinkt.set_pixel(i,255,0,0)
blinkt.show() blinkt.show()
time.sleep(waitstate)
blinkt.set_pixel(2,0,0,0) def pixel_off():
for i in range(from_led,to_led):
blinkt.set_pixel(i,0,0,0)
blinkt.show() blinkt.show()
def blink_once():
pixel_on()
time.sleep(waitstate)
pixel_off()
time.sleep(waitstate) time.sleep(waitstate)
for i in range(3):
blink_once()
#while True: #while True:
# pixels = random.sample(range(blinkt.NUM_PIXELS), random.randint(1, 5)) # pixels = random.sample(range(blinkt.NUM_PIXELS), random.randint(1, 5))
# for i in range(blinkt.NUM_PIXELS): # for i in range(blinkt.NUM_PIXELS):

10
bin/showtemp

@ -0,0 +1,10 @@
cpu=$(</sys/class/thermal/thermal_zone0/temp)
vccmd=$(which vcgencmd)
gpu=$(${vccmd} measure_temp)
gpu=$(echo "${gpu}"| sed 's|temp\=||g')
echo "$(date) @ $(hostname)"
echo "-------------------------------------------"
echo "GPU => ${gpu}"
echo "CPU => $((cpu/1000))'C"

21
bin/updatesys

@ -0,0 +1,21 @@
# System-Updater CC-BY Olli Graf
# V 1.6 2019
VERSION="1.7"
TMPFILE="/tmp/updater.txt"
echo "Updater V ${VERSION}"
sudo rm -f ${TMPFILE}
sudo apt-get update
sudo apt-get dist-upgrade -y --allow-unauthenticated |tee ${TMPFILE}
sudo snap refresh
sudo apt-get autoremove -y
if grep -q linux-header ${TMPFILE}; then
echo "reboot nötig"
read -n1 -p "Neustart? (J/N)" auswahl
if [ "${auswahl}" == "j" ]; then
echo "System wird gestartet."
sudo reboot
fi
fi

12
hosts

@ -2,13 +2,16 @@ pis:
hosts: hosts:
brandine: brandine:
clancy: clancy:
# martin: martin:
quimby: quimby:
kirk: kirk:
willie: willie:
hans: hans:
pye:
julius:
carl:
cleatus: cleatus:
barney: # barney:
vars: vars:
ansible_python_interpreter: /usr/bin/python3 ansible_python_interpreter: /usr/bin/python3
ansible_connection: ssh ansible_connection: ssh
@ -19,7 +22,10 @@ pis:
ansible_ssh_private_key_file: ~/.ssh/id_rsa ansible_ssh_private_key_file: ~/.ssh/id_rsa
blini: blini:
hosts: hosts:
quimby quimby:
willie:
kirk:
brandine:
vars: vars:
ansible_python_interpreter: /usr/bin/python3 ansible_python_interpreter: /usr/bin/python3
ansible_connection: ssh ansible_connection: ssh

15
roles/blini/tasks/main.yml

@ -1,4 +1,17 @@
- name: Blini Test - name: copy blini.py
ansible.builtin.copy:
src: bin/blini.py
dest: bin/blini.py
owner: pi
group: pi
mode: '0744'
- name: adding pi to gpio group
become: true
user:
name: pi
groups: gpio
- name: Blini Run
become_user: pi become_user: pi
command: ~/bin/blini.py command: ~/bin/blini.py

22
roles/initpi/tasks/main.yml

@ -1,3 +1,21 @@
- name: create bin dir
file:
path: ~/bin
state: directory
- name: copy scripts
copy:
src: bin/{{ item }}
dest: /home/pi/bin
owner: pi
group: pi
mode: '0744'
with_items:
- blini.py
- updatesys
- showtemp
- name: PI Update - name: PI Update
become: true become: true
apt: apt:
@ -12,9 +30,11 @@
- cowsay - cowsay
- docker.io - docker.io
- git - git
- locate
- nfs-kernel-server
update_cache: yes update_cache: yes
cache_valid_time: 86400 cache_valid_time: 86400
autoremove: yes # autoremove: yes
- name: Permission für Docker - name: Permission für Docker
become: true become: true
file: path=/var/run/docker.sock mode=0660 file: path=/var/run/docker.sock mode=0660

Loading…
Cancel
Save