You are on page 1of 10

SAP BUSINESS ONE & CHEF

Automate the creation and setup of SAP Business One


environments using Chef
CONFIDENTIAL: RELEASED FOR PARTNERS
TABLE OF CONTENTS
SAP BUSINESS ONE & CHEF ......................................................................................................................... 1
INSTALL CHEF IN YOUR OWN INFRASTRUCTURE .................................................................................... 3
Chef Server ....................................................................................................................................................... 3
Chef Configuration Machine ........................................................................................................................... 4
Configuring Knife ............................................................................................................................................ 4
Adding a new node with knife ........................................................................................................................ 5
Recommendation ............................................................................................................................................. 5
Milestone .......................................................................................................................................................... 5
Install SAP Business One ............................................................................................................................... 5
Berkshelf .......................................................................................................................................................... 5
metadata.rb ...................................................................................................................................................... 5
Berksfile ............................................................................................................................................................ 6
recipes/default.rb ............................................................................................................................................. 6
attributes/default.rb ......................................................................................................................................... 6
Install and upload ............................................................................................................................................ 6
Execute a cookbook on a node ...................................................................................................................... 7
Install SAP Business One version of HANA ................................................................................................. 7
Berkshelf .......................................................................................................................................................... 7
metadata.rb ...................................................................................................................................................... 7
Berksfile ............................................................................................................................................................ 7
recipes/default.rb ............................................................................................................................................. 8
attributes/default.rb ......................................................................................................................................... 8
Install and upload ............................................................................................................................................ 8
Execute a cookbook on a node ...................................................................................................................... 8

2
Chef (www.chef.io) is a configuration management tool to automatically configure machines. It uses recipes
and cookbooks which represents the set of commands a machine needs to execute to get itself configured.
Chef is a great tool to automate the configuration of virtual machines in Clouds: AWS, Google Cloud, any
cloud infrastructure where Chef can be installed.

We created all the recipes and cookbooks to install SAP Business One test and demo environments:

• ‘business-one-chef-cookbook’ to install SAP Business One

• ’business-one-hana-chef-cookbook’ to install SAP Business One version of HANA

• Etc.

These recipes can be installed in an existing Chef infrastructure and enables the automatic configuration of
existing machines into a SAP Business One environment.

The difference between a cookbook and a recipe is quite simple – a cookbook is a collection of recipe. Let’s
take the example of a SAP Business One cookbook, there would be the recipe to install the server
component, the recipe to install the SLD, the recipe to install the SAP Business One client.

Regardless of the infrastructure you use, you will create a chef server with a chef repository, and in this
repository you will have all the cookbook necessary to install and configure the tools you need: SAP HANA,
Microsoft SQL, SAP Business One, etc. Chef provides a community based store with a lot of existing
cookbooks to reuse in your repositories: https://supermarket.chef.io

INSTALL CHEF IN YOUR OWN INFRASTRUCTURE


This documentation shows how to install Chef version 12.
What we’ll be doing is first to create a new Chef Server that will be doing all the work of configuring a
machine for us. We will then create a configuration machine we will use to configure and control our chef
server. Finally, we will “bootstrap” a new machine.

Chef Server
The chef server’s role is to store the configuration data and provide it to client machines. For this example,
we will be using an Ubuntu machine as the server.
• Download and install Chef Server: https://downloads.chef.io/
• Reconfigure the server:
$ sudo chef-server-ctl reconfigure

• Install the Chef Management Console


$ sudo chef-server-ctl install chef-manage
$ sudo chef-server-ctl reconfigure
$ sudo chef-manage-ctl reconfigure

• Create admin user:


chef-server-ctl user-create USERNAME FIRST_NAME LAST_NAME EMAIL PASSWORD

This will create a private key for the administrator user.


Example:
$ chef-server-ctl user-create aurelien Aurelien Leblond aurelien@my.domain
Avery5ecureP4ssword -f admin.pem

3
• Create an organization:
chef-server-ctl org-create SHORTNAME LONGNAME --association_user USERNAME
Example:
$ chef-server-ctl org-create myproject "My Automated Project" --
association_user aurelien -f myproject.pem

