Skip to content

Commit

Permalink
Make playbook into two pieces (#237)
Browse files Browse the repository at this point in the history
* Make playbook into two pieces

* [this is my] Code review

* Add islandora_base to gitignore

* Restart Solr after config is provided
  • Loading branch information
whikloj authored Dec 14, 2022
1 parent 28ab0ce commit 79b24b1
Show file tree
Hide file tree
Showing 36 changed files with 159 additions and 77 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ roles/external
.DS_Store
.project
.github
islandora_base
18 changes: 15 additions & 3 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,29 @@ $vagrantBox = ENV.fetch("ISLANDORA_DISTRO", "ubuntu/focal64")
# See the "install profile" section of the README for the full gamut available.
$drupalProfile = ENV.fetch("ISLANDORA_INSTALL_PROFILE", "starter")

# Build the base box, defaults to install a machine with the existing one.
$buildBaseBox=ENV.fetch("ISLANDORA_BUILD_BASE", "false").to_s.downcase == "true"

# vagrant is the main user
$vagrantUser = "vagrant"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provider "virtualbox" do |v|
v.name = "Islandora 8 Ansible Sandbox"
if $buildBaseBox
v.name = "Islandora 8 Ansible Base Box"
else
v.name = "Islandora 8 Ansible Sandbox Instance"
end
end

config.vm.hostname = $hostname

# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = $vagrantBox
if $buildBaseBox
config.vm.box = $vagrantBox
else
config.vm.box = "islandora_base"
end

# Configure home directory
home_dir = "/home/" + $vagrantUser
Expand Down Expand Up @@ -65,7 +76,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
"all" => { "ansible_ssh_user" => $vagrantUser }
}
ansible.extra_vars = { "islandora_distro" => $vagrantBox,
"islandora_profile" => $drupalProfile }
"islandora_profile" => $drupalProfile,
"islandora_build_base_box" => $buildBaseBox }
end
end

Expand Down
27 changes: 14 additions & 13 deletions bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
changed_when:
- output.stdout != ""
- output.stdout != "\r\n"
when: islandora_distro|default('') is match("ubuntu/")
when: "islandora_build_base_box|bool == True and islandora_distro|default('') is match('ubuntu/')"

# Manually gather facts once python is installed
- name: gather facts
Expand All @@ -31,56 +31,56 @@
name: aptitude
state: present
update_cache: yes
when: ansible_os_family == "Debian"
when: "islandora_build_base_box|bool == True and ansible_os_family == 'Debian'"

# install some packages we would like on every server
- name: install extra packages ubuntu
package:
name: "{{ item }}"
state: present
with_items: "{{ islandora_extra_ubuntu_packages }}"
when: ansible_os_family == "Debian"
when: "islandora_build_base_box|bool == True and ansible_os_family == 'Debian'"

# install some packages we would like on every server
- name: install extra packages centos
package:
name: "{{ item }}"
state: present
with_items: "{{ islandora_extra_centos_packages }}"
when: ansible_os_family == "RedHat"
when: "islandora_build_base_box|bool == True and ansible_os_family == 'RedHat'"

# Check Selinux
- name: check selinux status
raw: sestatus
register: sestatus_out
when: ansible_os_family == "RedHat"
when: "islandora_build_base_box|bool == True and ansible_os_family == 'RedHat'"

# Parse sestatus down to one of two options.
- name: Set selinux permissive fact
set_fact:
selinux_permissive: "{{ sestatus_out.stdout|regex_search('Current mode.*(permissive|enforcing)')|regex_search('(permissive|enforcing)') }}"
when: ansible_os_family == "RedHat"
when: "islandora_build_base_box|bool == True and ansible_os_family == 'RedHat'"

# Change Selinux to permissive
- name: change selinux enforcement to permissive
command: setenforce permissive
when: ansible_os_family == "RedHat" and disable_selinux and selinux_permissive == "enforcing"
when: "ansible_os_family == 'RedHat' and disable_selinux and selinux_permissive == 'enforcing' and islandora_build_base_box|bool == True"

# Check if we may be re-running
- name: Check for possible re-run
stat:
path: "{{ drupal_composer_install_dir }}/web/sites/default/"
register: defaultdir_exists
# if we are re-running, change the perms on the default dir so composer
# doesn't error out.
- name: Set writable perms on the default/ directory
file:

# if we are re-running, change the perms on the default dir so composer
# doesn't error out.
- name: Set writable perms on the default/ directory
file:
path: "{{ drupal_composer_install_dir }}/web/sites/default/"
mode: u+rw
recurse: yes
owner: "{{ ansible_user }}"
when: defaultdir_exists.stat.exists == true
when: defaultdir_exists.stat.exists == true
become: yes

- name: populate /etc/environment
Expand All @@ -90,6 +90,7 @@
regexp: "^{{ item.key }}="
line: "{{ item.key }}={{ item.value}}"
with_items: "{{ os_environment }}"
when: "islandora_build_base_box|bool == True"

# Include install profile-specific variables
- name: include Drupal install profile specific variables
Expand Down
20 changes: 13 additions & 7 deletions crayfish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@

