1 | # Self-contained Ansible playbook to install required Unix
|
---|
2 | # command-line packages, and then configure, compile and install
|
---|
3 | # a basic Greenstone3, running tomcat over http, and accessed
|
---|
4 | # directly, e.g. http://localhost:8383/greenstone3/library
|
---|
5 |
|
---|
6 |
|
---|
7 | # Playbook currently designed to be run on computer where the
|
---|
8 | # Greenstone installation is to occur (i.e., localhost)
|
---|
9 |
|
---|
10 | # To install ansible:
|
---|
11 | # sudo apt update
|
---|
12 | # sudo apt install software-properties-common
|
---|
13 | # sudo add-apt-repository --yes --update ppa:ansible/ansible
|
---|
14 | # sudo apt install ansible
|
---|
15 |
|
---|
16 | # To run this playbook to svn checkout Greenstone3 and compile it up:
|
---|
17 | #
|
---|
18 | # ansible-playbook -l localhost -u $USER ./greenstone3-svn-playbook.yml
|
---|
19 |
|
---|
20 | ---
|
---|
21 |
|
---|
22 | - name: Installing required command-line tools
|
---|
23 | hosts: localhost
|
---|
24 | connection: local
|
---|
25 |
|
---|
26 | ####
|
---|
27 | # Review and edit as needed the variables in the following file
|
---|
28 | ####
|
---|
29 | vars_files:
|
---|
30 | - vars/default-core.yml
|
---|
31 |
|
---|
32 | # ####
|
---|
33 | # # Edit variable values below as needed
|
---|
34 | # ####
|
---|
35 | # vars:
|
---|
36 | # gsdl3srchome: /home/{{ ansible_user }}/greenstone3-svn
|
---|
37 | # # gsdl3srchome: /mnt/<mydisk>/greenstone3-svn
|
---|
38 | # # gsdl3srchome: /mnt/intermuse/greenstone3-ansible-svn
|
---|
39 | # gsdl3port: 8383
|
---|
40 |
|
---|
41 | tasks:
|
---|
42 | - name: Setting gsdl3srchome
|
---|
43 | set_fact: gsdl3srchome="{{ gsdl3srchome }}"
|
---|
44 | - debug: msg="gsdl3srchome = {{ hostvars['localhost']['gsdl3srchome'] }}"
|
---|
45 |
|
---|
46 | - name: Setting gsdl3port
|
---|
47 | set_fact: gsdl3port="{{ gsdl3port }}"
|
---|
48 | - debug: msg="gsdl3port = {{ hostvars['localhost']['gsdl3port'] }}"
|
---|
49 |
|
---|
50 | - name: Setting gsdl3ports
|
---|
51 | set_fact: gsdl3ports="{{ gsdl3ports }}"
|
---|
52 | - debug: msg="gsdl3ports = {{ hostvars['localhost']['gsdl3ports'] }}"
|
---|
53 |
|
---|
54 | - name: Installing required command-line tools
|
---|
55 | hosts: localhost
|
---|
56 | connection: local
|
---|
57 | become: true
|
---|
58 |
|
---|
59 | tasks:
|
---|
60 | - name: Changing Ansible to use 'aptitude' as package installation manager
|
---|
61 | apt: name=aptitude update_cache=yes state=latest force_apt_get=yes
|
---|
62 |
|
---|
63 | - name: Ensure that existing packages are up-to-date (within last 30 mins)
|
---|
64 | apt: update_cache=yes state=latest force_apt_get=yes cache_valid_time=1800
|
---|
65 |
|
---|
66 | - name: Install prerequisites
|
---|
67 | apt: name={{ item }} update_cache=yes state=latest
|
---|
68 | loop: [
|
---|
69 | 'subversion', 'build-essential', 'wget',
|
---|
70 |
|
---|
71 | # As well as using 'unzip', the greenstone3 compile sequence currently uses
|
---|
72 | # 'zip' in a handful of places, such as:
|
---|
73 | # <gsdl3srchome>/gli/makejar.sh
|
---|
74 | 'zip', 'unzip',
|
---|
75 |
|
---|
76 | # Choosing to install the latest, rather than work with the one included
|
---|
77 | # as an Greenstone3 extension, as that latter is getting a bit old
|
---|
78 | 'imagemagick',
|
---|
79 |
|
---|
80 | # The following needed for WebSwing on a headless server
|
---|
81 | 'libxrender1', 'libxtst6', 'libxi6', 'xvfb',
|
---|
82 |
|
---|
83 | # The following are nice to have in general
|
---|
84 | 'plocate', 'emacs-nox'
|
---|
85 | ]
|
---|
86 |
|
---|
87 | - hosts: localhost
|
---|
88 | connection: local
|
---|
89 | vars_files:
|
---|
90 | - vars/default-core.yml
|
---|
91 |
|
---|
92 | tasks:
|
---|
93 | - name: Subversion checkout of Greenstone3
|
---|
94 | ansible.builtin.subversion:
|
---|
95 | repo: https://svn.greenstone.org/main/trunk/greenstone3
|
---|
96 | checkout: yes
|
---|
97 | update: no
|
---|
98 | dest: "{{ gsdl3srchome }}"
|
---|
99 |
|
---|
100 | - name: Downloading and unpacking self-contained command-line tools for Greenstone3
|
---|
101 | ansible.builtin.shell:
|
---|
102 | chdir: "{{ gsdl3srchome }}/ext-cli"
|
---|
103 | # cmd: "./get-selfcontained-jdk.sh && ./get-selfcontained-ant.sh"
|
---|
104 | cmd: "./get-selfcontained-{{ item }}.sh"
|
---|
105 | register: result
|
---|
106 | changed_when:
|
---|
107 | - '"Untarred" in result.stdout'
|
---|
108 | with_items:
|
---|
109 | - jdk
|
---|
110 | - ant
|
---|
111 |
|
---|
112 | # The next two steps are equivalent to sourcing SETUP.bash
|
---|
113 | # For more details, see:
|
---|
114 | # https://stackoverflow.com/questions/60209185/ansible-environment-variables-from-env-file
|
---|
115 | #
|
---|
116 | - name: Source Greenstone3's SETUP.bash
|
---|
117 | ansible.builtin.shell:
|
---|
118 | executable: /bin/bash
|
---|
119 | chdir: "{{ gsdl3srchome }}"
|
---|
120 | cmd: . ./SETUP.bash 1>/dev/null 2>&1 && env
|
---|
121 | register: env_file_result
|
---|
122 |
|
---|
123 | # - name: Source Greenstone3's SETUP.bash using newer ./SETUP-ENV.sh (Ultimately new appoach not needed)
|
---|
124 | # ansible.builtin.command: ./SETUP-ENV.sh
|
---|
125 | # args:
|
---|
126 | # chdir: "{{ gsdl3srchome }}"
|
---|
127 | # register: env_file_result
|
---|
128 |
|
---|
129 | # - name: Deprecated 'source' Greenstone3's SETUP.bash (command)
|
---|
130 | # ansible.builtin.command:
|
---|
131 | # # executable: /bin/bash
|
---|
132 | # chdir: "{{ gsdl3srchome }}"
|
---|
133 | # cmd: ./SETUP-ENV.sh
|
---|
134 | # register: env_file_result
|
---|
135 |
|
---|
136 |
|
---|
137 | # #- debug: var=env_file_result.stdout_lines
|
---|
138 |
|
---|
139 | - name: Parse Greenstone3 environment variables
|
---|
140 | set_fact:
|
---|
141 | env_vars: "{{ ('{' + env_file_result.stdout_lines | map('regex_replace', '([^=]*)=(.*)', '\"\\1\": \"\\2\"') | join(',') + '}') | from_json }}"
|
---|
142 |
|
---|
143 | # - name: Display environment variables
|
---|
144 | # command: env
|
---|
145 | # environment: "{{ env_vars }}"
|
---|
146 |
|
---|
147 | #- debug: var=env_vars
|
---|
148 |
|
---|
149 |
|
---|
150 | - name: Generate build.properties for Greenstone3
|
---|
151 | ansible.builtin.command:
|
---|
152 | chdir: "{{ gsdl3srchome }}"
|
---|
153 | cmd: ant
|
---|
154 | environment: "{{ env_vars }}"
|
---|
155 |
|
---|
156 | - name: Setting localhost.port.http in build.properties
|
---|
157 | ansible.builtin.lineinfile:
|
---|
158 | path: "{{ gsdl3srchome }}/build.properties"
|
---|
159 | regexp: '^localhost.port.http='
|
---|
160 | line: localhost.port.http={{ gsdl3port }}
|
---|
161 |
|
---|
162 | - name: Setting ports in build.properties
|
---|
163 | ansible.builtin.lineinfile:
|
---|
164 | path: "{{ gsdl3srchome }}/build.properties"
|
---|
165 | regexp: '^{{ item }}='
|
---|
166 | line: "{{ item }}={{ hostvars['localhost']['gsdl3ports'][item] }}"
|
---|
167 | with_items:
|
---|
168 | - "localhost.port.http"
|
---|
169 | - "tomcat.shutdown.port"
|
---|
170 | - "tomcat.ajp.port"
|
---|
171 | - "derby.server.port"
|
---|
172 | - "tomcat.port.https"
|
---|
173 |
|
---|
174 | - name: Prepare Greenstone3
|
---|
175 | ansible.builtin.command:
|
---|
176 | chdir: "{{ gsdl3srchome }}"
|
---|
177 | stdin: "y"
|
---|
178 | stdin_add_newline: true
|
---|
179 | cmd: ant prepare
|
---|
180 | environment: "{{ env_vars }}"
|
---|
181 |
|
---|
182 | # - name: Prepare Greenstone3 (A more complicated approach using 'expect')
|
---|
183 | # ansible.builtin.expect:
|
---|
184 | # chdir: "{{ gsdl3srchome }}"
|
---|
185 | # command: ant prepare
|
---|
186 | # timeout: null
|
---|
187 | # responses:
|
---|
188 | # "\\[input\\]\\s+\\(y, n\\)": "y"
|
---|
189 | # environment: "{{ env_vars }}"
|
---|
190 |
|
---|
191 | # - name: Prepare Greenstone3 II (untested, and even more complicated, requiring 'expect' to be installed)
|
---|
192 | # ansible.builtin.shell: |
|
---|
193 | # cd {{ gsdl3srchome }}
|
---|
194 | # . ./SETUP.bash
|
---|
195 | # spawn ant prepare
|
---|
196 | # expect "[input] (y, n):"
|
---|
197 | # send "y\n"
|
---|
198 | #
|
---|
199 | # exit 0
|
---|
200 | # args:
|
---|
201 | # executable: /usr/bin/expect
|
---|
202 |
|
---|
203 |
|
---|
204 | - name: Compile and Install Greenstone3 (command)
|
---|
205 | ansible.builtin.command:
|
---|
206 | chdir: "{{ gsdl3srchome }}"
|
---|
207 | cmd: ant install
|
---|
208 | environment: "{{ env_vars }}"
|
---|
209 |
|
---|
210 | # - name: Compile and Install Greenstone3 (shell)
|
---|
211 | # ansible.builtin.shell:
|
---|
212 | # chdir: "{{ gsdl3srchome }}"
|
---|
213 | # cmd: . ./SETUP.bash && ant install
|
---|
214 |
|
---|