small bugfixes and deployment setup
This commit is contained in:
36
deploy/deploy.playbook.yml
Normal file
36
deploy/deploy.playbook.yml
Normal file
@@ -0,0 +1,36 @@
|
||||
- name: Basic setup tasks for Raspberry Pi
|
||||
hosts: raspberrypi
|
||||
become: true
|
||||
vars:
|
||||
code_dest: /home/pi/eink
|
||||
service_target_dir: /etc/systemd/system/
|
||||
|
||||
tasks:
|
||||
- name: Pull the latest version of the code
|
||||
git:
|
||||
repo: https://git.kluster.moll.re/remoll/eink.git
|
||||
dest: "{{ code_dest }}"
|
||||
version: main
|
||||
|
||||
- name: Install from the pipenv-file
|
||||
command: "pipenv install --system --deploy"
|
||||
args:
|
||||
chdir: "{{ code_dest }}"
|
||||
|
||||
- name: Copy unit files
|
||||
template:
|
||||
src: ./templates/{{ item }}.j2
|
||||
dest: "{{ service_target_dir }}/{{ item }}"
|
||||
loop:
|
||||
- eink-show.service
|
||||
- eink-show.timer
|
||||
|
||||
- name: Enable units
|
||||
systemd:
|
||||
daemon_reload: yes
|
||||
name: "{{ item }}"
|
||||
state: started
|
||||
enabled: yes
|
||||
loop:
|
||||
- eink-show.service
|
||||
- eink-show.timer
|
57
deploy/setup.playbook.yml
Normal file
57
deploy/setup.playbook.yml
Normal file
@@ -0,0 +1,57 @@
|
||||
- name: Basic setup tasks for Raspberry Pi
|
||||
hosts: raspberrypi
|
||||
become: true
|
||||
|
||||
tasks:
|
||||
- name: Add local ssh key
|
||||
ansible.posix.authorized_key:
|
||||
user: "{{ ansible_user }}"
|
||||
state: present
|
||||
# copy file present on the controller to the remote host
|
||||
# https://docs.ansible.com/ansible/latest/collections/ansible/builtin/copy_module.html
|
||||
key: "{{ lookup('file', '~/.ssh/default.pub') }}"
|
||||
|
||||
- name: apt update all packages
|
||||
apt:
|
||||
update_cache: yes
|
||||
upgrade: yes
|
||||
|
||||
- name: Install required packages
|
||||
apt:
|
||||
name:
|
||||
- git
|
||||
- python3-pipenv
|
||||
- python3-dev
|
||||
- python3-setuptools
|
||||
- python3-rpi.gpio
|
||||
- python3-spidev
|
||||
state: present
|
||||
|
||||
- name: Enable SPI and I2C interfaces
|
||||
lineinfile:
|
||||
path: /boot/config.txt
|
||||
regexp: "^#?(dtparam=i2c_arm|dtparam=spi)"
|
||||
line: "{{ item }}"
|
||||
state: present
|
||||
with_items:
|
||||
- "dtparam=i2c_arm=on"
|
||||
- "dtparam=spi=on"
|
||||
|
||||
- name: Reboot the Raspberry Pi
|
||||
reboot:
|
||||
delay: 5
|
||||
connect_timeout: 20
|
||||
reboot_timeout: 300
|
||||
|
||||
- name: Wait for the Raspberry Pi to reboot
|
||||
wait_for_connection:
|
||||
delay: 5
|
||||
timeout: 300
|
||||
|
||||
- name: Add wifi networks from secrets
|
||||
template:
|
||||
src: templates/wpa_supplicant.conf.j2
|
||||
dest: /etc/wpa_supplicant/wpa_supplicant.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0600
|
14
deploy/templates/eink-show.service.j2
Normal file
14
deploy/templates/eink-show.service.j2
Normal file
@@ -0,0 +1,14 @@
|
||||
[Unit]
|
||||
Description=Show new photo onto the eink display
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
|
||||
WorkingDirectory={{ code_dest }}
|
||||
#EnvironmentFile={{ service_config_dir }}/restic.env
|
||||
|
||||
ExecStart=python main.py
|
||||
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
9
deploy/templates/eink-show.timer.j2
Normal file
9
deploy/templates/eink-show.timer.j2
Normal file
@@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
Description=Run photo update regularly
|
||||
|
||||
[Timer]
|
||||
OnCalendar=Tue 11:00
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
0
deploy/templates/wpa_supplicant.conf.j2
Normal file
0
deploy/templates/wpa_supplicant.conf.j2
Normal file
Reference in New Issue
Block a user