Public Repository

Last pushed: 2 years ago
Short Description
A Docker image containing everything needed to automate HPE OneView with Chef recipes.
Full Description

This docker container is built on the CentOS:Latest and comes with Chef and HPEs Chef provisioning driver allowing a simplified deployment and automation of HPE OneView and Synergy.

Requirements

  • Docker client
  • HPE OneView (Either with real hardware or the Data Centre Simulator)
  • IP connectivity to HPE OneView from the Docker client
  • Optional: Insight Control Server Provisioning

Usage

On the Docker client machine, ensure that the recipes and chef configuration (knife.rb) are placed into a directory to be mapped into the container e.g. /home/thebsdbox/chef.

Pull the oneview-chef container to your docker client:
docker pull thebsdbox/oneview-chef

You should now see this image on your local machine with the following command:
docker images

To run a chef recipe the following example command should be used:
docker run -it -v /home/thebsdbox/chef:/root/chef thebsdbox/oneview-chef chef-client -c /root/chef/knife.rb -z /root/chef/recipe.rb

The key parts to be aware of are -v /home/thebsdbox/chef:/root/chef, which is mapping the chef directory with our configuration and recipes to a directory inside the container, allowing chef to access these resources.
/home/thebsdbox/chef => becomes /root/chef.

Also the -c /root/chef/knife.rb which tells chef to use the configuration we've mapped into the container along with -z /root/chef/recipe.rb which is the recipe to run.

Example configuration (knife.rb)

current_dir = File.dirname(__FILE__)
log_level                :warn
log_location             STDOUT
node_name                "chef"
client_key               "#{current_dir}/chef.pem"
validation_client_name   "hpe-validator"
validation_key           "#{current_dir}/hpe-validator.pem"
chef_server_url          "https://localhost/organizations/hpe"
cookbook_path            ["#{current_dir}/../cookbooks"]


# Additional configuration for OneView and ICSP
#ICSP will be removed or commented for testing
# (knife.rb)

knife[:api_timeout]       = 50
knife[:oneview_url]        = 'https://192.168.0.90'
knife[:oneview_username]   = 'Administrator'
knife[:oneview_password]   = 'password'
knife[:oneview_ignore_ssl] = true # For self-signed certs

#knife[:icsp_url]           = 'https://192.168.0.91'
#knife[:icsp_username]      = 'Administrator'
#knife[:icsp_password]      = 'password123'
#knife[:icsp_ignore_ssl]    = true # For self-signed certs

#knife[:node_root_password] = 'password123'

# If your Chef server has self-signed certs:
verify_api_cert              false
ssl_verify_mode              :verify_none

Example recipe (allocate a profile)

require 'chef/provisioning'

with_driver 'oneview'

machine 'web01' do
  recipe 'my_server_cookbook::default'
  # Action to be performed on this server
  action :allocate
  # Options are :allocate :converge :destroy :stop
  machine_options :driver_options => {
      :server_template => 'WebServer',
      :host_name => 'chef-http-01',
      :server_location => 'Encl1, bay 11'
    }
  chef_environment '_default'
end

Example recipe (free the resource)

require 'chef/provisioning'

with_driver 'oneview'

machine 'web01' do
  recipe 'my_server_cookbook::default'
  # Action to be performed on this server
  action :destroy
  # Options are :allocate :converge :destroy :stop
  machine_options :driver_options => {
      :server_template => 'WebServer',
      :host_name => 'chef-http-01',
      :server_location => 'Encl1, bay 11'
    }
  chef_environment '_default'
end
Docker Pull Command
Owner
thebsdbox