ansible-role-go_programs/tasks/build.yml

53 lines
1.3 KiB
YAML
Raw Normal View History

2019-01-28 22:05:58 +00:00
---
- 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