-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeploy-to-ftp-server.yaml
104 lines (104 loc) · 2.62 KB
/
deploy-to-ftp-server.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
---
- hosts: ftp-server
become: yes
tasks:
- name: Install packages
package: name={{ item }} state=latest
with_items:
- tmux
- zsh
- vsftpd
- python-pip
- name: Install pip packages
pip: name={{ item }}
with_items:
- watchdog
- python-telegram-bot
- name: Create user cctv
user:
name: cctv
shell: /usr/bin/zsh
generate_ssh_key: yes
- name: Create /home/cctv/cctv
file:
path: /home/cctv/{{ item }}
state: directory
owner: cctv
with_items:
- cctv
- .locks
- name: Copy vsftpd settings
copy:
src: configs/vsftpd.conf
dest: /etc/vsftpd.conf
register: vsftpd_conf
- name: Enable vsftpd
service:
name: vsftpd
enabled: yes
state: started
- name: Restart vsftp if new config file
service:
name: vsftpd
enabled: yes
state: restarted
when: vsftpd_conf.changed
- name: Create /opt/tbot/bin
file:
path: /opt/tbot/bin
state: directory
- name: Copy main script
copy:
src: telegram-bot/watchdog-ftp.py
dest: /opt/tbot/bin/watchdog-ftp.py
mode: 0755
register: watchdog_ftp_script
- name: Copy main service file
copy:
src: telegram-bot/watchdog-ftp.service
dest: /etc/systemd/system/watchdog-ftp.service
mode: 0644
register: watchdog_ftp_service
- name: Enable watchdog-ftp
systemd:
name: watchdog-ftp
enabled: yes
state: started
daemon_reload: yes
- name: Restart watchdog-ftp
systemd:
name: watchdog-ftp
enabled: yes
state: restarted
daemon_reload: yes
when: watchdog_ftp_service.changed or watchdog_ftp_script.changed
- name: Set authorized key from file
authorized_key:
user: cctv
state: present
key: "{{ lookup('file', 'keys/cctv_key.pub') }}"
- name: Enable cronie
service:
name: cronie
enabled: yes
state: started
- cron:
name: Delete old photos
minute: 0
hour: 0
user: cctv
job: /usr/bin/find /home/cctv/cctv -mindepth 1 -mtime +14 -delete
# For OCam M3 only
# - name: Webcam scripts
# copy:
# src: scripts/{{ item }}
# dest: /usr/local/bin/{{ item }}
# mode: 0755
# with_items:
# - webcam_restart.py
# - cron:
# name: Reboot webcam
# minute: 0
# hour: 4
# user: cctv
# job: /usr/local/bin/webcam_restart.py