Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
- name: Download and extract Go
ansible.builtin.unarchive:
src: https://go.dev/dl/go{{go_version}}.linux-amd64.tar.gz
dest: /usr/local
remote_src: yes
- name: Create symlink to Go
ansible.builtin.file:
src: /usr/local/go/bin/{{item}}
dest: /usr/local/bin/{{item}}
state: link
with_items:
- go
- gofmt
- name: Install protobuf-compiler and golang-goprotobuf-dev package
ansible.builtin.apt:
name:
- golang-goprotobuf-dev
- protobuf-compiler
state: present
update_cache: yes
- name: Download {{service_name}} from git
ansible.builtin.git:
repo: "{{git_repo_url}}"
dest: "{{path_to_service}}"
notify:
- Go mod download
- Build the proto
- Build the service
- restart the service
- name: Create genproto directory
ansible.builtin.file:
path: "{{path_to_service}}/genproto"
state: directory
notify:
- Build the proto
- Build the service
- restart the service
- name: Create the {{service_name}} file
vars:
working_directory: "{{path_to_service}}"
cmd_to_execute: "{{path_to_service}}/{{service_name}}"
env_vars: "port=3550"
ansible.builtin.template:
src: templates/systemd.j2
dest: /etc/systemd/system/{{service_name}}.service
notify:
- restart the service