Ansible role to perform an initial code deploy to a UCLA Library Samvera/Hyrax system using Capistrano
This role handles the first deployment of hyrax project code from a git repository to the rails application server.
Please take note of the following assumptions:
- the rails application server uses Red Hat Enterprise Linux 7 for the OS
- a Solr 7.X server is available with the index core created and project-specific configuration files installed in the core
- a Fedora 4.7.X repository server is available
- a MySQL database server is available with the project-specific database created and user account/privileges established
- a git repository is available containing the project's code
- project-specific variables for this role can be defined in a vars file with a name following the format of
projectname_envname.yml
- an example vars file is available in
vars/exampleproj_test.yml
- this vars file will contain sensitive information and should be encrypted with ansible-vault
- NOTE: if you choose not to use the vars file for including the variable definitions, they should be defined in the playbook file
- an example vars file is available in
Variables the need to be defined in the play file or the host inventory file - please note these should match the naming used for the vars file:
project_name
- defines the name of the rails application project - there is no default valueenv_name
- defines the name of the deploy environment (e.g. test, stage, prod) - there is no default value
Variables with default values that do not need to be defined in the project vars file:
capistrano_user
- defines the user account that will perform the code deploy - default isdeploy
capistrano_base
- defines the top-level directory where the project will be deployed - default is/opt
logrotate_files
- defies the list of files to include in the rails application logrotate configuration file - defaults areproduction.log
andsidekiq.log
Variables that do need to be defined in the project vars file:
rails_host_fqdn
- defines the fully qualified domain name of the rails app serverrails_db_adapter
- defines the type of database back-end (mysql2
orpostgresql
) - please note that currently this role only supports a db backend ofmysql2
rails_db_pool
- defines the number of connections to maintain to the databaserails_db_host
- defines the hostname of the database serverrails_db_name
- defines the name of the project's databaserails_db_user
- defines the user account with access to the databaserails_db_pass
- defines the password for the database userproject_default_admin_password
- defines the rails app admin password that will be created at first deploycontact_email_addr
- defines the email address for a project contactfedora_repo_url
- defines the HTTP url to the Fedora REST interfacefedora_repo_user
- defines the username for Fedora accessfedora_repo_password
- defines the password for the Fedora usersolr_index_url
- defines the HTTP url to the project's Solr coreredis_host
- defines the hostname of the server running Redisredis_port
- defines the port number where Redis is reachablesidekiq_num_threads
- defines the number of Sidekiq threads to maintainexternal_iiif_server_url
- (optional) defines the URL to an external IIIF image serveriiif_service_url
- (optional) defines the URL to a IIIF image serveriiif_manifest_url
- (optional) defines the URL endpoint for submitting/retrieving IIIF manifestscsv_file_path
- defines the filesystem path to the csv file containing file names of content to ingestgoogle_tag_manager_id
- (optional) - defines a Google Tag Manager key to be used within the server environmentrollbar_api_token
- (optional) - defines the api token to use with the Rollbar error reporting toolursus_host
- (optional) - defines the url to the corresponding ursus serverfits_servlet_url
- (optional) - defines the URL to a FITS endpoint if FITS is installed as a web service in Tomcatrecaptcha_site_key
- (optional) defines the site key to use with the recaptcha servicerecaptcha_secret_key
- (optional) defines the secret key to use with the recaptcha serviceemail_from_address
- defines the email address used in conjunction with the contact form where email will be sent fromemail_to_address
- defines the email address used in conjunction with the contact form where email will be sent toemail_server_url
- the url of the SMTP server email should be sentemail_port
- the port number of the SMTP email serverimport_file_path
- defines the filesystem path to the directory containing the objects to ingestgit_repo_url
- defines the HTTP url to the project's git repositorygit_repo_branch
- defines the name of the project's git branch to deployallow_web_crawl
- defines if search engines are allowed to crawl this site (yes or no)ssh_pub_keys
- defines the list of ssh public keys to install in the deploy user's authorized_keys file; this allows for other users to perform deploymentsuse_deflate_module
- defines if we should use the deflate_module in the Apache HTTPD vhost configuration (default isyes
)
An example vars file is available as a part of this role, named exampleproj_test.yml
Variables with default values that define if this deployment should use SSL For a local dev deployment, default values enable SSL and install self-signed certificates For a production install, defaults values are overriden by variables defined in host_vars
enable_ssl
- defines if this deloyment should use SSL (yes
orno
- default isyes
)ssl_cert_base_path
- defines the base path to the SSL certs and keyssl_cert_file_path
- defines the path to the SSL certsssl_key_file_path
- defines the path to the SSL private keyssl_files
self_signed
- defines if the certificates are self-signed (yes
orno
- default isyes
)crt
- contains the contents of the SSL public certificateinterm
- contains the contents of the SSL intermediate chain certificate (only needed if using a trusted cert)key
- contains the contents of the SSL private key
The following roles must be run on the rails application server prior to executing this deploy role:
uclalib_role_rhel7repos
uclalib_role_epel
uclalib_role_uclalibrepo
uclalib_role_samvera_basepackages
uclalib_role_java
uclalib_role_clamav
uclalib_role_pip
uclalib_role_imagemagick
uclalib_role_libreoffice
uclalib_role_ffmpeg
uclalib_role_fits
uclalib_role_ruby
uclalib_role_apache
uclalib_role_passenger
uclalib_role_nodejs
uclalib_role_yarn
uclalib_role_redis
---
- name: uclalib_capdeploy.yml
become: yes
become_method: sudo
hosts: test
user: ansible
vars:
project_name: "californica"
env_name: "test"
roles:
- { role: uclalib_role_rhel7repos }
- { role: uclalib_role_epel }
- { role: uclalib_role_uclalibrepo }
- { role: uclalib_role_samvera_basepackages }
- { role: uclalib_role_java, oracle_java_version: '1.8.0_181' }
- { role: uclalib_role_clamav }
- { role: uclalib_role_pip }
- { role: uclalib_role_imagemagick }
- { role: uclalib_role_libreoffice, libreoffice_version: '5.4.7' }
- { role: uclalib_role_ffmpeg, ffmpeg_version: '4.0.2' }
- { role: uclalib_role_fits, fits_version: '1.3.0' }
- { role: uclalib_role_ruby, ruby_version: '2.5.1' }
- { role: uclalib_role_apache }
- { role: uclalib_role_passenger, passenger_version: '5.3.3' }
- { role: uclalib_role_nodejs, nodejs_version: '8' }
- { role: uclalib_role_yarn }
- { role: uclalib_role_redis }
- { role: uclalib_role_samvera_capdeploy }
The uclalib_role_samvera_capdeploy
role can also be used to build a developers' box that mimics the environment used in production. To do this, slight changes are needed in the way that the role is run. The need for these changes is a result of having tagged tasks in the ansible_user_env_setup.yml
, capistrano_deploy.yml
, and dotenv_setup.yml
files, which are specific to a developers' box build. These are ignored for production builds.
To trigger the running of tasks that are only needed for a developers' box, supply the following two arguments when you run your Ansible playbook:
--skip-tags "always" --tags "untagged,development"
For a production build, you would omit these arguments and the tasks that are intended only for the developers' box would be, by default, skipped.
Running the build with the above skip-tags
and tags
arguments ensures that the project .env files for a developers' box are created, that the test database is created, and that the GitHub source is kept on the machine for the developer to use.