-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Integrate a sample REST API (using OpenAPI) into the local env…
…ironment (#2482) * chore: Integrate a sample REST API (using OpenAPI) into the local environment. * chore: Download example-restapi from artifactory instead * chore: Remove example-restapi sources as they've been moved to another repo
- Loading branch information
1 parent
b202590
commit 0b27b27
Showing
6 changed files
with
111 additions
and
2 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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
--- | ||
- include_tasks: setup-nginx.yml | ||
- include_tasks: setup-xrd4j.yml | ||
- include_tasks: setup-xrd4j.yml | ||
- include_tasks: setup-restapi.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,49 @@ | ||
--- | ||
|
||
- name: Set architecture-specific variables | ||
set_fact: | ||
java_arch_path: "{{ ansible_architecture | regex_replace('x86_64', 'amd64') | regex_replace('aarch64', 'arm64') }}" | ||
|
||
- name: Set Java home path | ||
set_fact: | ||
java_17_home: "/usr/lib/jvm/java-17-openjdk-{{ java_arch_path }}" | ||
|
||
- name: Install required packages | ||
apt: | ||
name: | ||
- openjdk-17-jdk-headless | ||
update_cache: yes | ||
state: present | ||
|
||
- name: Get latest example-restapi version | ||
shell: | | ||
curl -s "https://artifactory.niis.org/api/storage/xroad-maven-releases/org/niis/example-restapi/" | \ | ||
jq -r '.children[] | select(.uri | match("/[0-9]+.[0-9]+.[0-9]+")) | .uri' | \ | ||
sort -V | tail -n1 | tr -d '/' | ||
register: latest_version | ||
|
||
- name: Get latest example-restapi artifact URL | ||
shell: | | ||
curl -s "https://artifactory.niis.org/api/storage/xroad-maven-releases/org/niis/example-restapi/{{ latest_version.stdout }}" | \ | ||
jq -r '.children[] | select(.uri | endswith("-boot.jar")) | .uri' | \ | ||
sort -V | tail -n1 | tr -d '/' | ||
register: artifact_filename | ||
|
||
- name: Download example-restapi | ||
get_url: | ||
url: "https://artifactory.niis.org/xroad-maven-releases/org/niis/example-restapi/{{ latest_version.stdout }}/{{ artifact_filename.stdout }}" | ||
dest: /example-restapi.jar | ||
mode: '0644' | ||
|
||
- name: Create systemd service | ||
template: | ||
src: templates/example-restapi.service.j2 | ||
dest: /etc/systemd/system/example-restapi.service | ||
mode: '0644' | ||
|
||
- name: Start and enable example-restapi service | ||
systemd: | ||
name: example-restapi | ||
state: started | ||
enabled: yes | ||
daemon_reload: yes |
11 changes: 11 additions & 0 deletions
11
ansible/roles/xroad-is/templates/example-restapi.service.j2
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,11 @@ | ||
[Unit] | ||
Description=Example REST API | ||
After=network.target | ||
|
||
[Service] | ||
Environment="JAVA_HOME={{ java_17_home }}" | ||
ExecStart={{ java_17_home }}/bin/java -jar -Dserver.port=8081 /example-restapi.jar | ||
Restart=always | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
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