summaryrefslogtreecommitdiff
path: root/baserock_opengrok/instance-config.yml
blob: 836e805bc2ed05b7c630f45ca3a1f5968a997ff0 (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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# Configuration for Baserock OpenGrok system image.
#
# This expects to be run on a Fedora 23 cloud image.
---
- hosts: opengrok
  gather_facts: false
  sudo: yes
  vars:
    OG_VERSION: 0.12.1.5
    EXPORT_WORKDIR: /opt/export-workdir
    BASEROCK_EXPORT: /opt/baserock-export
    OPENGROK_BASE: /opt/opengrok
  tasks:
  # See: https://fedoramagazine.org/getting-ansible-working-fedora-23/
  - name: install Python2 and required deps for Ansible modules
    raw: dnf install -y python2 python2-dnf libselinux-python

  - name: enable persistant journal
    shell: mkdir /var/log/journal
    args:
      creates: /var/log/journal

  - name: ensure system up to date
    dnf: name=* state=latest

  - name: Install Tomcat, wget, git, and ctags packages
    dnf:
      name: "{{ item }}"
      state: latest
    with_items:
    - tomcat
    - wget
    - git
    - ctags

  - name: Enable and start Tomcat
    service:
        name: tomcat
        enabled: yes

  - name: add opengrok user
    user:
      name: opengrok
      shell: /bin/false

  - name: create /opt/.. directories
    file:
      path: "{{ item }}"
      state: directory
      owner: opengrok
      group: opengrok
    with_items:
    - "{{ OPENGROK_BASE }}"
    - /opt/downloads
    - "{{ BASEROCK_EXPORT }}"
    - "{{ EXPORT_WORKDIR }}"

  - name: Download opengrok
    shell: wget https://java.net/projects/opengrok/downloads/download/opengrok-{{ OG_VERSION }}.tar.gz -O /opt/downloads/opengrok-{{ OG_VERSION }}.tar.gz
    args:
      creates: /opt/downloads/opengrok-{{ OG_VERSION }}.tar.gz
    sudo_user: opengrok

  - name: Unpack opengrok
    unarchive:
      src: /opt/downloads/opengrok-{{ OG_VERSION }}.tar.gz
      copy: no
      dest: /opt/downloads
      owner: opengrok
      group: opengrok
      creates: /opt/downloads/opengrok-{{ OG_VERSION }}
    register: opengrok_unpacked

  - name: Copy OpenGrok to the right location
    shell: cp -r /opt/downloads/opengrok-{{ OG_VERSION }}/* "{{ OPENGROK_BASE }}"
    when: opengrok_unpacked|changed

  - name: Install morph dependencies
    pip:
      name: "{{ item }}"
    with_items:
    - fs
    - pylru
    - pyyaml
    - jsonschema

  - name: Downloading baserock-export scripts
    git:
      repo: git://github.com/ssssam/baserock-export
      dest: "{{ BASEROCK_EXPORT }}"
      accept_hostkey: yes
    sudo_user: opengrok

  - name: Install baserock-export wrapper script
    template:
      src: export.sh
      dest: "{{ EXPORT_WORKDIR }}/export.sh"
      mode: 0755
      owner: opengrok
      group: opengrok

  - name: Install baserock-export service
    template:
      src: baserock-export.service
      dest: /etc/systemd/system/baserock-export.service

  - name: Install baserock-export timer
    copy:
      src: baserock-export.timer
      dest: /etc/systemd/system/baserock-export.timer

  - name: Enable and start baserock-export services
    service:
        name: "{{ item }}"
        enabled: yes
        state: started
    with_items:
    - baserock-export.timer
    - baserock-export.service

  - name: Deploy OpenGrok app in Tomcat
    shell: OPENGROK_TOMCAT_BASE=/var/lib/tomcat "{{ OPENGROK_BASE }}/bin/OpenGrok" deploy

  - name: Create ROOT folder for Tomcat
    file:
      path: /var/lib/tomcat/webapps/ROOT
      state: directory
      owner: tomcat
      group: tomcat

  - name: Redirect / to /source (OpenGrok) in Tomcat
    copy:
      src: index.jsp
      dest: /var/lib/tomcat/webapps/ROOT/index.jsp
      owner: tomcat
      group: tomcat

  - name: Install clone-and-index wrapper script
    template:
      src: clone-and-index.sh
      dest: "{{ OPENGROK_BASE }}/clone-and-index.sh"
      mode: 0755
      owner: opengrok
      group: opengrok

  - name: Install clone-and-index service
    template:
      src: clone-and-index.service
      dest: /etc/systemd/system/clone-and-index.service

  - name: Install clone-and-index timer
    copy:
      src: clone-and-index.timer
      dest: /etc/systemd/system/clone-and-index.timer

  - name: Enable and start clone-and-index services
    service:
        name: "{{ item }}"
        enabled: yes
        state: started
    with_items:
    - clone-and-index.timer
    - clone-and-index.service