Install and configure Narratio
This commit is contained in:
147
tasks/main.yml
Normal file
147
tasks/main.yml
Normal file
@@ -0,0 +1,147 @@
|
||||
---
|
||||
- name: Validate the supported platform
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- ansible_facts.distribution == "Ubuntu"
|
||||
- ansible_facts.distribution_version == "26.04"
|
||||
- ansible_facts.architecture in ["x86_64", "aarch64"]
|
||||
fail_msg: Narratio supports Ubuntu 26.04 on x86_64 or aarch64.
|
||||
|
||||
- name: Install Git
|
||||
become: true
|
||||
ansible.builtin.apt:
|
||||
name: git
|
||||
state: present
|
||||
update_cache: true
|
||||
cache_valid_time: 3600
|
||||
when: narratio_manage_build_dependencies
|
||||
|
||||
- name: Install Go
|
||||
become: true
|
||||
community.general.snap:
|
||||
name: go
|
||||
channel: "{{ narratio_go_snap_channel }}"
|
||||
classic: true
|
||||
state: present
|
||||
when: narratio_manage_build_dependencies
|
||||
|
||||
- name: Create the Narratio group
|
||||
become: true
|
||||
ansible.builtin.group:
|
||||
name: "{{ narratio_group }}"
|
||||
system: true
|
||||
|
||||
- name: Create the Narratio account
|
||||
become: true
|
||||
ansible.builtin.user:
|
||||
name: "{{ narratio_user }}"
|
||||
group: "{{ narratio_group }}"
|
||||
system: true
|
||||
home: "{{ narratio_workspace_root }}"
|
||||
create_home: false
|
||||
shell: /usr/sbin/nologin
|
||||
|
||||
- name: Create installation parent directories
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
loop:
|
||||
- "{{ narratio_source_dir | dirname }}"
|
||||
- "{{ narratio_binary_path | dirname }}"
|
||||
|
||||
- name: Create configuration directory
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: "{{ narratio_config_path | dirname }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: "{{ narratio_group }}"
|
||||
mode: "0750"
|
||||
|
||||
- name: Create mutable Narratio roots
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
owner: "{{ narratio_user }}"
|
||||
group: "{{ narratio_group }}"
|
||||
mode: "2775"
|
||||
loop:
|
||||
- "{{ narratio_workspace_root }}"
|
||||
- "{{ narratio_spool_root }}"
|
||||
- "{{ narratio_cache_root }}"
|
||||
|
||||
- name: Create the campaign registry root
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: "{{ narratio_campaigns_root }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: "{{ narratio_group }}"
|
||||
mode: "0755"
|
||||
|
||||
- name: Check out Narratio source
|
||||
become: true
|
||||
ansible.builtin.git:
|
||||
repo: "{{ narratio_repository_url }}"
|
||||
dest: "{{ narratio_source_dir }}"
|
||||
version: "{{ narratio_version }}"
|
||||
force: true
|
||||
register: narratio_checkout
|
||||
|
||||
- name: Inspect the installed binary
|
||||
ansible.builtin.stat:
|
||||
path: "{{ narratio_binary_path }}"
|
||||
register: narratio_binary
|
||||
|
||||
- name: Build Narratio
|
||||
become: true
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- "{{ narratio_go_binary }}"
|
||||
- build
|
||||
- -trimpath
|
||||
- -ldflags
|
||||
- "-s -w -X gitea.maximumdirect.net/eric/narratio/internal/buildinfo.Version={{ narratio_version }}"
|
||||
- -o
|
||||
- "{{ narratio_binary_path }}"
|
||||
- ./cmd/narratio
|
||||
chdir: "{{ narratio_source_dir }}"
|
||||
environment:
|
||||
CGO_ENABLED: "0"
|
||||
GOWORK: "off"
|
||||
GOTOOLCHAIN: local
|
||||
changed_when: true
|
||||
when: >-
|
||||
narratio_checkout.changed or
|
||||
not narratio_binary.stat.exists
|
||||
|
||||
- name: Converge installed metadata
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: "{{ item.state }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "{{ item.mode | default(omit) }}"
|
||||
recurse: "{{ item.recurse | default(omit) }}"
|
||||
loop:
|
||||
- path: "{{ narratio_source_dir }}"
|
||||
state: directory
|
||||
recurse: true
|
||||
- path: "{{ narratio_binary_path }}"
|
||||
state: file
|
||||
mode: "0755"
|
||||
|
||||
- name: Write Narratio pipeline configuration
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: pipeline.yml.j2
|
||||
dest: "{{ narratio_config_path }}"
|
||||
owner: root
|
||||
group: "{{ narratio_group }}"
|
||||
mode: "0640"
|
||||
Reference in New Issue
Block a user