--- - name: check if binary exist stat: path: '{{ go_programs_bin_directory }}/{{ repository.name }}' register: bin tags: go - name: clone repository git: repo: '{{ repository.repo }}' dest: '{{ go_programs_src_directory }}/{{ repository.name }}' version: '{{ repository.version }}' register: git tags: go - name: install dependencies command: args: chdir: '{{ go_programs_src_directory }}/{{ repository.name }}' argv: - '/usr/lib/go-{{ go_programs_version }}/bin/go' - get - . environment: GOPATH: '{{ go_programs_src_directory }}/go' GOBIN: '{{ go_programs_src_directory }}/go/bin' when: git.changed or not bin.stat.exists tags: go - name: build program command: args: chdir: '{{ go_programs_src_directory }}/{{ repository.name }}' argv: - '/usr/lib/go-{{ go_programs_version }}/bin/go' - build - '-o' - '{{ go_programs_bin_directory }}/{{ repository.name }}' - main.go environment: GOPATH: '{{ go_programs_src_directory }}/go' GOBIN: '{{ go_programs_src_directory }}/go/bin' when: git.changed or not bin.stat.exists tags: go - name: set permission on binary file: path: '{{ go_programs_bin_directory }}/{{ repository.name }}' owner: root group: root mode: 0755 tags: go