ansible/install_hyrax_dependencies.yaml
---
- name: install hyrax dependencies
hosts:
- "tag_AnsibleDesignation_OE24hyrax:&tag_AnsibleEnvironment_{{ ENV }}"
user: ec2-user
become: yes
vars:
hyrax_packages:
- httpd
- git
- redis
- libyaml-devel
- perl-IPC-Cmd
- ImageMagick
- gcc
- zlib-devel
- libffi-devel
- openssl-devel
- readline-devel
- gcc-c++
- libcurl-devel
- libxml2-devel
- httpd-devel
- apr-devel
- apr-util-devel
- java-11-amazon-corretto
- postgresql15
- postgresql-devel
gems_to_install:
- nokogiri
- base
- base64
profile_files:
- /root/.bash_profile
- /home/deploy/.bash_profile
- /home/ec2-user/.bash_profile
tasks:
- name: create deploy user
user:
name: deploy
groups:
- wheel
- name: add key to deploy user
authorized_key:
user: deploy
state: present
key: "{{ lookup('file', 'files/deploy.pub') }}"
- name: allow deploy user to not need pass
copy:
src: files/deploy-no-pass
dest: /etc/sudoers.d/deploy-no-pass
- name: install fedora repo
copy:
dest: /etc/yum.repos.d/fedora.repo
src: files/fedora.repo
- name: unpack and install libreoffie repos
unarchive:
src: https://ftp.wayne.edu/tdf/libreoffice/stable/24.8.1/rpm/x86_64/LibreOffice_24.8.1_Linux_x86-64_rpm.tar.gz
dest: /home/ec2-user/
remote_src: yes
- name: install libreoffice rpms
shell: yum install /home/ec2-user/LibreOffice_24.8.1.2_Linux_x86-64_rpm/RPMS/*.rpm -y
args:
creates: /opt/libreoffice24.8
- name: install package "{{ item }}
yum:
name: "{{ item }}"
state: latest
loop: "{{ hyrax_packages }}"
- name: create tomcat user
user:
name: tomcat
- name: Create a Tomcat Group
group:
name: tomcat
- name: Create a Tomcat Directory
file:
path: /opt/tomcat9
owner: tomcat
group: tomcat
mode: 0755
recurse: yes
- name: Check if we need to download tomcat
stat:
path: /opt/tomcat9/apache-tomcat-9.0.73
register: filesFound
- name: download & unarchive tomcat
unarchive:
src: https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.73/bin/apache-tomcat-9.0.73.tar.gz
dest: /opt/tomcat9
remote_src: yes
when: filesFound.stat.exists == False
- name: Change ownership of tomcat directory
file:
path: /opt/tomcat9
owner: tomcat
group: tomcat
mode: "u+rwx,g+rx,o=rx"
recurse: yes
state: directory
- name: create symbolic link for ease
file:
src: /opt/tomcat9/apache-tomcat-9.0.73
dest: /opt/tomcat
owner: tomcat
group: tomcat
state: link
- name: Copy Tomcat service from local to remote
copy:
src: files/tomcat.service
dest: /etc/systemd/system/
mode: 0755
- name: create fits folder
file:
path: /opt/fits
state: directory
owner: tomcat
group: tomcat
- name: Check if we need to download fits
stat:
path: /opt/fits/fits-env.sh
register: fitsfilesFound
- name: download & unarchive fits
unarchive:
src: https://github.com/harvard-lts/fits/releases/download/1.5.1/fits-1.5.1.zip
dest: /opt/fits
remote_src: yes
when: fitsfilesFound.stat.exists == False
- name: copy fits war file
copy:
src: files/fits-1.2.1.war
dest: /opt/tomcat9/apache-tomcat-9.0.73/webapps/fits.war
owner: tomcat
group: tomcat
- name: add fits home to catalina properties
blockinfile:
path: /opt/tomcat9/apache-tomcat-9.0.73/conf/catalina.properties
block: |
fits.home=/opt/fits
shared.loader=${fits.home}/lib/*.jar
- name: Start and Enable Tomcat 9 on sever
systemd:
name: tomcat
state: started
daemon_reload: true
- name: start and enable apache
service:
name: httpd
state: started
enabled: yes
- name: install rbenv
git:
repo: https://github.com/sstephenson/rbenv.git
dest: /usr/local/rbenv
- name: create plugin directory
file:
path: /usr/local/rbenv/plugins
state: directory
- name: install ruby-build plugins
git:
repo: https://github.com/sstephenson/ruby-build.git
dest: /usr/local/rbenv/plugins/ruby-build
- name: source rbenv
blockinfile:
path: "{{ item }}"
block: |
export RAILS_ENV=production bundle exec rails c
export RBENV_ROOT=/usr/local/rbenv
export PATH="$RBENV_ROOT/bin:$PATH"
export PATH="$RBENV_ROOT/bin:$FEDORA_HOME/client/bin:$MAGICK_HOME/bin:$LIBREOFFICE_PATH:$GHOSTSCRIPT_HOME/bin:$PATH"
eval "$(rbenv init -)"
loop: "{{ profile_files }}"
- name: install ruby 3.2.2
shell: |
source /root/.bash_profile
/usr/local/rbenv/bin/rbenv install 3.2.2
args:
creates: /usr/local/rbenv/versions/3.2.2
timeout: 1500
- name: set ruby version
shell: |
source /root/.bash_profile
rbenv global 3.2.2
- name: install passenger
shell: |
source /root/.bash_profile
/usr/local/rbenv/shims/gem install passenger
args:
creates: /usr/local/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/passenger-6.0*
- name: get passenger version
shell: source ~/.bash_profile; /usr/local/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/passenger-*/bin/passenger -v |cut -f3 -d' '
register: passenger_version
- name: place passenger.conf
template:
dest: /etc/httpd/conf.d/passenger.conf
src: files/passenger.conf.j2
force: true
- name: build apache passenger module
shell: |
source /root/.bash_profile
ruby /usr/local/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/passenger-6.0.*/bin/passenger-install-apache2-module -a
args:
creates: /usr/local/rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/passenger-6.0.*/buildout/apache2/mod_passenger.so
- name: create deployment directory
file:
path: /opt/dlp-selfdeposit
state: directory
owner: deploy
group: deploy
- name: drop in apache config
copy:
dest: /etc/httpd/conf.d/oe24.conf
src: files/oe24.conf
- name: edit mimetypes
lineinfile:
path: /etc/mime.types
line: "application/javascript js mjs"
regexp: "^applications/javascript*$"
- name: restart apache
service:
name: httpd
state: restarted
- name: deploy sidekiq service file
copy:
src: files/sidekiq.service
dest: /etc/systemd/system/sidekiq.service
owner: root
group: root
- name: create gem symlink
file:
dest: /usr/bin/gem
src: /usr/local/rbenv/shims/gem
state: link
- name: install gem "{{ item }}
gem:
name: "{{ item }}"
state: latest
loop: "{{ gems_to_install }}"
- name: fix base64w
shell:
cmd: source ~/.bash_profile; gem install --default -v=0.2.0 base64
args:
executable: /bin/bash
- name: install things for deploy user specifically
hosts:
- "tag_AnsibleDesignation_OE24hyrax:&tag_AnsibleEnvironment_{{ ENV }}"
user: deploy
tasks:
- name: install nvm
shell: curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
args:
executable: /bin/bash
creates: "/home/deploy/.nvm/nvm.sh"
- name: install node 16.20.2
shell: source /home/deploy/.bashrc; nvm install v16.20.2
- name: install yarn
shell: source /home/deploy/.bashrc; curl --compressed -o- -L https://yarnpkg.com/install.sh | bash