configurations-ansible/roles/zabov/tasks/main.yml

74 lines
2 KiB
YAML

---
# tasks file for zabov
- name: zabov role; install zabov from sources
when: 'go_path is defined'
block:
- name: Install git if needed
ansible.builtin.package:
name: git
- name: Create zabov group
group:
name: "{{ zabov_group }}"
state: present
- name: Create zabov user
user:
name: "{{ zabov_user }}"
state: present
shell: /sbin/nologin
group: "{{ zabov_group }}"
- name: Official repo print url
debug:
msg: "{{ zabov_git_url }}"
- name: Compile zabov
become: true
become_user: "{{ zabov_user }}"
block:
- name: Check if repo is cloned
stat:
path: "{{ zabov_installation_path }}"
register: installation_path
- name: Clone repo
when: 'not installation_path.stat.exists'
ansible.builtin.git:
repo: "{{ zabov_git_url }}"
dest: "{{ zabov_installation_path }}"
single_branch: yes
version: "{{ zabov_git_branch }}"
- name: Update repo
ansible.builtin.git:
repo: "{{ zabov_git_url }}"
dest: "{{ zabov_installation_path }}"
update: yes
- name: Get $PATH
ansible.builtin.shell:
cmd: "echo $PATH"
register: path_env
- name: Get go dependencies
ansible.builtin.shell:
cmd: "go get"
chdir: "{{ zabov_installation_path }}"
environment:
PATH: '{{ go_path }}:{{ path_env }}'
args:
executable: /bin/bash
- name: Build executable
ansible.builtin.shell:
cmd: "go build -mod=vendor"
chdir: "{{ zabov_installation_path }}"
environment:
PATH: '{{ go_path }}:{{ path_env }}'
args:
executable: /bin/bash
- include_tasks: "install_{{ ansible_service_mgr }}_service.yml"
ignore_errors: true