You can now check if the server is running ok by trying to access the following URL:
https://SERVERNAME_OR_IP/organizations/myproject

Chef Configuration Machine


This machine will be used to configure the chef server. We will as well use Ubuntu for this machine.
• Install git
$ sudo apt install git
• Create the folder chef-repo/.chef in your home
• Download and install the Chef Development Kit: https://downloads.chef.io/chefdk#/
• Copy the two previously created ‘.pem’ files to the configuration machine in chef-repo/.chef

Configuring Knife
From the Chef documentation (https://docs.chef.io/knife.html), knife is a command-line tool that provides an
interface between the local chef-repo and the Chef server.
• In the folder ‘~/chef-repo’, create the knife.rb file:
current_dir = File.dirname(__FILE__)
log_level :info
log_location STDOUT
node_name "name_for_workstation"
client_key "#{current_dir}/name_of_user_key"
validation_client_name "organization_validator_name"
validation_key "#{current_dir}/organization_validator_key"
chef_server_url
https://server_domain_or_IP/organizations/organization_name
syntax_check_cache_path "#{ENV['HOME']}/.chef/syntaxcache"
cookbook_path ["#{current_dir}/../cookbooks"]

• Following our example above the file will look as such:


current_dir = File.dirname(__FILE__)
log_level :info
log_location STDOUT
node_name "aurelien"
client_key "#{current_dir}/aurelien.pem"
validation_client_name "myproject_validation"
validation_key "#{current_dir}/myproject.pem"
chef_server_url https://myserver.my.domain/organizations/myproject
syntax_check_cache_path "#{ENV['HOME']}/.chef/syntaxcache"
cookbook_path ["#{current_dir}/../cookbooks"]

• From the chef-repo folder, run this command to test that knife can access the server:
knife client list

4
Adding a new node with knife
Now that we have a Chef Server and a machine to control it, we can add a new server to our infrastructure.
This process is called “bootstrapping”. The command to do so is:
knife bootstrap node_domain_or_IP [options]

For the sake of this example, we will bootstrap a final Suse machine using the root user with Chef 12:
$ knife bootstrap myubuntumachine.mydomain -x root -N SuseTesting –-
bootstrap-version 12

We will now bootstrap a Windows machine using a domain user:


$ knife bootstrap windows winrm 'mywindowsmachine.mydomain' -x
mydomain\\myuser -P 'Avery5ecureP4ssword' -N WindowsTesting --bootstrap-
version 12

Recommendation
We would recommand configuring the client machines for Chef to run as a service.
More information can be found on https://docs.chef.io/

Milestone
At that stage we have a running chef server, a machine to administrate our chef environment and we create
a Windows and Linux client machine ready to welcome SAP Business One.

Install SAP Business One

Berkshelf
Cookbooks rely on each other – if a software requires Microsoft .Net 4.5 to be installed to run, the cookbook
installing this software will depend on the cookbook installing Microsoft .Net 4.5.
Berkshelf is on the solution in Chef used to manage these dependencies for you. Without such a tool, you
would have to manually gather all the cookbook dependencies. But Berkshef can at runtime download the
relevant cookbooks from the Chef Supermarket (https://supermarket.chef.io/) or other community driven
repositories.
The file knife.rb is defining the location of the cookbooks in the setting ‘cookbook-path’. In our case, it will be
‘~/chef-repo/cookbooks’.

$ cd ~/chef-repo/cookbooks
$ chef generate cookbook b1_testenv

metadata.rb
This is the starting point, we need to modify the file b1_testenv/metadata.rb to specify which cookbooks we
will be using, in this case Microsoft SQL and SAP Business One.
name 'b1_testenv'
maintainer 'The Authors'
maintainer_email 'you@example.com'
license 'All Rights Reserved'
description 'Installs/Configures b1_testenv'
long_description 'Installs/Configures b1_testenv'
version '0.1.0'
chef_version '>= 12.1' if respond_to?(:chef_version)

depends 'sql_server', '~> 5.3.1'

5
depends 'b1'

Berksfile
We need to modify the b1_testenv/Berksfile file to specify where to get these cookbooks from.
In our example, Microsoft SQL cookbook will come from the Chef Supermarket:
https://supermarket.chef.io/cookbooks/sql_server
source 'https://supermarket.chef.io'

metadata

cookbook 'sql_server', '~> 5.3.1'


cookbook 'b1', git: 'https://github.com/SAP/business-one-chef-cookbook.git'

recipes/default.rb
Next we need to define which recipes from these previous cookbooks will run in our cookbook. To install
SAP Business One, we will first install Microsoft SQL Express 2008R2, then the SAP Business One Server
and finish with the Buisiness One client.
This is all defined in the recipes/default file.
include_recipe 'sql_server::server'
include_recipe 'b1::server'
include_recipe 'b1::client'

attributes/default.rb
The default attributes specifies the settings used by default by the cookbook. They can be overwritten later
on – but if some of them would not change for a whole infrastructure, they can be specified here.
default['sql_server']['instance_name'] = "MSSQLSERVER"
default['sql_server']['accept_eula'] = true
default['sql_server']['server_sa_password'] = "UnP4sswordC0mplique!"
default['sql_server']['update_enabled'] = false

default['b1']['archiverepo'] =
"http://somerepo.fake:8080/static/tec/b1-software/b1-patch/mssql/"
default['b1']['archive'] = "B192_PL08.zip"
default['b1']['sqlservertype'] = "6"
default['b1']['setupissdbservertype'] = "6"
default['b1']['sapassword'] = "UnP4sswordC0mplique!"
default['b1']['siteuserpassword'] = "MyPassword1"
default['b1']['installerfolder'] = "C:\\temp\\b1"

default['b1server']['targetdbversion'] = "920180"
default['b1server']['targetpatch'] = "8"

default['b1client']['dbversion'] = "920180"
default['b1client']['patch'] = "8"

Install and upload

Finally, we can ask Berkshelf to download all the necessary cookbooks and upload them to our Chef server.
You will see that Berkshelf will download much more cookbooks, for example the 7Zip cookbook necessary
to the SAP Business One one.

$ berks install

6
$ berks upload

Execute a cookbook on a node


In order to execute a cookbook (or series of cookbooks) in a node you need to add it to the run list of the
machine. The run list is simply the list of cookbooks the node needs to executre in order.
$ knife node run_list set WindowsTesting 'recipe[b1_testenv]'
$ knife winrm mywindowsmachine.mydomain chef-client -m -x mydomain\\myuser -P
'user_password'

Alternatively, once the run list is assigned to a machine, you can login to that machine and run `chef-client`
manually on that machine.

Install SAP Business One version of HANA

Berkshelf
If you need more information about Berkshelf, please review the „Install SAP Business One“ page.
Let’s generate a new cookbook for SAP Business One version of HANA.

$ cd ~/chef-repo/cookbooks
$ chef generate cookbook b1h_testenv

metadata.rb
This is the starting point, we need to modify the file b1_testenv/metadata.rb to specify which cookbooks we
will be using, in this case SAP HANA and SAP Business One version of HANA.
name 'b1h_testenv'
maintainer 'The Authors'
maintainer_email 'you@example.com'
license 'All Rights Reserved'
description 'Installs/Configures b1h_testenv'
long_description 'Installs/Configures b1h_testenv'
version '0.1.0'
chef_version '>= 12.1' if respond_to?(:chef_version)

depends 'hana', '~> 0.1.1'


depends 'b1h'

Berksfile
We need to modify the b1_testenv/Berksfile file to specify where to get these cookbooks from.
HANA cookbook will be downloaded automatically from the Chef Supermarket:
https://supermarket.chef.io/cookbooks/hana
source 'https://supermarket.chef.io'

metadata

cookbook 'hana', '~> 0.1.1'


cookbook 'b1h', git: 'https://github.com/SAP/business-one-hana-chef-cookbook'

7
recipes/default.rb
Next we need to define which recipes from these previous cookbooks will run in our cookbook. To install
SAP Business One, we will first install Microsoft SQL Express 2008R2, then the SAP Business One Server
and finish with the Buisiness One client.
This is all defined in the recipes/default file.
include_recipe 'sql_server::server'
include_recipe 'b1::server'
include_recipe 'b1::client'

attributes/default.rb
The default attributes specifies the settings used by default by the cookbook. They can be overwritten later
on – but if some of them would not change for a whole infrastructure, they can be specified here.
default['hana']['installpath'] = "/usr/sap"
default['hana']['sid'] = "HA0"
default['hana']['instance'] = "00"
default['hana']['password'] = "Manager1"
default['hana']['syspassword'] = "Welcome1"

default['install']['files']['sapcar'] =
"http://somerepo.fake:8080/static/monsoon/hana/newdb/SAPCAR"
default['install']['files']['hanadb'] =
"http://somerepo.fake:8080/static/monsoon/hana/newdb/1.0.122_05/SAP_HANA_DATA
BASE100_122_05_Linux_on_x86_64.SAR"
default['install']['files']['hanaclient'] =
"http://somerepo.fake:8080/static/monsoon/hana/newdb/1.0.122_05/SAP_HANA_CLIE
NT100_122_05_Linux_on_x86_64.SAR"

default['b1h']['targetdbversion'] = "920181"
default['b1h']['targetbranch'] = "SMP"
default['b1h']['targetpatch'] = "8_HF2"
default['b1h']['additional_repo'] =
"http://somerepo.fake:8080/InstallationFiles/yast-repo/suse/11/rpm/x86_64/"
default['b1h']['siteuserpassword'] = "busmb"
default['b1h']['systempassword'] = "Welcome1"
default['b1h']['is_multispan_archive'] = false
default['b1h']['archiverepo'] =
"http://somerepo.fake:8080/static/tec/b1-software/b1-patch/hana/"
default['b1h']['archive'] = "B1H92_PL08_HF2.zip"
default['b1h']['componentrepo'] =
"htto://somerepo.fake:8080/TECRepo_B1Components/"

Install and upload

Finally, we can ask Berkshelf to download all the necessary cookbooks and upload them to our Chef server.
You will see that Berkshelf will download much more cookbooks, for example the 7Zip cookbook necessary
to the SAP Business One one.

$ berks install
$ berks upload

Execute a cookbook on a node


In order to execute a cookbook (or series of cookbooks) in a node you need to add it to the run list of the
machine. The run list is simply the list of cookbooks the node needs to executre in order.

8
$ knife node run_list set SuseTesting 'recipe[b1_testenv]'
$ knife ssh name:SuseTesting "sudo chef-client"

Alternatively, once the run list is assigned to a machine, you can login to that machine and run `chef-client`
manually on that machine.

9
sappartneredge.com

© 2017 SAP SE or an SAP affiliate company. All rights reserved.


No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP SE or an SAP affiliate company.

The information contained herein may be changed without prior notice. Some software products marketed by SAP SE and its distributors contain proprietary software components of other software vendors.
National product specifications may vary.

These materials are provided by SAP SE or an SAP affiliate company for informational purposes only, without representation or warranty of any kind, and SAP or its affiliated companies shall not be liable
for errors or omissions with respect to the materials. The only warranties for SAP or SAP affiliate company products and services are those that are set forth in the express warranty statements
accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.

In particular, SAP SE or its affiliated companies have no obligation to pursue any course of business outlined in this document or any related presentation, or to develop or release any functionality
mentioned therein. This document, or any related presentation, and SAP SE’s or its affiliated companies’ strategy and possible future developments, products, and/or platform directions and functionality are
all subject to change and may be changed by SAP SE or its affiliated companies at any time for any reason without notice. The information in this document is not a commitment, promise, or legal obligation
to deliver any material, code, or functionality. All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ materially from expectations. Readers are
cautioned not to place undue reliance on these forward-looking statements, and they should not be relied upon in making purchasing decisions.

SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP SE (or an SAP affiliate company) in Germany and other
countries. All other product and service names mentioned are the trademarks of their respective companies. See http://www.sap.com/corporate-en/legal/copyright/index.epx for additional trademark
information and notices.

You might also like