Custom resource to enable interaction with Actifio using Chef. Usual caveats: use at your own risk! Tested with SQL and Informix databases on Windows and Linux (specifically Suse Enteprise Linux)
At present, these resources will allow you to do the following :
- Authenticate to Actifio Sky Appliance (and receive a valid session ID back)
- Check if a host exists
- Configure ISCSI on windows or linux
- Install the actifio connector (windows or linux)
- Configure actifio (enable LUN rescan, configure Azure WAAGENT)
- Enable CBT
- Create a new host in Actifio
- Mount a database (informix and SQL DBs are tested with this cookbook)
Note that these resources require the Actifio user password and vendor key to be provided. These should not be stored in clear text (as seen in the examples below).
Add the below line to your cookbooks:
include_recipe 'actifio::default'
act_login 'Auth to Actifio' do
action :login
actifioHost 'actifio.myexample.com'
actifio_username 'admin'
actifio_password 'ShhItsSecret'
vendorkey 'xxxxx-xxxxx-xxxx-xxxx'
hostname Chef::Config[:node_name]
end
This will return a hostExists attribute : node.run_state['hostExists']
This can be used to build guards into other resources to ensure idempotency.
actifioHost: Hostname of actifio sky appliance
actifio_username: Actifio username
actifio_password: Actifio password
vendorkey: Actifio provided vendorkey
hostname: Hostname of the node you wish to interact with Actifio. This will also check the existance of this in the sky appliance.
act_install do
actifioHost 'actifio.myexample.com'
end
This will check the OS platform and install the right binary base on Linux or Windows.
actifioHost: Hostname of actifio sky appliance
Note: this was added as some cloud vm's will provide the same IQN for all deployed instances from a gold image. This will enable a random iqn to be created.
act_iscsi 'setup iscsi' do
only_if { !node.run_state['hostExists'] }
generateISCSI true
action :setup
end
generateISCSI: generate a random IQN
act_createhost Chef::Config[:node_name] do
only_if { !node.run_state['hostExists'] }
action :create
session_id lazy { node.run_state['sessionID'] }
actifioHost 'actifio.myexample.com'
enableCBT true
IQN lazy { node.run_state['initiator'] }
end
A couple of things about this resource...We are making the session id available to all resources as a run_state attribute. This ensures that this isnt stored as part of the nodes attributes. To access this in the compilation phase however, we need to use lazy evaluation (see https://docs.chef.io/resource_common.html#lazy-attribute-evaluation)
We do the same thing with the IQN.
actifioHost: Hostname of actifio sky appliance
enableCBT: Enable CBT on host
session_id: Active session id (this will be provided by lazy evaulation of node.run_state['sessionID']
)
IQN: IQN of host (if using IQN generation, use lazy evaluation of the node.run_state['initiator']
attribute)
act_mount do
host_id lazy { node['actifio']['host_id'] }
only_if { !node.run_state['hostExists'] }
action :mount
session_id lazy { node.run_state['sessionID'] }
appID '12345'
actifioHost 'actifio.myexample.com'
end
In this example we need to specify the appID for the application you want to mount.
act_mount do
host_id lazy { node['actifio']['host_id'] }
only_if { !node.run_state['hostExists'] }
action :mount
session_id lazy { node.run_state['sessionID'] }
parts 'MyDB'
windows_restore_option "mountpointperimage=C:\\MYDB\\mydb,provisioningoptions=<provisioningoptions><recover>true</recover><username>mydb</username><password>itsameactifio</password><dbname>MyDB</dbname><sqlinstance>#{node.name}</sqlinstance></provisioningoptions>"
appID '12345'
actifioHost node['actifio']['host']
end
For SQL server, we need to add more details. Specifically the parts we want to mount and the restore options xml.