revamped temporary directories
[noc.git] / ansible / host_playbooks / torwaechter.yml
diff --git a/ansible/host_playbooks/torwaechter.yml b/ansible/host_playbooks/torwaechter.yml
new file mode 100644 (file)
index 0000000..a5a695a
--- /dev/null
@@ -0,0 +1,42 @@
+---
+- hosts: torwaechter
+  connection: local
+  pre_tasks:
+    - name: Create go directories
+      file:
+        path: "{{ global_cache_dir }}/{{ inventory_hostname }}/{{ item }}"
+        state: directory
+      with_items: [ gopath, gocache ]
+
+    - name: Clone necessary git repositories
+      git:
+        repo: https://github.com/realraum/{{ item }}.git
+        dest: "{{ global_cache_dir }}/{{ inventory_hostname }}/{{ item }}"
+        update: True
+      with_items: [ door_and_sensors ]
+
+    - name: Download dependencies
+      command: go get -d ./...
+      args:
+        chdir: "{{ global_cache_dir }}/{{ inventory_hostname }}/door_and_sensors/{{ item }}"
+      environment:
+        GOCACHE: "{{ global_cache_dir }}/{{ inventory_hostname }}/gocache"
+        GOPATH:  "{{ global_cache_dir }}/{{ inventory_hostname }}/gopath"
+      with_items: [ door_client, door_daemon, update-keys ]
+
+    - name: Cross-compile Go binaries
+      command: go build -ldflags "-s"
+      args:
+        chdir: "{{ global_cache_dir }}/{{ inventory_hostname }}/door_and_sensors/{{ item }}"
+      environment:
+        GOCACHE: "{{ global_cache_dir }}/{{ inventory_hostname }}/gocache"
+        GOPATH:  "{{ global_cache_dir }}/{{ inventory_hostname }}/gopath"
+        GO386: 387
+        CGO_ENABLED: 0
+        GOOS: linux
+        GOARCH: 386
+      with_items: [ door_client, door_daemon, update-keys ]
+
+  roles:
+    - role: openwrt-image
+      delegate_to: localhost