Cookbook that keeps the common utilities.
- Linux YUM Repository - An onsite linux YUM Repsoitory is required.
- ibm_cloud_utils_cpuno - Check available number of CPUs.
- ibm_cloud_utils_freespace - Check free space under a path.
- ibm_cloud_utils_supported_os_check - Verify whether pattern is supported on the operating system of the vm.
- ibm_cloud_utils_ibm_cloud_yum - Install both 32-bit and 64-bit versions of a package in one yum command.
- ibm_cloud_utils_im_repo - Check if a package exists in IM repository
- ibm_cloud_utils_increasepagefilesize - Increase the Pagefile size in MB by value passed as an argument
- ibm_cloud_utils_lvm_logical_volume - Create a logical volume if the VG has enough free space.
- ibm_cloud_utils_lvm_physical_volume - Create a physical volume assuming that the specified disk is available on the VM.
- ibm_cloud_utils_lvm_volume_group - Create a volume group using an existing physical volume
- ibm_cloud_utils_ram - Check available RAM in MBs.
- ibm_cloud_utils_selinux - Enables or disabled SELinux.
- ibm_cloud_utils_ssh_util - Resource for either executing a command over SSH or copying a TEXT!!!!1111 file over SSH
- ibm_cloud_utils_sw_repo - Check if a package exists in software repository
- ibm_cloud_utils_tar - Create tar archive
- ibm_cloud_utils_unpack - Get a packed file (zip, tar, tar.gz, tar.bz2, tgz, Z) over HTTP, FTP or local file system and unpacks it into the target_dir.
- ibm_cloud_utils_webdav - Used to upload/download files to/from WeDAV server
- ibm_cloud_utils_zip - Create zip archive on Windows
- ibm_cloud_utils_ibm_cloud_sysctl - Apply or remove sysctl parameter on linux
- ibm_cloud_utils_hostsfile_update - Update the etc/hosts file of the vm.
Check available number of CPUs. If lower then required chef-client will exit with error_message. If continue is set to true the chef will continue to run.
- check: used to check available number of CPUs.
LWRP Attribute | Description | Default |
required |
Required number of CPUs |
|
error_message |
The error message used if the available number of CPUs is lower then required |
|
continue |
If **continue** is set to true the chef will continue to run. | false |
ibm_cloud_utils_cpuno 'check-number-of-cpus' do
required 2
continue true
action :check
error_message 'Please make sure you have at least 2 CPUs available'
end
Check free space under a path. If space is lower then required_space chef-client will exit with error_message. If continue is set to true the chef will continue to run.
- check: used to check free space under a path.
LWRP Attribute | Description | Default |
path |
|
|
required_space |
Required free space |
|
error_message |
The error message used if the free space is lower then required |
|
continue |
If **continue** is set to true the chef will continue to run. | false |
ibm_cloud_utils_freespace 'check-tmp-freespace' do
path '/tmp'
required_space 2048
continue true
action :check
error_message 'Please make sure you have at least 2GB free space under /tmp'
end
Update the /etc/hosts file with hosts file information.
- updateshosts: Update the /etc/hosts file with hosts file information..
ibm_cloud_utils_hostsfile_update 'update_the_etc_hosts_file' do
action :updateshosts
end
Validate whether pattern is supprted on the operating system of the vm as a Pre-Requisites check before install.
- check: used to opearting system support.
LWRP Attribute | Description | Default |
supported_os_list |
|
|
error_message |
The error message used if the free space is lower then required |
|
ibm_cloud_utils_supported_os_check 'check-supported-opeartingsystem-for-pattern' do
supported_os_list node['wasnd']['OS_supported']
action :check
error_message "Pattern is not supported on this opearting system"
end
Install both 32-bit and 64-bit versions of a package in one yum command.
- install: Default. Install packages.
- upgrade: Install packages and/or ensure that packages are the latest version.
- purge: Remove packages from your system
LWRP Attribute | Description | Default |
package_name |
The name of the package |
|
version |
The version of the package |
|
options |
One (or more) additional options that are passed to the command. |
|
ibm_cloud_utils_ibm_cloud_yum 'install package' do
package_name 'netpbm'
version '10.35.58-8.el5'
action :install
end
Check if a package exists in IM repository. It will automatically detect the type of IM repository: simple or composite.
- check_package: Default. Used to check if a package is included in Im repository
LWRP Attribute | Description | Default |
repository |
The URL of the IM repository | node['ibm']['im_repo'] |
im_repo_self_signed_cert |
If the IM repo is secured but it uses a self signed SSL certificate this should be set to "true" | node['ibm']['im_repo_self_signed_cert'] |
im_repo_user |
User used to access IM repo if this repo is secured and authentication is required This is not required if IM repo is not secured. | node['ibm']['im_repo_user'] |
secure_repo |
If the IM repo is public this should be set to "false" | 'true' |
offering_id |
Offering ID of the package. This is a mandatory attribute | 'true' |
offering_version |
Offering version of the package. If this is not provided this resource will try to find at least one package with the provided offering id. | nil |
ibm_cloud_utils_im_repo 'com.ibm.websphere.IHS.v85'
ibm_cloud_utils_im_repo 'Check package' do
offering_id 'com.ibm.websphere.IHS.v85'
action :check_package
end
ibm_cloud_utils_im_repo 'Check package' do
im_repo_self_signed_cert 'true'
offering_id 'com.ibm.websphere.IHS.v85'
offering_version '8.5.5000.20130514_1044'
action :check_package
end
Increase the Pagefile size in MB by value passed as an argument
- run: used to increase the Pagefile size
LWRP Attribute | Description | Default |
increment_size |
Pagefile size that will be added to the existing size |
|
ibm_cloud_utils_increasepagefilesize "Increment-Pagefile-Size" do
increment_size 256
action :run
end
Create a logical volume if the VG has enough free space. lv_size must be specified in this format . (e.g. 2G or 512M). The following values are supported for : k|K|m|M|g|G|t|T.
- create: used to create a logical volume
LWRP Attribute | Description | Default |
lv_name |
The name for the new logical volume. |
|
vg_name |
The name for the volume group. |
|
lv_size |
Gives the size to allocate for the new logical volume. |
|
filesystem |
Specify the type of filesystem to be built. |
|
mountpoint |
The directory (or path) in which the device is to be mounted. |
|
options |
An array or string that contains mount options. |
|
ibm_cloud_utils_lvm_logical_volume 'Creating logical volume' do
vg_name 'vgname'
mountpoint '/path/to/directory'
lv_name 'lvname'
filesystem 'ext4'
lv_size '1g'
options 'rw'
action :create
end
Create a physical volume assuming that the specified disk is available on the VM.
- create: used to create a physical volume
LWRP Attribute | Description | Default |
disk |
The name of the disk. |
|
ibm_cloud_utils_lvm_physical_volume 'Creating physical volume' do
disk 'sdb'
action :create
end
Create a volume group using an existing physical volume
- create: used to create a volume group
LWRP Attribute | Description | Default |
pv_name |
The name for the physical volume |
|
vg_name |
The name for the volume group. |
|
ibm_cloud_utils_lvm_volume_group 'Creating volume group' do
pv_name '/dev/sdb'
vg_name 'vgname'
action :create
end
Check available RAM in MBs. If lower then required chef-client will exit with error_message. If continue is set to true the chef will continue to run.
- check: used to check available RAM in MBs.
LWRP Attribute | Description | Default |
required |
Required RAM size in MBs |
|
error_message |
The error message used if the available RAM in MBs is lower then required |
|
continue |
If **continue** is set to true the chef will continue to run. | false |
ibm_cloud_utils_ram 'check-available-RAM' do
required 2048
continue true
action :check
error_message 'Please make sure you have at least 2048 MBs available'
end
Enables or disables SELinux.
- enforcing: Set selinux to enforcing
- enabled: used to enable selinux (it will be set to enforcing)
- permissive: Set selinux to permissive
- disabled: used to disable selinux
LWRP Attribute | Description | Default |
status |
This is currenlty not used! |
|
ibm_cloud_utils_selinux 'SELinux enabled' do
action: enforcing
end
ibm_cloud_utils_selinux 'SELinux disabled' do
action: disabled
end
Resource for either executing a command over SSH or copying a TEXT!!!!1111 file over SSH (No external net/scp required). Since only the included gems in chef client are used, this should be fairly portable and should work from Windows clients as well.
- copy: Default. Used to copy a file
- exec: Used to execute a command with conditions
LWRP Attribute | Description | Default |
server |
remote server |
|
user |
login user |
|
password |
the password to use to login |
|
source |
source file | nil |
target |
target file | nil |
command |
the command that will be executed on the remote host | nil |
only_if_check |
only if condition | nil |
not_if_check |
not if condition | nil |
ibm_cloud_utils_ssh_util "Copy a file" do
server 'some_server'
user 'root'
password 'passw0rd'
source '/tmp/some_local_file'
target '/tmp/some_remote_file'
action :copy
end
ibm_cloud_utils_ssh_util "Executing some command with conditions" do
server 'some_server'
user 'root'
password 'passw0rd'
command "touch /tmp/some_file"
only_if_check "ps -ef | grep -i java | grep -v grep"
not_if_check "ps -ef | grep -i whatever| grep -v grep"
action :exec
end
Check if a package exists in software repository.
- check_package: Default. Used to check if a package is included in software repository
LWRP Attribute | Description | Default |
repository |
The URL of the software repository | node['ibm']['sw_repo'] |
sw_repo_self_signed_cert |
If the software repo is secured but it uses a self signed SSL certificate this should be set to "true" | node['ibm']['sw_repo_self_signed_cert'] |
sw_repo_user |
User used to access software repo if this repo is secured and authentication is required. This is not required if software repo is not secured. | node['ibm']['sw_repo_user'] |
secure_repo |
If the software repo is public this should be set to "false" | 'true' |
sw_repo_path |
The repository path where the package should be located | '/' |
package |
The name of the package |
|
ibm_cloud_utils_sw_repo "DB2_Svr_10.5.0.8_Linux_x86-64.tar.gz" do
sw_repo_self_signed_cert 'true'
sw_repo_path '/db2/v105/base'
end
ibm_cloud_utils_sw_repo "check_package" do
package 'DB2_Svr_10.5.0.8_Linux_x86-64.tar.gz'
sw_repo_self_signed_cert 'true'
sw_repo_path '/db2/v105/base'
action :check_package
end
Resource for creating a tar archive
- tar: Default. Used to create a tar archive
LWRP Attribute | Description | Default |
source |
Source file |
|
target_tar |
Target tar |
|
ibm_cloud_utils_tar "Create_tar_file" do
source "/opt/product/log/install.log"
target_tar "/tmp/archive.tar"
end
Get a packed file (zip, tar, tar.gz, tar.bz2, tgz, Z) over HTTP, FTP or local file system and unpacks it into the target_dir. remove_local if set to true deletes the packed file from target_dir after unpacking. checksum is optional, but highly recommended for HTTP & FTP.
- unpack: Default. Used to download and unpack an archive.
LWRP Attribute | Description | Default |
source |
URL of the source file |
|
target_dir |
Target dirctory where the archive will be unpacked |
|
target_file |
Name of the target file | nil |
checksum |
The checksum of the source file | nil |
owner |
The user that owns of the target file | nil |
group |
The group that owns the target file | nil |
mode |
permissions for the target file | 0o755 |
remove_local |
Set this to true if you want to remove the archive from the local machine after unpack | 'false' |
secure_repo |
Flag for secure repository. If a public non-secure repository is used this should be set to 'false' | true |
repo_self_signed_cert |
If the software repostory uses a self signed SSL certificate this should be set to 'true' | 'false' |
vault_name |
Vault name. This vault should include the password of sw_repo_user | node['ibm_internal']['vault']['name'] |
vault_item |
Vault item name | node['ibm_internal']['vault']['item'] |
sw_repo_user |
User to be used to login to software repository | node['ibm']['sw_repo_user'] |
ibm_cloud_utils_unpack 'unpack-sccm-installer' do
source 'file://installersource'
target_dir expanddir
owner 'root'
group 'root'
mode '0755'
checksum node['ibm']['sccm']['installer_checksum']
remove_local true
end
Used to upload/download files to/from WebDAV server and to create or delete collections
- upload: Default. Used to upload a file to WebDAV server
- download: Used to download a file from WebDAV server
- delete: Used to delete a file from WebDAV server
- create_collection: Used to create a collection on the WebDAV server
- delete_collection: Used to delete a collection from the WebDAV server
LWRP Attribute | Description | Default |
webdav_server |
URL for WebDAV server | node['ibm']['sw_repo'] + '/sharedStorage' |
sw_repo_self_signed_cert |
If the WebDAV server is secured but it uses a self signed SSL certificate this should be set to "true" | node['ibm']['sw_repo_self_signed_cert'] |
sw_repo_user |
User used to access WebDAV server if this server is secured and authentication is required. This is not required if WebDAV server is not secured. | node['ibm']['sw_repo_user'] |
secure_repo |
If the WebDAV server is public this should be set to "false" | 'true' |
file |
The name of the file that will be uploaded/deleted to/from WebDAV server | '' |
download_path |
This is the local path where the file will be downloaded from WebDAV server | nil |
source_path |
This is the local path of the file that will be uploaded to WebDAV server | nil |
collection |
Collection that will be used to store the files on the WebDAV server | nil |
ibm_cloud_utils_webdav "create_collection_and_upload_file" do
file 'upload.txt'
source_path '/tmp'
collection 'stack1234'
sw_repo_self_signed_cert 'true'
secure_repo 'true'
action [:create_collection, :upload]
end
ibm_cloud_utils_webdav "new_collection" do
collection 'stack1234'
sw_repo_self_signed_cert 'true'
secure_repo 'true'
action :create_collection
end
ibm_cloud_utils_webdav "upload_file" do
file 'upload.txt'
collection 'stack1234'
source_path '/tmp'
sw_repo_self_signed_cert 'true'
secure_repo 'true'
webdav_server 'https://<hostname>:<port>/sharedStorage/'
action :upload
end
ibm_cloud_utils_webdav "download_file" do
file 'upload.txt'
collection 'stack1234'
download_path '/tmp'
sw_repo_self_signed_cert 'true'
secure_repo 'true'
action :download
end
ibm_cloud_utils_webdav "delete_file" do
file 'upload.txt'
collection 'stack1234'
source_path '/tmp'
sw_repo_self_signed_cert 'true'
secure_repo 'true'
action :delete
end
ibm_cloud_utils_webdav "delete_collection" do
collection 'stack1234'
sw_repo_self_signed_cert 'true'
secure_repo 'true'
action :delete_collection
end
Resource for creating a zip archive on Windows
- zip: Default. Used to create a zip archive on Windows
LWRP Attribute | Description | Default |
source |
Source file |
|
target_zip |
Target zip |
|
ibm_cloud_utils_zip "Create_zip_file" do
source "C:\product\log\install.log"
target_tar "C:\Temp\archive.zip"
end
- IBM::IBMHelper.check_free_space - Check free space under a path.
- IBM::IBMHelper.get_vault_secret - Get a sensitive data (password) from a Vault server, using an expiring session token
- Vault::Helper.chef_vault_item - Get a sensitive data (password) from a vault created on the chef server
Check free space under a path. If space is lower then required_space chef-client will exit with error_message. If continue is set to true the chef will continue to run.
ruby_block 'check-var-freespace' do
block do
IBM::IBMHelper.check_free_space(node, '/var', 1024)
end
end
Get a sensitive data (password) from a Vault server, using an expiring session token
user_password = IBM::IBMHelper.get_vault_secret('https://repo01.company.com:8200', '3d642e21-57f7-ccb1-5ebd-12169ac3f90b', 'dev/node1/admin')
template 'some_template' do
source 'some_template.erb'
variables(
UserPassword: user_password,
UserName: node['ms']['ftp_server']['name']
)
end
Get a sensitive data (password) from a vault created on the chef server
chef_vault = node['db2']['vault']['name']
encrypted_id = node['db2']['vault']['encrypted_id']
instance_password = chef_vault_item(chef_vault, encrypted_id)['db2']['instance']['instance']['instance_password']
chef_vault = node['db2']['vault']['name']
encrypted_id = node['db2']['vault']['encrypted_id']
instance_password = Vault::Helper.chef_vault_item(chef_vault, encrypted_id)['db2']['instance']['instance']['instance_password']
Apply or remove a sysctl parameter on Linux
- apply: Apply a sysctl parameter
- remove: Remove a sysctl parameter (should be applied after the system is rebooted)
LWRP Attribute | Description | Default |
key |
The sysctl key |
|
value |
The sysctl value (doesn't apply for remove action) |
|
sysctl_file |
The sysctl configuration file to use (defaults to /etc/sysctl.d/99-ibm_cloud_sysctl.conf) |
|
ibm_cloud_utils_ibm_cloud_sysctl "apply" do
key "net.core.rmem_default"
value "262144"
end
ibm_cloud_utils_ibm_cloud_sysctl "remove" do
action :remove
key "net.core.rmem_default"
end
Apply or remove a swap (file or device) on Linux
- create: Create a swap (file or device) to the currently used ones
- enable: Create a swap (file or device) and add it to fstab so it is used permanently
- remove: Remove a swap (file or device) from the currently used ones
- disable: Remove a swap (file or device) from the currently used ones and delete the fstab definition
LWRP Attribute | Description | Default |
swapfile |
The file to use for swap (a regular file or a block device file) |
|
size |
The size of the swapfile to create (doesn't apply to block devices) |
|
label |
The swap (file or device) label |
|
force |
Force the formatting of a block device (defaults to false) |
|
ibm_cloud_utils_ibm_cloud_swap "swap01" do
action :enable
swapfile "/swapfile01"
size "1024"
label "swap01"
end
ibm_cloud_utils_ibm_cloud_swap "swap01" do
action :disable
swapfile "/swapfile01"
size "1024"
label "swap01"
end
ibm_cloud_utils_ibm_cloud_swap "swap02" do
action :create
swapfile "/dev/loop0"
label "swap02"
force true
end
ibm_cloud_utils_ibm_cloud_swap "swap02" do
action :remove
swapfile "/dev/loop0"
label "swap02"
end
Manipulate a block device on Linux
- create: Creates a filesystem on a block device (no partitioning) and mounts it
- enable: Creates a filesystem on a block device, mounts it and sets it up in /etc/fstab
- remove: Unmounts a filesystem
- disable: Unmounts a filesystem and removes it's entry from /etc/fstab
LWRP Attribute | Description | Default |
device |
The block device that should be used |
|
fstype |
The filesystem type (ext2/3/4, xfs) |
|
label |
The filesystem label |
|
mountpoint |
The mountpoint directory |
|
options |
Nonstandard mounting options (defaults to 'defaults') |
|
force |
Force the formatting of a block device (defaults to false) |
|
ibm_cloud_utils_ibm_cloud_fs "oradata" do
action :create
device "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi0-0-0-1"
mountpoint "/oradata"
label "oradata"
fstype "ext4"
force true
end
ibm_cloud_utils_ibm_cloud_fs "oradata" do
action :enable
device "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi0-0-0-1"
mountpoint "/oradata"
label "oradata"
fstype "ext4"
force true
end
ibm_cloud_utils_ibm_cloud_fs "db2data" do
action :enable
device "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi0-0-0-2"
mountpoint "/db2data"
label "db2data"
fstype "xfs"
force true
end
ibm_cloud_utils_ibm_cloud_fs "db2data" do
action :disable
device "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi0-0-0-2"
mountpoint "/db2data"
label "db2data"
fstype "xfs"
force true
end
- Redhat
- Windows
No dependencies defined
Attribute | Description | Default |
node['ibm']['im_repo'] |
IBM Software Installation Manager Repository URL (https://:/IMRepo) |
|
node['ibm']['im_repo_password'] |
IBM Software Installation Manager Repository Password |
|
node['ibm']['im_repo_self_signed_cert'] |
IBM Software Installation Manager Repository Self Signed Certificate (True/False) | false |
node['ibm']['im_repo_user'] |
IBM Software Installation Manager Repository username | repouser |
node['ibm']['sw_repo'] |
IBM Software Repo Root (https://:) |
|
node['ibm']['sw_repo_auth'] |
IBM Software Software Manager Authentication Enabled | true |
node['ibm']['sw_repo_password'] |
IBM Software Repo Password |
|
node['ibm']['sw_repo_self_signed_cert'] |
IBM Software Software Manager Repository Self Signed Certificate (True/False) | false |
node['ibm']['sw_repo_user'] |
IBM Software Repo Username | repouser |
Default recipe (default.rb) Perform minimal product installation
Default recipe (gather_evidence.rb) Perform product verification steps
Default recipe (install.rb) Perform product installation steps
Default recipe (prereq.rb) Perform product prerequisite steps
Author:: IBM Corp (<>)
Copyright:: 2018, IBM Corp
License:: Copyright IBM Corp. 2016, 2018