Skip to content

Instantly share code, notes, and snippets.

@seth-macpherson
Last active May 31, 2016 14:24
Show Gist options
  • Save seth-macpherson/55422518a22853358af2fe6ec5c19ded to your computer and use it in GitHub Desktop.
Save seth-macpherson/55422518a22853358af2fe6ec5c19ded to your computer and use it in GitHub Desktop.

Jenkins Installation

Create EC2 instance

  • Choose Amazon Linux AMI as it comes configured with a strong set of tools
  • Create security group with access to TCP on ports 22, 80, 8080, and 52698
  • Generate key-pair called jenkins -> download as jenkins.pem
    • move jenkins.pem into ~/.ssh
    • run chmod 400 on jenkins.pem to set correct permissions
  • Launch Instance
  • Locate public IP settings in AWS instance management console and copy to clipboard

Install Jenkins

  • Connect to instance via SSH ssh -i ~/.ssh/jenkins.pem [email protected] -R 52698:localhost:52698
  • sudo yum install -y git java-1.8.0-openjdk-devel
  • sudo yum update -y aws-cli
  • sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
  • sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
  • sudo yum install -y jenkins

Configure

Bot Account

Create bot user and login:

  • sudo useradd qs-jenkin-bot
  • sudo passwd qs-jenkin-bot
  • sudo su qs-jenkin-bot
  • cd ~
  • Edit /etc/sudoers and add this line below root ALL=(ALL) ALL qs-jenkin-bot ALL=(ALL:ALL) ALL

Install RVM

  • sudo \curl -sSL https://get.rvm.io | bash -s stable
  • echo "gem: --no-ri --no-rdoc" >> ~/.gemrc

Generate public key for Github

  • ssh-keygen
  • cat ~/.ssh/id_rsa.pub Copy the resulting output to your clipboard for later use

Jenkins Service

  • Open /etc/sysconfig/jenkins
  • Replace $JENKINS_USER="jenkins" with $JENKINS_USER="qs-jenkin-bot"
  • sudo chown -R qs-jenkin-bot:qs-jenkin-bot /var/lib/jenkins
  • sudo chown -R qs-jenkin-bot:qs-jenkin-bot /var/cache/jenkins
  • sudo chown -R qs-jenkin-bot:qs-jenkin-bot /var/log/jenkins
  • sudo service jenkins restart

Dependencies

Install all Rails dependencies
  • sudo yum update -y

  • sudo yum groupinstall -y 'Development Tools'

  • sudo yum groupinstall -y development-libs

  • This is a huge list - it's deliberate sudo yum install -y libffi-devel libyaml-devel gcc-c++ patch readline readline-devel zlib zlib-devel openssl-devel libxml2-devel libxslt-devel libcurl-devel make bzip2 autoconf automake libtool bison postgresql-devel postgresql postgresql-server postgresql-devel postgresql-contrib postgresql-docs ImageMagick-devel ImageMagick ruby-devel mysql postfix

Install Sphinx
  • sudo mkdir /var/installers
  • sudo chown -R qs-jenkin-bot:qs-jenkin-bot /var/installers
  • cd /var/installers
  • wget http://sphinxsearch.com/files/sphinx-2.2.5-release.tar.gz
  • tar xvfz sphinx-2.2.5-release.tar.gz
  • cd sphinx-2.2.5-release
  • ./configure --prefix=/usr
  • make
  • sudo make install
Install Redis
Install NodeJS & NPM
  • sudo yum install nodejs npm --enablerepo=epel
Install MySQL
  • sudo yum install mysql
  • sudo chkconfig mysqld on
  • sudo service mysqld start
Configure test/dev accounts

Login to mysql

  $> mysql -u root -p
  CREATE USER 'tester'@'%' IDENTIFIED BY 'testing123';
  CREATE USER 'app'@'%' IDENTIFIED BY 'EYSSSTS4';
  GRANT ALL PRIVILEGES ON *.* TO 'tester'@'%' WITH GRANT OPTION;
  GRANT ALL PRIVILEGES ON *.* TO 'app'@'%' WITH GRANT OPTION;
  // exit mysql
Initialize PostgreSQL

Edit /var/lib/pgsql9/data/pg_hba.conf and change this: "local all all ident" into "local all all trust"

sql -U postgres
postgres=# ALTER USER postgres WITH PASSWORD 'password';
postgres=# \q
Create Databases

rake db:create rake db:create_trove rake db:schema:load RAILS_ENV=test db:schema:load rake db:migrate mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql -p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment