Skip to content
Snippets Groups Projects
main.yml 1.27 KiB
Newer Older
REIG Julien's avatar
REIG Julien committed
- 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