Finished up dendrite build server role.
authorLuke Hoersten <luke@hoersten.org>
Sat, 22 Jul 2023 15:50:07 -0500
changeset 216 6c85835d4621
parent 215 dd52907adff9
child 217 e69a030975c4
Finished up dendrite build server role.
dendrite/build/defaults/main.yaml
dendrite/build/tasks/main.yaml
dendrite/server/defaults/main.yaml
dendrite/server/tasks/main.yaml
--- a/dendrite/build/defaults/main.yaml	Fri Jul 21 15:14:24 2023 -0500
+++ b/dendrite/build/defaults/main.yaml	Sat Jul 22 15:50:07 2023 -0500
@@ -1,7 +1,7 @@
 ---
 
-dendrite_user: "dendrite"
 dendrite_version: "0.13.1"
 # https://github.com/matrix-org/dendrite/releases
 dendrite_tar: "https://github.com/matrix-org/dendrite/archive/refs/tags/v{{dendrite_version}}.tar.gz"
 dendrite_build_dir: "/tmp/dendrite-{{dendrite_version}}"
+dendrite_srv_dir: "/var/www/build/"
--- a/dendrite/build/tasks/main.yaml	Fri Jul 21 15:14:24 2023 -0500
+++ b/dendrite/build/tasks/main.yaml	Sat Jul 22 15:50:07 2023 -0500
@@ -1,8 +1,8 @@
 ---
 
-- name: snap install golang
+- name: install golang
   become: yes
-  snap: name="go" classic="yes"
+  apt: name="golang-go"
 
 - name: unarchive dendrite
   unarchive:
@@ -11,13 +11,39 @@
     dest: "/tmp/"
     creates: "{{dendrite_build_dir}}"
 
+- name: create build dir
+  file:
+    path: "{{dendrite_build_dir}}/bin"
+    mode: "0755"
+    state: "directory"
+
 - name: check if dendrite build exists
   stat:
-    path: "{{dendrite_build_dir}}/bin"
+    path: "{{dendrite_build_dir}}/bin/dendrite"
   register: build_file
 
 - name: build dendrite
-  command: "{{dendrite_build_dir}}/build.sh"
+  command: "go build -o bin/ ./cmd/..."
   args:
     chdir: "{{dendrite_build_dir}}"
   when: not build_file.stat.exists
+
+- name: create build server dir
+  become: yes
+  file:
+    path: "{{dendrite_srv_dir}}"
+    mode: "0755"
+    state: "directory"
+  when: not build_file.stat.exists
+
+- name: create a gz archive of dendrite bins
+  become: yes
+  archive:
+    path: "{{dendrite_build_dir}}/bin/*"
+    exclude_path:
+      - "{{dendrite_build_dir}}/bin/dendrite-demo-pinecone"
+      - "{{dendrite_build_dir}}/bin/dendrite-demo-yggdrasil"
+      - "{{dendrite_build_dir}}/bin/furl"
+    dest: "{{dendrite_srv_dir}}/dendrite.tar.gz"
+    format: "gz"
+  when: not build_file.stat.exists
--- a/dendrite/server/defaults/main.yaml	Fri Jul 21 15:14:24 2023 -0500
+++ b/dendrite/server/defaults/main.yaml	Sat Jul 22 15:50:07 2023 -0500
@@ -1,6 +1,6 @@
 ---
 
-dendrite_bin_dir: "/tmp/dendrite-{{dendrite_version}}"
+dendrite_user: "dendrite"
 dendrite_old_key: false
 dendrite_registration_disabled: true
 dendrite_registration_secret: ""
--- a/dendrite/server/tasks/main.yaml	Fri Jul 21 15:14:24 2023 -0500
+++ b/dendrite/server/tasks/main.yaml	Sat Jul 22 15:50:07 2023 -0500
@@ -4,10 +4,24 @@
   become: yes
   user: name="{{dendrite_user}}" shell="/bin/false" system="yes"
 
+- name: create unzip dir
+  become: yes
+  file:
+    path: "/tmp/dendrite/"
+    state: "directory"
+    mode: "0755"
+
+- name: unarchive dendrite bins
+  become: yes
+  unarchive:
+    remote_src: yes
+    src: "{{dendrite_tar}}"
+    dest: "/tmp/dendrite/"
+
 - name: install dendrite binary
   become: yes
   copy:
-    src: "{{dendrite_bin_dir}}/{{item.src}}"
+    src: "/tmp/dendrite/{{item.src}}"
     dest: "/usr/local/bin/{{item.dest}}"
     remote_src: yes
     owner: "root"