roles:
- name: geerlingguy.repo-remi
when: ansible_os_family == "RedHat"
- geerlingguy.apache
- geerlingguy.php-versions
- geerlingguy.php
- geerlingguy.git
- geerlingguy.composer
- Islandora-Devops.crayfish
when: "ansible_os_family == 'RedHat' and islandora_build_box|bool == True"
- name: geerlingguy.apache # Include apache to get the handlers
- name: geerlingguy.php-versions
when: islandora_build_base_box|bool == True
- name: geerlingguy.php
when: islandora_build_base_box|bool == True
- name: geerlingguy.git
when: islandora_build_base_box|bool == True
- name: geerlingguy.composer
when: islandora_build_base_box|bool == True

- name: Islandora-Devops.crayfish
when: islandora_build_base_box|bool == False
7 changes: 4 additions & 3 deletions database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
become: yes

pre_tasks:
- set_fact:
- name: Just set the database type to mysql
set_fact:
islandora_db: 'mysql'
when: islandora_db is not defined
tags:
- always

roles:
- role: geerlingguy.mysql
when: islandora_db == 'mysql'
when: "islandora_build_base_box|bool == True and islandora_db == 'mysql'"
- role: geerlingguy.postgresql
when: islandora_db == 'pgsql'
when: "islandora_build_base_box|bool == True and islandora_db == 'pgsql'"
6 changes: 3 additions & 3 deletions inventory/vagrant/group_vars/alpaca.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---

# Comment out to download Alpaca from Maven
alpaca_from_source: yes
alpaca_version: 2.x
# Uncomment below 2 lines to build Alpaca from source.
# alpaca_from_source: yes
# alpaca_version: 2.x
alpaca_clone_directory: /opt/alpaca
alpaca_log_level: DEBUG

Expand Down
2 changes: 2 additions & 0 deletions playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@
- import_playbook: tomcat.yml
- import_playbook: crayfish.yml
- import_playbook: alpaca.yml
when: "islandora_build_base_box|bool == False"
- import_playbook: post-install.yml
when: "islandora_build_base_box|bool == False"
7 changes: 4 additions & 3 deletions post-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@
when: post_install_migrate_import_fits_tags

- name: Add vagrant user to webserver app user group
user: name={{ vagrant_user }}
group={{ webserver_app_user }}
append=yes
ansible.builtin.user:
name: "{{ vagrant_user }}"
groups: "{{ webserver_app_user }}"
append: yes

- name: Chown islandora core feature
file:
Expand Down
2 changes: 1 addition & 1 deletion roles/internal/Islandora-Devops.alpaca/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---

alpaca_from_source: no
alpaca_version: 2.0.0
alpaca_version: 2.2.0
alpaca_clone_directory: /opt/alpaca
alpaca_jar_path: "{{ alpaca_clone_directory }}/islandora-alpaca-app-{{ alpaca_version }}-all.jar"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
---

- name: Look for drush in expected path
ansible.builtin.stat:
path: "/usr/local/bin/drush"
register: drush_stat

- name: Use drush_path if defined
set_fact: openseadragon_drush_path="{{ drush_path }}"
when: drush_path != ''
when: drush_path is defined and drush_path != ''

- name: Use found drush instead
set_fact: openseadragon_drush_path="/usr/local/bin/drush"
when: drush_path is not defined and drush_stat.stat.exists

- include: install.yml
tags:
Expand Down
7 changes: 7 additions & 0 deletions roles/internal/Islandora-Devops.fcrepo/tasks/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,10 @@
owner: "{{ fcrepo_user }}"
group: "{{ fcrepo_user }}"
notify: restart tomcat9

- name: Add Fedora to tomcat override.conf
lineinfile:
path: "/etc/systemd/system/tomcat9.service.d/override.conf"
regex: "^ReadWritePaths={{ fcrepo_home_dir }}/$"
line: "ReadWritePaths={{ fcrepo_home_dir }}/"
insertafter: "[Service]"
6 changes: 4 additions & 2 deletions roles/internal/Islandora-Devops.fcrepo/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,19 @@
pkg:
- python3-psycopg2
- python3-mysqldb
- mysql-client
- mysql-client
state: present
update_cache: yes
cache_valid_time: 3600
when: ansible_os_family == "Debian"
become: true

- name: Install python dependencies
- name: Install python dependencies
yum:
name:
- python-psycopg2
- MySQL-python
- mysql
state: present
when: ansible_os_family == "RedHat"
become: true
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
dest: "/etc/systemd/system/tomcat9.service.d/override.conf"
content: |
[Service]
ReadWritePaths={{ fcrepo_home_dir }}/
ReadWritePaths={{ blazegraph_home_dir }}/data/
mode: '0644'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
- tomcat9
- tomcat9-config
- tomcat9-install

- include: "install-{{ ansible_os_family }}.yml"
when: "islandora_build_base_box is defined and islandora_build_base_box|bool == True"
tags:
- tomcat9
- tomcat9-install

- include_tasks: config.yml
when: "islandora_build_base_box is defined and islandora_build_base_box|bool == True"
tags:
- tomcat9
- tomcat9-config
10 changes: 5 additions & 5 deletions roles/internal/webserver-app/tasks/drupal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@


