roles/openwrt-image: Cache downloaded files
[noc.git] / ansible / tuer.yml
index cd06649..0d26eb3 100644 (file)
@@ -1,15 +1,12 @@
+---
 - hosts: torwaechter
   connection: local
-  tasks:
-    - name: Create cache repository
+  pre_tasks:
+    - name: Create go directories
       file:
-        path: .cache/openwrt/tuer
-        state: directory
-
-    - name: Create GOPATH directory
-      file:
-        path: .cache/openwrt/tuer/gopath
+        path: .cache/openwrt/tuer/{{ item }}
         state: directory
+      with_items: [ gopath, gocache ]
 
     - name: Clone necessary git repositories
       git:
         update: True
       with_items: [ door_and_sensors ]
 
-#    - name: Build update-keys
-
     - name: Download dependencies
       command: go get -d ./...
       args:
         chdir: .cache/openwrt/tuer/door_and_sensors/{{ item }}
       environment:
-        GOPATH: "{{ playbook_dir }}/.cache/openwrt/tuer/gopath"
-      with_items: [ door_client, door_daemon ]
+        GOCACHE: "{{ playbook_dir }}/.cache/openwrt/tuer/gocache"
+        GOPATH:  "{{ playbook_dir }}/.cache/openwrt/tuer/gopath"
+      with_items: [ door_client, door_daemon, update-keys ]
 
     - name: Cross-compile Go binaries
       command: go build -ldflags "-s"
       args:
         chdir: .cache/openwrt/tuer/door_and_sensors/{{ item }}
       environment:
+        GOCACHE: "{{ playbook_dir }}/.cache/openwrt/tuer/gocache"
+        GOPATH:  "{{ playbook_dir }}/.cache/openwrt/tuer/gopath"
         GO386: 387
         CGO_ENABLED: 0
         GOOS: linux
         GOARCH: 386
-      with_items: [ door_client, door_daemon ]
+      with_items: [ door_client, door_daemon, update-keys ]
 
-- hosts: torwaechter
-  connection: local
   roles:
     - role: openwrt-image
       delegate_to: localhost
-      vars:
-        openwrt_arch: x86
-        openwrt_target: geode
-        openwrt_packages_remove:
-          - ppp
-          - ppp-mod-pppoe
-          - dnsmasq
-          - firewall
-          - odhcpd
-        openwrt_packages_add:
-          - flashrom
-          - haveged
-          - htop
-          - hwclock
-          - ip
-          - less
-          - nano
-          - tcpdump
-        openwrt_packages_extra:
-          - git