summaryrefslogtreecommitdiff
path: root/roles/pipeliner/tasks/pipeline.yml
blob: 61becfb333d3f6136ab352577ecf16ab4cf5c920 (plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
---

# Needed for stretch as we need golang >= 1.9 (for x/draw dependency), and stretch
# only has 1.8 available
- name: Install debian backports
  lineinfile:
    path: /etc/apt/sources.list.d/backports.list
    line: deb http://deb.debian.org/debian stretch-backports main
    create: yes

# This shouldn't be needed due to update_cache line in the below install rule,
# however that doesn't seem to trigger for some reason
- name: Update apt
  apt:
    update_cache: yes

- name: Install golang
  apt:
    name: golang-go
    state: present
    default_release: stretch-backports
    update_cache: yes

# Do this manually rather than relying on go get so that go get
# with modules enabled can be run to do the build
- name: Get go repo
  git:
    dest: /home/{{ ansible_user }}/src/go/src/rescribe.xyz/{{ item }}
    repo: https://git.rescribe.xyz/{{ item }}
    force: yes
  become: no
  with_items:
    - bookpipeline
    - preproc
    - utils

- name: Get and build bookpipeline and dependencies
  shell:
    cmd: GOPATH=/home/{{ ansible_user }}/src/go GO111MODULE=on go install rescribe.xyz/bookpipeline/...
    chdir: /home/{{ ansible_user }}/src/go/src/rescribe.xyz/bookpipeline
  become: no
# command fails because of a strange error with environment, resulting in
# 'go: unknown environment setting GO111MODULE=True'
# so we're setting it from the shell instead.
# we should be able to revert back to command once using a more recent
# go version where GO111MODULE is not required.
#  command:
#    cmd: go install rescribe.xyz/bookpipeline/...
#    chdir: /home/{{ ansible_user }}/src/go/src/rescribe.xyz/bookpipeline
#  environment:
#    GOPATH: /home/{{ ansible_user }}/src/go
#    GO111MODULE: on
#  become: no

- name: Install bookpipeline binary
  copy:
    remote_src: true
    src: /home/{{ ansible_user }}/src/go/bin/bookpipeline
    dest: /usr/local/bin/
    owner: root
    group: root
    mode: 0755

- name: Install updatepipeline script
  template:
    src: updatepipeline.j2
    dest: /usr/local/bin/updatepipeline
    owner: root
    group: root
    mode: 0755

- name: Create settings directory
  file:
    path: /home/admin/.config/bookpipeline
    state: directory
    owner: admin
    group: admin
    mode: 0755

- name: Install mail settings
  copy:
    src: mailsettings
    dest: /home/admin/.config/bookpipeline/mailsettings
    owner: admin
    group: admin
    mode: 0600

- name: Install systemd unit file
  copy: src=bookpipeline.service dest=/etc/systemd/system
  notify: reload daemons

- name: Enable service
  service: name=bookpipeline enabled=true