- name: Uninstall core search module
command: "{{ drush_path }} --root {{ drupal_core_path }} -y pm-uninstall search"
command: "{{ drush_path }} --root={{ drupal_core_path }} -y pm-uninstall search"
register: uninstall_search
changed_when: "'successfully uninstalled' in uninstall_search.stdout"
when: webserver_app_uninstall_search_module
Expand Down Expand Up @@ -93,22 +93,22 @@
when: webserver_app_do_content_sync_config or webserver_app_do_original_trusted_host_and_more

- name: Import features
command: "{{ drush_path }} --root {{ drupal_core_path }} -y fim islandora_core_feature,islandora_defaults"
command: "{{ drush_path }} --root={{ drupal_core_path }} -y fim islandora_core_feature,islandora_defaults"
when: webserver_app_feature_import_base

- name: Import search feature
command: "{{ drush_path }} --root {{ drupal_core_path }} -y fim islandora_search"
command: "{{ drush_path }} --root={{ drupal_core_path }} -y fim islandora_search"
when: webserver_app_feature_import_search

# Set Matomo Settings
- name: Set Matomo site id.
command: "{{ drush_path }} --root {{ drupal_core_path }} -y config-set matomo.settings site_id 1"
command: "{{ drush_path }} --root={{ drupal_core_path }} -y config-set matomo.settings site_id 1"
register: set_matomo_site_id_config
changed_when: "'Do you want to update site_id' in set_matomo_site_id_config.stdout"
when: webserver_app_configure_matomo

- name: Set Matomo server url.
command: "{{ drush_path }} --root {{ drupal_core_path }} -y config-set matomo.settings url_http http://localhost:8000/matomo/"
command: "{{ drush_path }} --root={{ drupal_core_path }} -y config-set matomo.settings url_http http://localhost:8000/matomo/"
register: set_matomo_server_url_config
changed_when: "'Do you want to update url_http' in set_matomo_server_url_config.stdout"
when: webserver_app_configure_matomo
Expand Down
4 changes: 2 additions & 2 deletions roles/internal/webserver-app/tasks/jwt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
register: drupal_jwt_config
# Workaround for error validating configurations in islandora_defaults.
- name: Enable Bartik
command: "{{ drush_path }} --root {{ drupal_core_path }} theme:enable bartik -y"
command: "{{ drush_path }} --root={{ drupal_core_path }} theme:enable bartik -y"

- name: Import JWT Config Into Drupal
command: "{{ drush_path }} --root {{ drupal_core_path }} config-import -y --partial --source={{ webserver_app_jwt_config_path }}"
command: "{{ drush_path }} --root={{ drupal_core_path }} config-import -y --partial --source={{ webserver_app_jwt_config_path }}"
when: drupal_jwt_config.changed is defined and drupal_jwt_config.changed
9 changes: 9 additions & 0 deletions roles/internal/webserver-app/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
---

- name: Look for drush in expected path
ansible.builtin.stat:
path: "/usr/local/bin/drush"
register: drush_stat

- name: Use found drush instead
set_fact: drush_path="/usr/local/bin/drush"
when: drush_path is not defined and drush_stat.stat.exists

- include: apache.yml
when: webserver_app_apache
tags:
Expand Down
6 changes: 3 additions & 3 deletions roles/internal/webserver-app/tasks/solr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
# Only tasks related to configuring search_api_solr are put here
# Solr server configuration should go into the solr playbook: https://github.com/Islandora-Devops/islandora-playbook/blob/dev/solr.yml
- name: Set default solr server host from hostvars
command: "{{ drush_path }} --root {{ drupal_core_path }} -y config-set search_api.server.default_solr_server backend_config.connector_config.host {{ hostvars[groups['solr'][0]].ansible_host }}"
command: "{{ drush_path }} --root={{ drupal_core_path }} -y config-set search_api.server.default_solr_server backend_config.connector_config.host {{ hostvars[groups['solr'][0]].ansible_host }}"
register: set_search_api_config_host
changed_when: "'Do you want to update' in set_search_api_config_host.stdout"

- name: Set default solr server to point to first core
command: "{{ drush_path }} --root {{ drupal_core_path }} -y config-set search_api.server.default_solr_server backend_config.connector_config.core {{ solr_cores[0] }}"
command: "{{ drush_path }} --root={{ drupal_core_path }} -y config-set search_api.server.default_solr_server backend_config.connector_config.core {{ solr_cores[0] }}"
register: set_search_api_config_core
changed_when: "'Do you want to update' in set_search_api_config_core.stdout"

- name: Create SOLR config.zip
command:
cmd: "{{ drush_path }} --root {{ drupal_core_path }} -y solr-gsc default_solr_server solr_config.zip {{ solr_version }}"
cmd: "{{ drush_path }} --root={{ drupal_core_path }} -y solr-gsc default_solr_server solr_config.zip {{ solr_version }}"
chdir: "{{ drupal_core_path }}"

Loading

0 comments on commit 79b24b1

Please sign in to comment.