source: main/trunk/greenstone3/src/ansible-playbooks/experimental-playbooks/v1/greenstone3-svn-base-playbook.yml@ 38572

Last change on this file since 38572 was 38572, checked in by davidb, 5 months ago

Copy of the playbook to get Greenstone3 compiled up and deployed over https when first working, and before code tidyup

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