One seriously major thing to note is that I don't recommend actually doing this. I'm doing it to shed some light on some of the things still going on in the development process and to highlight the ways in which you can get some visibility into the installation and monitoring of the service.
If you're interested in building and running your own development environment or service for real, I suggest starting by reading through Krishna Raman's article on creating a development environment using Vagrant and Puppet and the puppet script sources themselves to see what's involved. Finally there's a comprehensive document that describes the procedure with fewer warts.
Ingredients
As usual, I start with a clean minimal install of Fedora 18. In addition this time I also have a yum repository filled with a bleeding-edge build from source as I described previously. Finally I have a prepared MongoDB server waiting for a connection.I'm replacing my real URLs and access information with dummies for demonstration purposes.
- Yum repo URL
http://myrepo.example.com/origin-server
- MONGO_HOST_PORT="mydbhost.example.com:27017"
- MONGO_USER="openshift"
- MONGO_PASSWORD="dontuseme"
- MONGO_DB="openshift"
Preparation
Since I'm building my own packages from source and placing them in a Yum repository, I need to add that repo to the standard set. I'll add a new file to /etc/yum.repod.d referring to my yum server.
Even if you're building from your own sources, there are still some packages you need to get that aren't in either the stock Fedora repositories or in the OpenShift sources. These are generally packages with patches that are in the process of moving upstream or are in the acceptance process for Fedora. Right now a set is maintained by the OpenShift build engineers. I need to add the repo file for that too:
[origin-server] name=OpenShift Origin Server baseurl=http://myrepo.example.com/openshift-origin enable=1 gpgcheck=0
[origin-extras] name=Custom packages for OpenShift Origin Server baseurl=https://mirror.openshift.com/pub/openshift-origin/fedora-18/x86_64/ enable=1 gpgcheck=0
At this point you can install the
openshift-origin-broker
package.
yum install openshift-origin-broker ... urw-fonts.noarch 0:2.4-14.fc18 v8.x86_64 1:3.13.7.5-1.fc18 xorg-x11-font-utils.x86_64 1:7.5-10.fc18 Complete!
There are a set of Rubygems that are not yet packaged as RPMs. I need to install these as gems for now.
gem install mongoid Fetching: i18n-0.6.1.gem (100%) Fetching: moped-1.4.4.gem (100%) Fetching: origin-1.0.11.gem (100%) Fetching: mongoid-3.1.2.gem (100%) Successfully installed i18n-0.6.1 Successfully installed moped-1.4.4 Successfully installed origin-1.0.11 Successfully installed mongoid-3.1.2 3 gems installed Installing ri documentation for moped-1.4.4... Building YARD (yri) index for moped-1.4.4... Installing ri documentation for origin-1.0.11... Building YARD (yri) index for origin-1.0.11... Installing ri documentation for mongoid-3.1.2... Building YARD (yri) index for mongoid-3.1.2... Installing RDoc documentation for moped-1.4.4... Installing RDoc documentation for origin-1.0.11... Installing RDoc documentation for mongoid-3.1.2...
There are a number of gem version restrictions in the broker Gemfile which are not met by the current rubygem RPMs. I have to remove the version restrictions so that the broker application will use what is available. This risks breaking things due to interface changes, but will at least allow the broker application to start.
sed -i -f - <<EOF /var/www/openshift/broker/Gemfile /parseconfig/s/,.*// /minitest/s/,.*// /rest-client/s/,.*// /mocha/s/,.*// /rake/s/,.*// EOF
For some reason, even with the
--without
clause for :test
and :development
, bundle still wants the mocha
rubygem. This should not be required for production, but right now you need to install it so that the Rails application will start.yum install rubygem-mocha ... Installed: rubygem-mocha.noarch 0:0.12.1-1.fc18 Dependency Installed: rubygem-metaclass.noarch 0:0.0.1-6.fc18
Verifying The Dependencies
Now that all of the software dependencies have been installed (mostly by RPM requirements through Yum, and finally through gem requirements and some version tweaking of the Gemfile) I can check that all of them resolve when I start the application. Rails will call bundler when the application starts so I'll call it explicitly before hand. I'm only interested in the production environment, so I'll explicitly exclude development and test.
cd /var/www/openshift/broker bundle --local Using rake (0.9.6) Using bigdecimal (1.1.0) .... Using systemu (2.5.2) Using xml-simple (1.1.2) Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
If I try to start the rails console now, though, I'll be sad. It won't connect to the database.
Configure MongoDB access/authentication
The OpenShift broker is (right now) tightly coupled to MongoDB. Recently it switched to using the rubygem-mongoid ODM module (which is a definite plus if you have to work on the code).
The last thing I need to do before I can fire up the Rails console with the broker application is to set the database connectivity parameters. One side effect of using an ODM is that it establishes a connection to the database the moment the application starts.
NOTE: when this is done I will not have a complete working broker server. I still need to configure the other external services: auth, dns and messaging.
Set the values listed in the Ingredients into
/etc/openshift/broker.conf
./etc/openshift/broker.conf ... # Eg: MONGO_HOST_PORT="<host1:port1>,<host2:port2>..." MONGO_HOST_PORT="mydbhost.example.com:27017" MONGO_USER="openshift" MONGO_PASSWORD="dontuseme" MONGO_DB="openshift" MONGO_SSL="false"
...
Now I can try starting the rails console. It should connect to the mongodb and offer an irb prompt:
To verify the database connectivity, take a look at this recent blog post.
Next up is configuring each plugin, one by one.
Gist Scripts
I'm trying something new. Rather than including code snippets inline, I'm going to post them as Github Gist entries.
- Add Yum Repos - oo-add-repo.sh
- Fix broker requirements - oo-broker-fix-requirements.sh
Krishna also points out that a complete broker installation guide is here: http://openshift.github.com/origin/file.install_origin_manually.html
ReplyDeleteIt turns out that the bundle check with --without doesn't seem to work as listed. You have to manually install rubygem-mocha (which pulls in rubygem-metaclass). Then bundle --local will pass. Strangely, you can then REMOVE rubygem-mocha and rubygem-metaclass and bundle --local will STILL pass.
ReplyDelete