Skip to content

Instantly share code, notes, and snippets.

@mandeepbal
Last active August 29, 2015 14:09
Show Gist options
  • Save mandeepbal/0e10413a66aeeb7a38ae to your computer and use it in GitHub Desktop.
Save mandeepbal/0e10413a66aeeb7a38ae to your computer and use it in GitHub Desktop.
manageiq install using ruby 2.0

Install ManageIQ from source

To get started developing ManageIQ, or to deploy on an OS other than CentOS or Red Hat Enterprise Linux (RHEL), there are a few steps to get started.

A lot of this has been automated in the ManageIQ kickstart file. Details on installing an image using a quickstart file are available from the Kickstart page on Fedora.

  1. For RHEL, make sure you have rhel-6-server-rpms channel enabled.
rhn-channel --add --channel=rhel-6-server-rpms --user=(your RHN login) --password=(password)
  1. As root, add the miqbuilder user

    chmod 777 /opt
    useradd miqbuilder
    echo "" >> /etc/sudoers

echo "" >> /etc/sudoers echo "miqbuilder ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers ```

  1. (Optional) For both RHEL and CentOS, download and install the epel (Extra Packages for Enterprise Linux) package

    yum -y install http://dl.fedoraproject.org/pub/epel/6Server/x86_64/epel-release-6-8.noarch.rpm
  2. Update the VM and add iptables rule

    yum update -y
    iptables -I INPUT -p tcp --dport 3000 -j ACCEPT
    service iptables save
    service iptables restart
  3. ManageIQ prerequisites are git, libxml2 and libxslt (including headers), postgresql, and memcached. sudo should be upgraded to the latest version. On RHEL and CentOS, install these packages:

    yum -y install git libxml2-devel libxslt libxslt-devel sudo
    yum -y install postgresql-server postgresql-devel memcached ruby-devel
  4. Start memcached

    service memcached start
    chkconfig memcached on
  5. Configure Postgres

    1. Initialize the database:

      chkconfig postgresql on
      service postgresql initdb
    2. You want to modify /var/lib/pgsql/data/pg_hba.conf,by commenting out everything and add a new line, but you can do that by running the command below as root:

      echo "local all all trust" > /var/lib/pgsql/data/pg_hba.conf
    3. You want to modify `/var/lib/pgsql/data/postgresql.conf``,by commenting out everything and add a new line, but you can do that by running the commands below as root

      echo "" >> /var/lib/pgsql/data/postgresql.conf
      echo "listen_addresses = '*'" >> /var/lib/pgsql/data/postgresql.conf
    4. Start the database:

      service postgresql start
    5. Log in as postgres, and generate test, production and development databases and the root user. Then assign the development database vmdb_development to root

      su - postgres
      for i in test production development;do createdb vmdb_$i;done
      psql -c "create role root login password 'smartvm'"
      psql -c "alter database vmdb_development owner to root"
      exit
  6. As user miqbuilder, set up the ManageIQ Ruby development environment.

    su - miqbuilder
    \curl -sSL https://get.rvm.io | bash
    . ~/.bash_profile
    rvm install 2.0.0
    gem install bundler -v "~>1.3"
  7. Clone the ManageIQ repo and install dependencies:

    cd /opt
    git clone https://github.com/ManageIQ/manageiq
    cd manageiq/vmdb
    bundle install --without qpid
    cd ..
    vmdb/bin/rake build:shared_objects
    cd vmdb
    bundle install --without qpid
  8. Ensure that ManageIQ is connecting to the right database. Edit the config/database.yml file. Add the root user for the vmdb_development database.

    cp config/database.pg.yml config/database.yml
    bin/rake db:migrate
    
    
  9. Add SSL support

mkdir ~/.ssl cd ~/.ssl openssl genrsa -out server.key 2048

#answer prompts when running the command below openssl req -new -key server.key -out server.csr

openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt ```

  1. Replace the contents of the rails file vi /opt/manageiq/vmdb/script/rails with the rails file below:
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.

require 'rack'
 
# Thin SSL workaround
module Rack
  module Handler
    class Thin
      def self.run(app, options={})
        app = Rack::Chunked.new(Rack::ContentLength.new(app))
        server = ::Thin::Server.new(options[:Host] || '0.0.0.0',
                                    options[:Port] || 3000,
                                    app)
        server.ssl = true
        server.ssl_options = {
			:private_key_file => '/home/miqbuilder/.ssl/server.key',
			:cert_chain_file => '/home/miqbuilder/.ssl/server.crt'
		}
	yield server if block_given?
        server.start
      end
    end
  end
end
# Workaround end

APP_PATH = File.expand_path('../../config/application',  __FILE__)
require File.expand_path('../../config/boot',  __FILE__)
require 'rails/commands'
  1. add the line below to vi /opt/manageiq/vmdb/config/environments/development.rb, before the 'end' line
config.force_ssl = true
  1. start the evm
cd /opt/manageiq/vmdb/
bin/rake evm:start

You should now be able to access the ManageIQ console at <IP_ADDRESS>:3000. The default username and password is username : admin and password : smartvm

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