aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbinary <me@rgoncalves.se>2021-01-22 11:42:56 +0100
committerbinary <me@rgoncalves.se>2021-01-22 11:42:56 +0100
commitf7c9094ff72da79b70d98c4be15636a2d503a2aa (patch)
treecca3127859999eb65e5aa50a50bc8e3d6e597371
parentab009b7d91ece98db3bfb1ab2bc4bf39e3b84c66 (diff)
downloadinfrastructure-f7c9094ff72da79b70d98c4be15636a2d503a2aa.tar.gz
Break java installation in separate role
-rw-r--r--roles/java/tasks/main.yml22
-rw-r--r--roles/java/vars/main.yml8
-rw-r--r--roles/minecraft/meta/main.yml8
-rw-r--r--roles/minecraft/tasks/main.yml9
-rw-r--r--roles/minecraft/vars/main.yml4
5 files changed, 44 insertions, 7 deletions
diff --git a/roles/java/tasks/main.yml b/roles/java/tasks/main.yml
new file mode 100644
index 0000000..748314a
--- /dev/null
+++ b/roles/java/tasks/main.yml
@@ -0,0 +1,22 @@
+
+# java ~~ roles/java/tasks/main.yml
+# install and configure java runtime environment
+
+---
+
+- name: install java for OpenBSD
+ package: name="{{ java_package_openbsd }}" state=present
+ when: ansible_distribution == "OpenBSD"
+
+- name: install java for Alpine
+ package: name="{{ java_package_alpine }}" state=present
+ when: ansible_distribution == "Alpine"
+
+- name: add java to /usr path
+ file:
+ src: /usr/local/jdk-11/bin/java
+ dest: /usr/local/bin/java
+ state: link
+ owner: "{{ user_root }}"
+ group: "{{ group_root }}"
+ when: ansible_distribution == "OpenBSD"
diff --git a/roles/java/vars/main.yml b/roles/java/vars/main.yml
new file mode 100644
index 0000000..5db3b4c
--- /dev/null
+++ b/roles/java/vars/main.yml
@@ -0,0 +1,8 @@
+
+# grafana ~~ roles/grafana/tasks/main.yml
+# grafana variables
+
+---
+
+java_package_openbsd: jdk-11.0.8.10.1v0
+java_package_alpine: openjdk11-jre-headless
diff --git a/roles/minecraft/meta/main.yml b/roles/minecraft/meta/main.yml
new file mode 100644
index 0000000..9866fe9
--- /dev/null
+++ b/roles/minecraft/meta/main.yml
@@ -0,0 +1,8 @@
+
+# minecraft ~~ roles/minecraft/meta/main.yml
+# Meta parameters
+
+---
+
+dependencies:
+ - { role: java, tags: "dependency" }
diff --git a/roles/minecraft/tasks/main.yml b/roles/minecraft/tasks/main.yml
index 657fb60..d78aa6e 100644
--- a/roles/minecraft/tasks/main.yml
+++ b/roles/minecraft/tasks/main.yml
@@ -12,6 +12,7 @@
user:
name: "{{ minecraft_user }}"
group: "{{ minecraft_group }}"
+ system: true
- name: create minecraft directory
file:
@@ -21,15 +22,12 @@
mode: 0700
state: directory
-- name: install java package
- package:
- name: "{{ packages[os_distribution].java }}"
-
- name: download minecraft server
get_url:
url: "{{ minecraft_url }}"
dest: "{{ minecraft_dir }}/{{ minecraft_bin }}"
owner: "{{ minecraft_user }}"
+ mode: 0644
- name: enable eula
lineinfile:
@@ -45,7 +43,8 @@
include_role: name=rc
vars:
rc_cmd: java
- rc_args: "-jar -Xms{{ minecraft_ram }} -Xmx{{ minecraft_ram }} -XX:+UseG1GC -jar server.jar nogui"
+ rc_args: "-Xms{{ minecraft_ram }} -Xmx{{ minecraft_ram }} -XX:+UseG1GC -jar server.jar nogui"
rc_user: "{{ minecraft_user }}:{{ minecraft_group }}"
rc_dir: "{{ minecraft_dir }}"
rc_name: minecraft
+ rc_strictpexp: true
diff --git a/roles/minecraft/vars/main.yml b/roles/minecraft/vars/main.yml
index f280e73..d917ac9 100644
--- a/roles/minecraft/vars/main.yml
+++ b/roles/minecraft/vars/main.yml
@@ -3,8 +3,8 @@
---
-minecraft_user: "minecraft"
-minecraft_group: "minecraft"
+minecraft_user: "_minecraft"
+minecraft_group: "_minecraft"
minecraft_dir: "/data/minecraft"
minecraft_bin: "server.jar"
minecraft_ram: "4G"
remember that computers suck.