--- - name: ensure build work dir exists become: yes file: path: "{{build_work_dir}}" state: "directory" owner: "{{ansible_user}}" group: "{{ansible_user}}" mode: "0755" - name: install golang become: yes apt: name="golang-1.21-go" - name: link go bin become: yes file: src: "/usr/lib/go-1.21/bin/go" dest: "/usr/bin/go" state: "link" mode: "0755" - name: git checkout lnurld git: repo: "{{lnurld_git}}" dest: "{{lnurld_build_dir}}" version: "{{lnurld_version}}" - name: check if build exists stat: path: "{{lnurld_srv_dir}}/lnurld-{{lnurld_version}}.tar.gz" register: build_file - name: build command: "go build" args: chdir: "{{lnurld_build_dir}}" # Keep the Go caches on build_work_dir (the SSD) instead of the SD card. environment: GOPATH: "{{build_work_dir}}/.go" GOCACHE: "{{build_work_dir}}/.go-cache" GOMODCACHE: "{{build_work_dir}}/.go-mod" when: not build_file.stat.exists - name: create build server dir become: yes file: path: "{{lnurld_srv_dir}}" mode: "0755" state: "directory" - name: create gz archive of lnurld become: yes archive: path: "{{lnurld_build_dir}}/lnurld" dest: "{{lnurld_srv_dir}}/lnurld-{{lnurld_version}}.tar.gz" format: "gz" # force a real tar for the single binary; the module otherwise gzips a lone # file into a bare .gz that the server's unarchive can't extract. force_archive: true when: not build_file.stat.exists