Install and configure Scriptorium
This commit is contained in:
101
tasks/main.yml
Normal file
101
tasks/main.yml
Normal file
@@ -0,0 +1,101 @@
|
||||
---
|
||||
- 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: Scriptorium 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: scriptorium_manage_build_dependencies
|
||||
|
||||
- name: Install Go
|
||||
become: true
|
||||
community.general.snap:
|
||||
name: go
|
||||
channel: "{{ scriptorium_go_snap_channel }}"
|
||||
classic: true
|
||||
state: present
|
||||
when: scriptorium_manage_build_dependencies
|
||||
|
||||
- name: Create installation parent directories
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
loop:
|
||||
- "{{ scriptorium_source_dir | dirname }}"
|
||||
- "{{ scriptorium_binary_path | dirname }}"
|
||||
- "{{ scriptorium_config_path | dirname }}"
|
||||
|
||||
- name: Check out Scriptorium source
|
||||
become: true
|
||||
ansible.builtin.git:
|
||||
repo: "{{ scriptorium_repository_url }}"
|
||||
dest: "{{ scriptorium_source_dir }}"
|
||||
version: "{{ scriptorium_version }}"
|
||||
force: true
|
||||
register: scriptorium_checkout
|
||||
|
||||
- name: Inspect the installed binary
|
||||
ansible.builtin.stat:
|
||||
path: "{{ scriptorium_binary_path }}"
|
||||
register: scriptorium_binary
|
||||
|
||||
- name: Build Scriptorium
|
||||
become: true
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- "{{ scriptorium_go_binary }}"
|
||||
- build
|
||||
- -trimpath
|
||||
- -ldflags
|
||||
- -s -w
|
||||
- -o
|
||||
- "{{ scriptorium_binary_path }}"
|
||||
- ./cmd/scriptorium
|
||||
chdir: "{{ scriptorium_source_dir }}"
|
||||
environment:
|
||||
CGO_ENABLED: "0"
|
||||
GOWORK: "off"
|
||||
GOTOOLCHAIN: local
|
||||
changed_when: true
|
||||
when: >-
|
||||
scriptorium_checkout.changed or
|
||||
not scriptorium_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: "{{ scriptorium_source_dir }}"
|
||||
state: directory
|
||||
recurse: true
|
||||
- path: "{{ scriptorium_binary_path }}"
|
||||
state: file
|
||||
mode: "0755"
|
||||
|
||||
- name: Write Scriptorium configuration
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: config.yml.j2
|
||||
dest: "{{ scriptorium_config_path }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
Reference in New Issue
Block a user