Kapisi/roles/Vergil/tasks/main.yml

176 lines
4.3 KiB
YAML
Raw Permalink Normal View History

2021-12-19 21:32:19 -06:00
---
2022-01-25 23:54:43 -06:00
2021-12-19 21:32:19 -06:00
- name: Geth-Hub packages
become: yes
package:
name:
- motion
- lirc
2023-11-30 02:47:16 -06:00
- snmpd
2022-01-25 23:54:43 -06:00
- libcamera-apps
- ir-keytable
2021-12-19 21:32:19 -06:00
state: present
2022-01-25 23:54:43 -06:00
update_cache: yes
2021-12-19 21:32:19 -06:00
- name: Copy the SSH key
authorized_key:
2022-01-25 23:54:43 -06:00
user: "{{ ansible_user_id }}"
2021-12-19 21:32:19 -06:00
state: present
key: "{{ lookup('file', lookup('env','HOME') + '/.ssh/geth.pub') }}"
2021-12-19 21:32:19 -06:00
- name: Copy the motion config
become: yes
register: motion_config
template:
src: "motion.conf.j2"
2021-12-19 21:32:19 -06:00
dest: "/etc/motion/motion.conf"
2022-01-25 23:54:43 -06:00
- name: Create motion log folder
become: yes
file:
path: "{{ item }}"
state: directory
owner: motion
group: motion
mode: 0750
loop:
2022-01-25 23:54:43 -06:00
- "/var/log/motion"
- "/var/run/motion"
2021-12-19 21:32:19 -06:00
- name: Restart the motion service
become: yes
when: motion_config.changed and motion_enabled
2021-12-19 21:32:19 -06:00
service:
name: motion
state: started
2021-12-19 21:32:19 -06:00
enabled: yes
2022-01-25 23:54:43 -06:00
- name: Allow override of motion service
become: yes
when: not motion_enabled
service:
name: motion
state: stopped
enabled: no
2021-12-19 21:32:19 -06:00
# Thanks to https://wiki.geekworm.com/Raspberry_Pi_IR_Control_Expansion_Board for instructions setting up lirc
- name: Set the dtoverlay
become: yes
2022-01-25 23:54:43 -06:00
register: dtoverlay
2024-07-23 14:18:32 -05:00
when: ansible_distribution_major_version == 11
2022-01-25 23:54:43 -06:00
blockinfile:
2021-12-19 21:32:19 -06:00
path: "/boot/config.txt"
2022-01-25 23:54:43 -06:00
insertafter: EOF
marker: "# {mark} Ubiqtorate Managed Block"
block: |
dtoverlay=gpio-ir,gpio_pin={{ gpio_in_pin | default('18') }}
dtoverlay=gpio-ir-tx,gpio_pin={{ gpio_out_pin | default('17') }}
start_x=1
- name: Unset camera autodetect
become: yes
register: camera_autodetect
2024-07-23 14:18:32 -05:00
when: ansible_distribution_major_version == 11
lineinfile:
path: "/boot/config.txt"
regexp: "camera_auto_detect"
line: "# camera_auto_detect=1"
2021-12-19 21:32:19 -06:00
2024-07-23 14:18:32 -05:00
# Thanks to https://wiki.geekworm.com/Raspberry_Pi_IR_Control_Expansion_Board for instructions setting up lirc
- name: Set the dtoverlay
become: yes
register: dtoverlay
when: ansible_distribution_major_version == 12
blockinfile:
path: "/boot/firmware/config.txt"
insertafter: EOF
marker: "# {mark} Ubiqtorate Managed Block"
block: |
dtoverlay=gpio-ir,gpio_pin={{ gpio_in_pin | default('18') }}
dtoverlay=gpio-ir-tx,gpio_pin={{ gpio_out_pin | default('17') }}
start_x=1
- name: Unset camera autodetect
become: yes
register: camera_autodetect
when: ansible_distribution_major_version == 12
lineinfile:
path: "/boot/firmware/config.txt"
regexp: "camera_auto_detect"
line: "# camera_auto_detect=1"
2021-12-19 21:32:19 -06:00
- name: Set the dtparam
become: yes
2022-01-25 23:54:43 -06:00
register: dtparam
2021-12-19 21:32:19 -06:00
lineinfile:
2024-07-23 14:18:32 -05:00
path: "/boot/firmware/config.txt"
2021-12-19 21:32:19 -06:00
path: "/boot/config.txt"
regexp: "^dtparam="
line: "dtparam=gpio_in_pull={{ gpio_in_pull | default('down') }}"
- name: Copy the modules config
become: yes
2022-01-25 23:54:43 -06:00
register: modules_config
2021-12-19 21:32:19 -06:00
template:
src: "modules.j2"
dest: "/etc/modules"
2022-01-25 23:54:43 -06:00
- name: Copy the modules config, part 2
become: yes
register: modules_config_2
template:
src: "lirc_rpi.conf.j2"
dest: "/etc/modprobe.d/lirc_rpi.conf"
- name: Reboot if needed
become: yes
when: modules_config.changed or dtparam.changed or dtoverlay.changed or modules_config_2.changed or camera_autodetect.changed
2022-01-25 23:54:43 -06:00
reboot:
- name: Wait if needed
become: yes
when: modules_config.changed or dtparam.changed or dtoverlay.changed or modules_config_2.changed
wait_for_connection:
2021-12-19 21:32:19 -06:00
- name: Copy lircd supplemental config
register: lircd_supp_config
become: yes
copy:
src: "{{ item }}"
dest: "/etc/lirc/{{ item }}"
2024-07-23 14:18:32 -05:00
force: no
# TODO: -- need a switch on the version of the RPi image
loop:
- hardware.conf
- lirc_options.conf
2021-12-19 21:32:19 -06:00
- name: Copy lircd remote config
register: lircd_remote_config
become: yes
copy:
2023-11-30 02:47:16 -06:00
src: "lircd.conf/{{ remote }}"
dest: /etc/lirc/lircd.conf
2021-12-19 21:32:19 -06:00
- name: Start the services
when: lircd_supp_config.changed or lircd_remote_config.changed
become: yes
service:
2022-01-25 23:54:43 -06:00
name: lircd
2021-12-19 21:32:19 -06:00
state: restarted
enabled: yes
2023-11-30 02:47:16 -06:00
- name: SNMPD config
become: yes
template:
src: snmpd.conf.j2
dest: /etc/snmp/snmpd.conf
- name: SNMPD service
become: yes
service:
name: snmpd
state: restarted
enabled: yes