Skip to content

Commit 4b1c6fc

Browse files
committed
Adding server to ansible.
1 parent bc1565c commit 4b1c6fc

File tree

9 files changed

+138
-48
lines changed

9 files changed

+138
-48
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,4 @@ ansible/roles/android_x86/files/*
161161
ansible/roles/android_arm/files/*
162162
ansible/roles/waydroid/files/*
163163
ansible/.env.ansible.yml
164+
deploy_key

Kindle Automator.code-workspace

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@
44
"path": "."
55
}
66
],
7-
"settings": {}
7+
"settings": {
8+
"ansible.python.interpreterPath": "/Users/sclay/projects/sindarin/kindle-automator/venv/bin/python"
9+
}
810
}

ansible/provision.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
- { role: mezmo, tags: mezmo }
1212
- { role: android_x86, tags: android-x86 }
1313
# - { role: android_arm, tags: android-arm }
14+
- { role: server, tags: server }
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
kindle_repo_url: "https://github.com/sindarin-inc/kindle-automator.git"
2+
kindle_repo_branch: "main"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINl9T4Vlwb5CjG/aVuvvud+7CLv7LE8jjfszf9xPajdL sclay@ClayMacStudio.localdomain
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
- name: restart kindle-automator
3+
systemd:
4+
name: kindle-automator
5+
state: restarted
6+
daemon_reload: yes
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
# Install required system packages
3+
- name: Install required packages
4+
apt:
5+
name:
6+
- git
7+
- python3
8+
- python3-pip
9+
- python3-venv
10+
- libffi-dev
11+
- libssl-dev
12+
- build-essential
13+
- nodejs
14+
- npm
15+
- unzip
16+
state: present
17+
update_cache: yes
18+
19+
# Create app directory
20+
- name: Create application directory
21+
file:
22+
path: /opt/kindle-automator
23+
state: directory
24+
mode: "0755"
25+
26+
# Create public deploy key for GitHub
27+
- name: Copy public deploy key for GitHub
28+
copy:
29+
src: files/deploy_key
30+
dest: /opt/kindle-automator/deploy_key
31+
mode: "0644"
32+
register: deploy_key
33+
34+
# Clone or update the repository
35+
- name: Clone or update the repository
36+
git:
37+
repo: "{{ kindle_repo_url }}"
38+
dest: /opt/kindle-automator
39+
version: "{{ kindle_repo_branch | default('main') }}"
40+
update: yes
41+
force: yes
42+
key_file: /opt/kindle-automator/deploy_key
43+
register: git_clone
44+
45+
# Set up Python virtual environment
46+
- name: Create Python virtual environment
47+
command: python3 -m venv /opt/kindle-automator/venv
48+
args:
49+
creates: /opt/kindle-automator/venv/bin/activate
50+
51+
# Install uv package manager
52+
- name: Install uv package manager
53+
pip:
54+
name: uv
55+
executable: /opt/kindle-automator/venv/bin/pip
56+
state: present
57+
58+
# Install dependencies
59+
- name: Install Python dependencies
60+
command: /opt/kindle-automator/venv/bin/uv pip install -r requirements.txt
61+
args:
62+
chdir: /opt/kindle-automator
63+
when: git_clone.changed
64+
65+
# Create logs directory
66+
- name: Create logs directory
67+
file:
68+
path: /opt/kindle-automator/logs
69+
state: directory
70+
mode: "0755"
71+
72+
# Create screenshots directory
73+
- name: Create screenshots directory
74+
file:
75+
path: /opt/kindle-automator/screenshots
76+
state: directory
77+
mode: "0755"
78+
79+
# Install Appium globally
80+
- name: Install Appium globally
81+
npm:
82+
name: appium
83+
global: yes
84+
state: present
85+
86+
# Install Appium UiAutomator2 driver
87+
- name: Install Appium UiAutomator2 driver
88+
command: npx appium driver install uiautomator2
89+
args:
90+
creates: /usr/local/lib/node_modules/appium/node_modules/appium-uiautomator2-driver
91+
92+
# Create systemd service file
93+
- name: Create systemd service file
94+
template:
95+
src: kindle-automator.service.j2
96+
dest: /etc/systemd/system/kindle-automator.service
97+
mode: "0644"
98+
notify: restart kindle-automator
99+
100+
# Enable and start the service
101+
- name: Enable and start kindle-automator service
102+
systemd:
103+
name: kindle-automator
104+
enabled: yes
105+
state: started
106+
daemon_reload: yes
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[Unit]
2+
Description=Kindle Automator Flask Server
3+
After=network.target
4+
5+
[Service]
6+
User=root
7+
WorkingDirectory=/opt/kindle-automator
8+
Environment="PATH=/opt/kindle-automator/venv/bin:/opt/android-sdk/platform-tools:/opt/android-sdk/emulator:/usr/local/bin:/usr/bin:/bin"
9+
Environment="ANDROID_HOME=/opt/android-sdk"
10+
Environment="ANDROID_SDK_ROOT=/opt/android-sdk"
11+
Environment="FLASK_ENV=production"
12+
Environment="PYTHONPATH=/opt/kindle-automator"
13+
ExecStart=/opt/kindle-automator/venv/bin/python -m server.server
14+
Restart=always
15+
RestartSec=10
16+
17+
[Install]
18+
WantedBy=multi-user.target

server/process_manager.py

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)