Skip to content

Commit

Permalink
chef recipe to deploy the app
Browse files Browse the repository at this point in the history
  • Loading branch information
Baguage committed Feb 26, 2018
1 parent a0566e6 commit 22b30f9
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.exe binary
*.dll binary
*.dll binary
binaries/om/openMalaria binary
3 changes: 3 additions & 0 deletions binaries/om/readme.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
OpenMalaria v32
Works on RedHat 7/CentOS 7 (with gsl and xerces-c packages are dependencies)

This build was built with build-maia-release.sh
* from user vagrant
* at 2015-12-16
Expand Down
4 changes: 4 additions & 0 deletions chef/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Chef recipe to install OpenMalaria Portal

Usage:
sudo chef-client --local-mode chef.rb
88 changes: 88 additions & 0 deletions chef/chef.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package 'gsl'
package 'xerces-c'
package 'httpd'
package 'mod_wsgi'
package 'python-pip'
package 'git'
package 'vim'

bash 'postgresql respository' do
code <<-EOH
yum install -y https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-redhat96-9.6-3.noarch.rpm
EOH
not_if {::File.exist?('/etc/yum.repos.d/pgdg-96-redhat.repo')}
end

package 'postgresql96-server'
package 'postgresql96-devel'


bash 'postgresql initdb' do
code <<-EOH
/usr/pgsql-9.6/bin/postgresql96-setup initdb
EOH
not_if {::File.exist?('/var/lib/pgsql/9.6/data/')}
end

service 'postgresql-9.6' do
action [:enable, :start]
end

bash 'postgresql create user' do
code <<-EOH
sudo -u postgres sh -c 'createdb om'
sudo -u postgres psql -c "CREATE USER om WITH PASSWORD 'om'"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE \"om\" to om;"
EOH
ignore_failure true
end

file '/var/lib/pgsql/9.6/data/pg_hba.conf' do
owner 'postgres'
group 'postgres'
mode '600'
content <<-EOH
local all all ident
host all all all md5
EOH
end

directory 'opt/portal/aws.vecnet.org' do
owner 'root'
group 'apache'
recursive true
end

git '/opt/portal/aws.vecnet.org' do
group 'apache'
repository 'https://github.com/vecnet/om'
action :sync
end

file '/opt/portal/aws.vecnet.org/config_local.py' do
group 'apache'
mode '640'
content <<-EOH
import os
settings_module="website.settings.aws"
os.environ["SECRET_KEY"] = "lkl39#;l=01,<ML;lodfsd;lkOP(aa;dsf90adfsadfksldfjp90sdflsklilsdfslklkj"
os.environ["DATABASE_NAME"] = "om"
os.environ["DATABASE_USER"] = "om"
os.environ["DATABASE_PASSWORD"] = "om"
EOH
end

file '/opt/portal/aws.vecnet.org/django.log' do
group 'apache'
mode '660'
end

bash 'Install python packages' do
code 'pip install -r /opt/portal/aws.vecnet.org/requirements/aws.txt'
end

service 'httpd' do
action [:enable, :start]
end
29 changes: 29 additions & 0 deletions install_centos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

# http://stackoverflow.com/questions/18215973/how-to-check-if-running-as-root-in-a-bash-script
# EUID Expands to the effective user ID of the current user, initialized at shell startup.
# This variable is readonly.
if [ "${EUID}" -ne 0 ]
then echo "Please run as root"
exit
fi

yum install xerces-c gsl git nginx python-pip python-devel
# Repository for PostgreSQL 9.6
yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-redhat96-9.6-3.noarch.rpm
yum install postgresql96-devel postgresql96
/usr/pgsql-9.6/bin/postgresql96-setup initdb

sudo cp /var/lib/pgsql/9.6/data/pg_hba.conf /var/lib/pgsql/9.6/data/pg_hba.conf.bak
sudo sh -c 'echo "local all all ident" > /var/lib/pgsql/9.6/data/pg_hba.conf'
sudo sh -c 'echo "host all all all md5">> /var/lib/pgsql/9.6/data/pg_hba.conf'

systemctl enable postgresql-9.6
systemctl start postgresql-9.6

sudo systemctl start postgresql
sudo -u postgres sh -c 'createdb om'
sudo -u postgres psql -c "CREATE USER om WITH PASSWORD 'om'"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE \"om\" to om;"
sudo systemctl restart postgresql-9.6

0 comments on commit 22b30f9

Please sign in to comment.