Installing Cloud Foundry BOSH Command Line Interface (CLI) on Centos 7

By Harikrishna Doredla

Cloud Foundry BOSH is an open source tool. BOSH Command Line Interface (CLI) is used to interact with the Director and to bootstrap new BOSH environments. The CLI is written in Ruby and is provided by the two gems:
bosh_cli contains main operator commands.
bosh_cli_plugin_micro contains bootstrapping commands.

Install the two Gems following the steps below: 

Steps:

  1. yum install gcc ruby ruby-devel mysql-devel postgresql-devel postgresql-libs sqlite-devel libxslt-devel libxml2-devel gcc-c++-4.8.3-9.el7.x86_64
  2. gem install yajl-ruby rake
  3. gem install nokogiri — –use-system-libraries
  4. gem install bosh_cli bosh_cli_plugin_micro –no-ri –no-rdoc
  5. Command to see the list of gem installed on your system:
    gem list –local
  6. Use the following command to consult the BOSH CLI help and to verify that CLI can run:
    $ bosh help or version
    bash: bosh: command not found
  7. if the response is as above resolve it as below:.
    Command to know the RubyGems Environment:

[root@ip-172-31-18-217 ~]# gem env

RubyGems Environment:

– RUBYGEMS VERSION: 2.0.14

– RUBY VERSION: 2.0.0 (2014-11-13 patchlevel 598) [x86_64-linux]

– INSTALLATION DIRECTORY: /usr/local/share/gems

– RUBY EXECUTABLE: /usr/bin/ruby

– EXECUTABLE DIRECTORY: /usr/local/bin

– RUBYGEMS PLATFORMS:

– ruby

– x86_64-linux

– GEM PATHS:

– /usr/local/share/gems

– /root/.gem/ruby

– /usr/share/gems

– GEM CONFIGURATION:

– :update_sources => true

– :verbose => true

– :backtrace => false

– :bulk_threshold => 1000

– REMOTE SOURCES:

– https://rubygems.org/

[root@ip-172-31-18-217 ~]#

  1. Note down EXECUTABLE DIRECTORY path and incorporate same in PATH environment variable.PATH variable value is to be included  in the EXECUTABLE DIRECTORYecho $PATH
    /sbin:/bin:/usr/sbin:/usr/bin
  2. How to add the EXECUTABLE DIRECTORY (/usr/local/bin) path to PATH environment variable in Permanent way (after reboot also).Add below line in  .bahrc file in your directory . .
    export PATH=$PATH:/usr/local/bin
    source .bashrc
    echo $PATH
    /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
  3. bosh version
    BOSH 1.2950.0

 Troubleshooting:

 Issue 1:

gem install bosh_cli bosh_cli_plugin_micro –no-ri –no-rdoc

Building native extensions.  This could take a while…

ERROR:  Error installing bosh_cli:

        ERROR: Failed to build gem native extension.

************************************************************************

IMPORTANT NOTICE:

Building Nokogiri with a packaged version of libxml2-2.9.2

with the following patches applied:

– 0001-Revert-Missing-initialization-for-the-catalog-module.patch

– 0002-Fix-missing-entities-after-CVE-2014-3660-fix.patch

Team Nokogiri will keep on doing their best to provide security

updates in a timely manner, but if this is a concern for you and want

to use the system library instead; abort this installation process and

reinstall nokogiri as follows:

gem install nokogiri — –use-system-libraries

[–with-xml2-config=/path/to/xml2-config]

[–with-xslt-config=/path/to/xslt-config]

 

If you are using Bundler, tell it to use the option:

bundle config build.nokogiri –use-system-libraries

bundle install

Note, however, that nokogiri is not fully compatible with arbitrary

versions of libxml2 provided by OS/package vendors.

************************************************************************

Extracting libxml2-2.9.2.tar.gz into tmp/x86_64-redhat-linux-gnu/ports/libxml2/2.9.2… OK

Running patch with /usr/local/share/gems/gems/nokogiri-1.6.6.2/ports/patches/libxml2/0001-Revert-Missing-initialization-for-the-catalog-module.patch…

Running ‘patch’ for libxml2 2.9.2… ERROR, review ‘/usr/local/share/gems/gems/nokogiri-1.6.6.2/ext/nokogiri/tmp/x86_64-redhat-linux-gnu/ports/libxml2/2.9.2/patch.log’

…………………………………

…………………………………..

to see what happened.

*** extconf.rb failed ***

Gem files will remain installed in /usr/local/share/gems/gems/nokogiri-1.6.6.2 for inspection.

Results logged to /usr/local/share/gems/gems/nokogiri-1.6.6.2/ext/nokogiri/gem_make.out

Resolution:  gem install nokogiri — –use-system-libraries 

Issue2:

gem install bosh_cli bosh_cli_plugin_micro –no-ri –no-rdoc

Fetching: eventmachine-1.0.7.gem (100%)

Building native extensions.  This could take a while…

ERROR:  Error installing bosh_cli_plugin_micro:

ERROR: Failed to build gem native extension.

……………………………………………..

…………………………………………….

creating Makefile

make “DESTDIR=”

g++ -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -DWITH_SSL -DBUILD_FOR_RUBY -DHAVE_RB_THREAD_BLOCKING_REGION -DHAVE_TBR -DHAVE_RUBY_THREAD_H DHAVE_RB_THREAD_CALL_WITHOUT_GVL -DHAVE_RB_THREAD_CALL_WITHOUT_GVL -DHAVE_INOTIFY_INIT -DHAVE_INOTIFY -DHAVE_WRITEV -DHAVE_WRITEV -DHAVE_RB_THREAD_FD_SELECT –

DHAVE_RB_THREAD_FD_SELECT -DHAVE_TYPE_RB_FDSET_T -DHAVE_RB_FDSET_T DHAVE_RB_WAIT_FOR_SINGLE_FD -DHAVE_RB_TIME_NEW -DOS_UNIX -DHAVE_EPOLL_CREATE -DHAVE_EPOLL –

DHAVE_CLOCK_GETTIME -DHAVE_CONST_CLOCK_MONOTONIC_RAW -DHAVE_CONST_CLOCK_MONOTONIC    -fPIC -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-

strong –param=ssp-buffer-size=4 -grecord-gcc-switches -mtune=generic  -m64 -o binder.o -c binder.cpp

make: g++: Command not found

make: *** [binder.o] Error 127

Gem files will remain installed in /usr/local/share/gems/gems/eventmachine-1.0.7 for inspection.

Results logged to /usr/local/share/gems/gems/eventmachine-1.0.7/ext/gem_make.out

37 gems installed

[root@ip-172-31-18-217 centos]#

Resolution:

          yum whatprovides “*/g++” and install  required cpp package.

Example:

          yum install gcc-c++-4.8.3-9.el7.x86_64

 Issue 3:

bosh help or bosh version

Failed to load plugin /usr/local/share/gems/gems/bosh_cli_plugin_micro-1.2950.0/lib/bosh/cli/commands/micro.rb: cannot load such file — rake/file_utils_ext

Resolution:

resolved the above issue by installing the rake gem package.

gem install rake