-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Testservice now deployed via Ansible (#3265)
* chore: Deployment of testservice via Ansible * Adjust README * Fix handler and add Dockerfile for building * Fix building and deploying native libs * Remove native library usage (not needed for core-crypto) * Use node018 in example too
- Loading branch information
1 parent
76d2206
commit 4055696
Showing
13 changed files
with
214 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM --platform=linux/amd64 eclipse-temurin:17-jdk | ||
|
||
# disable prompts from the txdata | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
build-essential \ | ||
cargo \ | ||
gcc \ | ||
software-properties-common \ | ||
unzip \ | ||
clang \ | ||
curl \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /app | ||
|
||
COPY . . | ||
|
||
RUN ./gradlew clean | ||
RUN ./gradlew :testservice:shadowJar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Ansible playbook for kalium testservice | ||
|
||
Execute with: `ansible-playbook -i hosts.ini site.yml --diff` | ||
|
||
Run only on individual nodes: `ansible-playbook -i hosts.ini -l node018 site.yml --diff` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[node018] | ||
192.168.2.18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
APT::Periodic::Update-Package-Lists "1"; | ||
APT::Periodic::Unattended-Upgrade "1"; | ||
APT::Periodic::AutocleanInterval "7"; | ||
Unattended-Upgrade::OnlyOnACPower "false"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- name: "Restart sshd" | ||
service: | ||
name: ssh | ||
state: restarted | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
- name: Update package repository | ||
when: | ||
- ansible_facts['distribution'] == "Debian" | ||
apt: | ||
update_cache: true | ||
|
||
- name: Install java and other useful packages | ||
when: | ||
- ansible_facts['distribution'] == "Debian" | ||
package: | ||
name: | ||
- openjdk-17-jre-headless | ||
- vim | ||
- curl | ||
- jq | ||
- git | ||
- intel-microcode | ||
- unattended-upgrades | ||
state: present | ||
|
||
- name: Disallow SSH root login | ||
lineinfile: | ||
dest: /etc/ssh/sshd_config | ||
regexp: "^PermitRootLogin" | ||
line: "PermitRootLogin no" | ||
state: present | ||
validate: sshd -t -f %s | ||
notify: | ||
- Restart sshd | ||
|
||
- name: Configure unattended upgrades | ||
copy: | ||
src: 20auto-upgrades | ||
dest: /etc/apt/apt.conf.d/20auto-upgrades | ||
mode: 0644 | ||
owner: root | ||
group: root |
18 changes: 18 additions & 0 deletions
18
testservice/ansible/roles/kalium-testservice/files/kalium-testservice.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[Unit] | ||
Description=kalium-testservice | ||
After=network.target | ||
|
||
[Service] | ||
User=kalium | ||
Group=kalium | ||
LimitNOFILE=infinity | ||
LimitNPROC=infinity | ||
LimitCORE=infinity | ||
TimeoutStartSec=8 | ||
WorkingDirectory=/usr/local/kalium-testservice | ||
Environment="PATH=/usr/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin" | ||
ExecStart=java -Djava.library.path=/usr/local/kalium-testservice/native/libs/ -jar /usr/local/kalium-testservice/testservice.jar server /usr/local/kalium-testservice/config.yml | ||
Restart=always | ||
|
||
[Install] | ||
WantedBy=default.target |
88 changes: 88 additions & 0 deletions
88
testservice/ansible/roles/kalium-testservice/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
- name: Install java and other useful packages | ||
when: | ||
- ansible_facts['distribution'] == "Debian" | ||
package: | ||
name: | ||
- haveged | ||
- openjdk-17-jre-headless | ||
- libc6 | ||
state: present | ||
|
||
- name: Enable service for random number generation | ||
systemd: | ||
name: haveged | ||
daemon_reload: true | ||
enabled: true | ||
state: restarted | ||
|
||
- name: Create user account | ||
user: | ||
name: kalium | ||
shell: /bin/bash | ||
state: present | ||
groups: audio, video | ||
|
||
- name: Ensure logs directory exists | ||
file: | ||
path: /var/log/kalium-testservice/ | ||
state: directory | ||
owner: kalium | ||
group: kalium | ||
mode: '0755' | ||
|
||
- name: Create directory for runtime files | ||
file: | ||
path: /usr/local/kalium-testservice/ | ||
state: directory | ||
owner: kalium | ||
group: kalium | ||
mode: '0755' | ||
|
||
- name: Deploy config | ||
copy: | ||
src: ../config.yml | ||
dest: /usr/local/kalium-testservice/config.yml | ||
owner: kalium | ||
group: kalium | ||
mode: '0644' | ||
|
||
# Native libraries are not external anymore with core crypto | ||
#- name: Create directory for native libs | ||
# file: | ||
# path: /usr/local/kalium-testservice/native/libs/ | ||
# state: directory | ||
# owner: kalium | ||
# group: kalium | ||
# mode: '0755' | ||
# | ||
#- name: Deploy native libraries | ||
# copy: | ||
# src: ../../native/libs/ | ||
# dest: /usr/local/kalium-testservice/native/libs/ | ||
# owner: kalium | ||
# group: kalium | ||
# mode: '0644' | ||
|
||
- name: Deploy jar | ||
copy: | ||
src: ../testservice-0.0.1-SNAPSHOT-all.jar | ||
dest: /usr/local/kalium-testservice/testservice.jar | ||
owner: kalium | ||
group: kalium | ||
mode: '0644' | ||
|
||
- name: Deploy service | ||
copy: | ||
src: kalium-testservice.service | ||
dest: /etc/systemd/system/kalium-testservice.service | ||
owner: kalium | ||
group: kalium | ||
mode: '0644' | ||
|
||
- name: Enable and start service | ||
systemd: | ||
name: kalium-testservice | ||
daemon_reload: true | ||
enabled: true | ||
state: restarted | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
- hosts: all | ||
become: yes | ||
become_user: root | ||
gather_facts: yes | ||
roles: | ||
- role: common | ||
|
||
- hosts: node018 | ||
become: yes | ||
become_user: root | ||
gather_facts: yes | ||
roles: | ||
- role: kalium-testservice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters