-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaybook.yml
89 lines (73 loc) · 1.94 KB
/
playbook.yml
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
---
- name: Host monitor service playbook
hosts: linux
become: yes
remote_user: "{{linux_user}}"
tasks:
- name: Install python3
yum:
name:
- python3
state: latest
- name: Copy process.py to destination
copy:
src: process.py
dest: "/app/"
owner: "{{linux_user}}"
group: "{{linux_user}}"
mode: '0777'
- name: Copy "{{linux_service_name}}" to destination
copy:
src: "{{linux_service_name}}"
dest: "/lib/systemd/system/{{linux_service_name}}"
mode: preserve
- name: Daemon reload
systemd:
daemon_reload: yes
- name: Enable service to run on boot
systemd:
name: "{{linux_service_name}}"
enabled: yes
- name: Start service "{{linux_service_name}}"
systemd:
name: "{{linux_service_name}}"
state: started
- name: Host monitor service playbook for Windows
hosts: windows
tasks:
- name: Create folder for process
win_file:
path: C:\Process
state: directory
- name: Copy python script
win_copy:
dest: C:\Process\
src: process.py
- name: Install nssm & python3 via chocolatey
win_chocolatey:
name:
- nssm
- python3
- name: Stop the service if already present
win_service:
name: "{{win_service_name}}"
state: stopped
ignore_errors: yes
- name: Delete the service if already present
win_service:
name: "{{win_service_name}}"
state: absent
ignore_errors: yes
- name: Install "{{win_service_name}}" service
win_nssm:
name: "{{win_service_name}}"
application: C:\Python38\pythonw.exe
arguments: C:\Process\process.py"
- name: Start "{{win_service_name}}" service
win_service:
name: "{{win_service_name}}"
state: started
register: win_service_result
until: win_service_result.state == "running"
retries: 2
delay: 10