diff --git a/Vagrantfile b/Vagrantfile index 9eefabb4..d18cf41b 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -121,6 +121,22 @@ Vagrant.configure(2) do |config| end end + config.vm.define "build_release", autostart: false do |build_release| + build_release.vm.box = "debian/contrib-jessie64" + build_release.vm.provider "virtualbox" do |vr| + vr.memory = 10240 + end + build_release.vm.network "forwarded_port", guest: 9130, host: 9130 + build_release.vm.network "forwarded_port", guest: 3000, host: 3000 + build_release.vm.provision "ansible" do |ansible| + ansible.playbook = "folio.yml" + ansible.groups = { + "vagrant" => ["build_release"], + "release" => ["build_release"] + } + end + end + config.vm.define "build_curriculum", autostart: false do |build_curriculum| build_curriculum.vm.box = "debian/contrib-jessie64" build_curriculum.vm.network "forwarded_port", guest: 9130, host: 9130 diff --git a/folio.yml b/folio.yml index f9031440..4649b419 100644 --- a/folio.yml +++ b/folio.yml @@ -1,7 +1,7 @@ --- # Ansible playbook to deploy Okapi and FOLIO modules # Provision a host as a backend FOLIO system -- hosts: stable:stable-backend:testing:snapshot:minimal +- hosts: stable:stable-backend:testing:snapshot:release:minimal roles: - common - postgresql @@ -29,6 +29,16 @@ - create-tenant-admin - tenant-admin-permissions +- name: Configure release build + hosts: release + roles: + - docker-engine + - okapi-pull + - tenant-data + - okapi-tenant-modules + - create-tenant-admin + - tenant-admin-permissions + # Sample data for stable - name: Load sample data for stable build hosts: stable:stable-backend @@ -92,6 +102,51 @@ - { load_endpoint: /vendor, fileglob: sample-data/vendors/*.json } - mod-auth-demo-users +# Sample data for release build +# Most of the reference data is loaded from folio-install Q2-2018 release +# There is a risk that the sample data not stored in folio-install will become incompatible +- name: Load sample data for release build + hosts: release + roles: + - role: module-sample-data + module_name: folio-install + repository: "https://github.com/folio-org/folio-install" + module_version: Q2-2018 + files: + - { load_endpoint: /classification-types, fileglob: reference-data/classification-types/*.json, dup_override: 400 } + - { load_endpoint: /contributor-name-types, fileglob: reference-data/contributor-name-types/*.json, dup_override: 400 } + - { load_endpoint: /contributor-types, fileglob: reference-data/contributor-types/*.json, dup_override: 400 } + - { load_endpoint: /identifier-types, fileglob: reference-data/identifier-types/*.json, dup_override: 400 } + - { load_endpoint: /instance-formats, fileglob: reference-data/instance-formats/*.json, dup_override: 400 } + - { load_endpoint: /instance-types, fileglob: reference-data/instance-types/*.json, dup_override: 400 } + - { load_endpoint: /loan-types, fileglob: reference-data/loan-types/*.json, dup_override: 400 } + - { load_endpoint: /location-units/institutions, fileglob: reference-data/location-units/institutions/*.json } + - { load_endpoint: /location-units/campuses, fileglob: reference-data/location-units/campuses/*.json } + - { load_endpoint: /location-units/libraries, fileglob: reference-data/location-units/libraries/*.json } + - { load_endpoint: /locations, fileglob: reference-data/locations/*.json } + - { load_endpoint: /material-types, fileglob: reference-data/material-types/*.json } + - { load_endpoint: /platforms, fileglob: reference-data/platforms/*.json, dup_override: 400 } + - { load_endpoint: /service-points, fileglob: reference-data/service-points/*.json } + - { load_endpoint: /loan-policy-storage/loan-policies, fileglob: reference-data/loan-policy-storage/loan-policies/*.json, dup_override: 500 } + - { load_endpoint: /loan-rules-storage, fileglob: reference-data/loan-rules-storage/*.json, http_method: PUT, updated_code: 204 } + - role: module-sample-data + module_name: mod-inventory-storage + repository: "https://github.com/folio-org/mod-inventory-storage" + duplicate_key_error: 400 + files: + - { load_endpoint: /instance-storage/instances, fileglob: sample-data/instances/*.json } + - { load_endpoint: /instance-storage/instances, fileglob: sample-data/instances/*.json } + - { load_endpoint: /holdings-storage/holdings, fileglob: sample-data/holdingsrecords/*.json } + - { load_endpoint: /item-storage/items, fileglob: sample-data/items/*.json } + - mod-inventory-mods + - mod-circulation-sample-data + - role: module-sample-data + module_name: mod-vendors + repository: "https://github.com/folio-org/mod-vendors" + files: + - { load_endpoint: /vendor, fileglob: sample-data/vendors/*.json } + - mod-auth-demo-users + # Set up stripes - name: Build stripes webpack, assign permissions hosts: stripes-build @@ -107,7 +162,7 @@ - tenant-admin-permissions - name: Build Stripes container - hosts: snapshot + hosts: snapshot:release roles: - stripes-docker diff --git a/group_vars/release b/group_vars/release new file mode 100644 index 00000000..1bcb1d0d --- /dev/null +++ b/group_vars/release @@ -0,0 +1,21 @@ +--- +# Variables for building a FOLIO release +okapi_pull: true +okapi_pull_timeout: 600 +auth_required: true +load_mods_larger: true +enable_okapi: true +deploy_url: https://cdn.rawgit.com/folio-org/folio-testing-platform/Q2-2018/okapi-install.json +enable_url: https://cdn.rawgit.com/folio-org/folio-testing-platform/Q2-2018/stripes-install.json + +# Variables for building UI +stripes_github_project: https://github.com/folio-org/folio-testing-platform +stripes_github_version: Q2-2018 +folio_npm_repo: npm-folioci +okapi_register_modules: no +okapi_enable_modules: no +platform_remove_lock: no +with_sourcemap: no + +# Metadata for CI build +version: Q2-2018 diff --git a/roles/okapi-tenant-modules/README.md b/roles/okapi-tenant-modules/README.md new file mode 100644 index 00000000..beae027e --- /dev/null +++ b/roles/okapi-tenant-modules/README.md @@ -0,0 +1,61 @@ +# okapi-tenant-modules + +Ansible role for deploying and enabling modules for a tenant based on an install.json file. + +## Prerequisites + +* A running Okapi system with: + * A database available for module data (you can use the `postgresql` role to provision a database and create an admin user). + * Registered module descriptors for all modules to be deployed. All module descriptors must contain a launch descriptor telling Okapi how to deploy the module (you can use the `okapi-pull` role to populate the module registry). + * The ability to deploy modules, either using `exec` or Docker (you can use the `docker-engine` role to install Docker on the target system). + * A tenant (you can use the `tenant-data` role to create a tenant). + +* An install file containing a JSON array of modules for posting to the `/_/proxy/tenants//install?deploy` endpoint for deployment. This can optionally point to a URL. A [sample file](roles/okapi-install.json) is available in the `files` directory of this role. + +* An install file containing a JSON array of modules for posting to the `/_/proxy/tenants//install` endpoint to enable the modules without deployment. This can optionally point to a URL. A [sample file](roles/stripes-install.json) is available in the `files` directory of this role. + +## Usage + +Invoke the role in a playbook, e.g.: + +```yaml +- hosts: my-folio-test + roles: + - postgresql + - docker-engine + - okapi-pull + - tenant-data + - okapi-tenant-modules +``` + +## Variables + +```yaml +--- +# defaults +create_db: yes +pg_admin_user: folio_admin +pg_admin_password: folio_admin +pg_host: "{{ ansible_default_ipv4.address }}" +pg_port: 5432 +pg_max_pool_size: 5 +module_database: okapi_modules +okapi_port: 9130 +okapi_url: "http://{{ ansible_default_ipv4.address }}:{{ okapi_port }}" +module_env: + - { name: db.host, value: "{{ pg_host }}" } + - { name: db.port, value: "{{ pg_port }}" } + - { name: db.database, value: "{{ module_database }}" } + - { name: db.username, value: "{{ pg_admin_user }}" } + - { name: db.password, value: "{{ pg_admin_password }}" } + - { name: db.maxPoolSize, value: "{{ pg_max_pool_size }}" } + +tenant: diku +deploy_timeout: 600 + +# Define one or more of these variables to post install JSON to Okapi. They are posted in the order listed here. +# deploy_file: +# deploy_url: +# enable_file: +# enable_url: +``` diff --git a/roles/okapi-tenant-modules/defaults/main.yml b/roles/okapi-tenant-modules/defaults/main.yml new file mode 100644 index 00000000..5e4cdc77 --- /dev/null +++ b/roles/okapi-tenant-modules/defaults/main.yml @@ -0,0 +1,27 @@ +--- +# defaults +create_db: yes +pg_admin_user: folio_admin +pg_admin_password: folio_admin +pg_host: "{{ ansible_default_ipv4.address }}" +pg_port: 5432 +pg_max_pool_size: 5 +module_database: okapi_modules +okapi_port: 9130 +okapi_url: "http://{{ ansible_default_ipv4.address }}:{{ okapi_port }}" +module_env: + - { name: db.host, value: "{{ pg_host }}" } + - { name: db.port, value: "{{ pg_port }}" } + - { name: db.database, value: "{{ module_database }}" } + - { name: db.username, value: "{{ pg_admin_user }}" } + - { name: db.password, value: "{{ pg_admin_password }}" } + - { name: db.maxPoolSize, value: "{{ pg_max_pool_size }}" } + +tenant: diku +deploy_timeout: 600 + +# Define one or more of these variables to post install JSON to Okapi. They are posted in the order listed here. +# deploy_file: +# deploy_url: +# enable_file: +# enable_url: diff --git a/roles/okapi-tenant-modules/files/okapi-install.json b/roles/okapi-tenant-modules/files/okapi-install.json new file mode 100644 index 00000000..2beb297d --- /dev/null +++ b/roles/okapi-tenant-modules/files/okapi-install.json @@ -0,0 +1,78 @@ +[ + { + "action": "enable", + "id": "mod-permissions-5.2.5-SNAPSHOT.22" + }, + { + "action": "enable", + "id": "mod-users-15.1.0-SNAPSHOT.36" + }, + { + "action": "enable", + "id": "mod-login-4.1.0-SNAPSHOT.12" + }, + { + "action": "enable", + "id": "mod-users-bl-3.0.0-SNAPSHOT.17" + }, + { + "action": "enable", + "id": "mod-authtoken-1.4.1-SNAPSHOT.21" + }, + { + "action": "enable", + "id": "mod-configuration-4.0.4-SNAPSHOT.36" + }, + { + "action": "enable", + "id": "mod-calendar-1.0.0-SNAPSHOT.37" + }, + { + "action": "enable", + "id": "mod-circulation-storage-5.3.0-SNAPSHOT.93" + }, + { + "action": "enable", + "id": "mod-inventory-storage-12.1.0-SNAPSHOT.128" + }, + { + "action": "enable", + "id": "mod-circulation-10.7.0-SNAPSHOT.160" + }, + { + "action": "enable", + "id": "mod-kb-ebsco-0.1.1-SNAPSHOT.112" + }, + { + "action": "enable", + "id": "mod-inventory-9.1.0-SNAPSHOT.88" + }, + { + "action": "enable", + "id": "mod-login-saml-1.1.0-SNAPSHOT.23" + }, + { + "action": "enable", + "id": "mod-notify-1.1.7-SNAPSHOT.46" + }, + { + "action": "enable", + "id": "mod-notes-2.1.1-SNAPSHOT.57" + }, + { + "action": "enable", + "id": "mod-codex-mux-2.2.2-SNAPSHOT.55" + }, + { + "action": "enable", + "id": "mod-vendors-1.0.1-SNAPSHOT.20" + }, + { + "action": "enable", + "id": "mod-codex-inventory-1.2.0-SNAPSHOT.53" + }, + { + "action": "enable", + "id": "mod-codex-ekb-1.0.1-SNAPSHOT.64" + } +] diff --git a/roles/okapi-tenant-modules/files/stripes-install.json b/roles/okapi-tenant-modules/files/stripes-install.json new file mode 100644 index 00000000..77ec66ac --- /dev/null +++ b/roles/okapi-tenant-modules/files/stripes-install.json @@ -0,0 +1,58 @@ +[ + { + "action": "enable", + "id": "folio_stripes-core-2.10.2000305" + }, + { + "action": "enable", + "id": "folio_calendar-1.0.100018" + }, + { + "action": "enable", + "id": "folio_checkin-1.1.100049" + }, + { + "action": "enable", + "id": "folio_checkout-1.1.4000158" + }, + { + "action": "enable", + "id": "folio_circulation-1.1.200089" + }, + { + "action": "enable", + "id": "folio_developer-1.3.100015" + }, + { + "action": "enable", + "id": "folio_eholdings-0.1.1000269" + }, + { + "action": "enable", + "id": "folio_inventory-1.0.3000205" + }, + { + "action": "enable", + "id": "folio_organization-2.2.100088" + }, + { + "action": "enable", + "id": "folio_plugin-find-user-1.1.100021" + }, + { + "action": "enable", + "id": "folio_requests-1.1.4000103" + }, + { + "action": "enable", + "id": "folio_search-1.1.100085" + }, + { + "action": "enable", + "id": "folio_users-2.12.2000354" + }, + { + "action": "enable", + "id": "folio_vendors-0.1.100016" + } +] diff --git a/roles/okapi-tenant-modules/tasks/main.yml b/roles/okapi-tenant-modules/tasks/main.yml new file mode 100644 index 00000000..e88a56b6 --- /dev/null +++ b/roles/okapi-tenant-modules/tasks/main.yml @@ -0,0 +1,97 @@ +--- +- name: Install prerequisites from apt + become: yes + apt: + name: "{{ item }}" + state: present + with_items: + - libpq-dev + - python-psycopg2 + - postgresql-client + when: create_db + +- name: Create modules db + postgresql_db: + login_host: "{{ pg_host }}" + login_user: "{{ pg_admin_user }}" + login_password: "{{ pg_admin_password }}" + name: "{{ module_database }}" + owner: "{{ pg_admin_user }}" + when: create_db + +- name: Set Okapi environment + uri: + url: "{{ okapi_url }}/_/env" + method: POST + body_format: json + headers: + Accept: application/json, text/plain + body: "{{ item|to_json }}" + status_code: 201 + register: set_okapi_env + changed_when: set_okapi_env.status == 201 + with_items: "{{ module_env }}" + +- name: Post install JSON from file for deployment + uri: + url: "{{ okapi_url }}/_/proxy/tenants/{{ tenant }}/install?deploy=true" + method: POST + body_format: json + headers: + Accept: application/json, text/plain + body: "{{ lookup('file', deploy_file) }}" + timeout: "{{ deploy_timeout }}" + register: deploy_from_file + changed_when: deploy_from_file.status == 200 + when: deploy_file|default(false) + +- name: Get install JSON from URL for deployment + uri: + url: "{{ deploy_url }}" + method: GET + register: deploy_json + when: deploy_url|default(false) + +- name: Post install JSON from URL for deployment + uri: + url: "{{ okapi_url }}/_/proxy/tenants/{{ tenant }}/install?deploy=true" + method: POST + body_format: json + headers: + Accept: application/json, text/plain + body: "{{ deploy_json.json }}" + timeout: "{{ deploy_timeout }}" + register: deploy_from_url + changed_when: deploy_from_url.status == 200 + when: deploy_url|default(false) + +- name: Post install JSON from file for enabling modules (no deployment) + uri: + url: "{{ okapi_url }}/_/proxy/tenants/{{ tenant }}/install" + method: POST + body_format: json + headers: + Accept: application/json, text/plain + body: "{{ lookup('file', enable_file) }}" + register: enable_from_file + changed_when: enable_from_file.status == 200 + when: enable_file|default(false) + +- name: Get install JSON from URL for enabling modules (no deployment) + uri: + url: "{{ enable_url }}" + method: GET + register: enable_json + when: enable_url|default(false) + +- name: Post install JSON from URL for enabling modules (no deployment) + uri: + url: "{{ okapi_url }}/_/proxy/tenants/{{ tenant }}/install" + method: POST + body_format: json + headers: + Accept: application/json, text/plain + body: "{{ enable_json.json }}" + register: enable_from_url + changed_when: enable_from_url.status == 200 + when: enable_url|default(false)