Fog VSphere provider vm_clone request cannot use datastore in folder - ruby

The following code works great but only when the datastore specified is in the root of the datacenter. We organise our datastores in folders with the same name as the cluster they are associated with.
Tried putting a path in (e.g. dc_name/ds_name) but no good.
server=connection.vm_clone( 'datacenter' => 'EWL',
'template_path' => '.Templates/RHEL 6.2 x64',
'name' => 'new_vm_name',
'datastore' => 'E2-CL01-T2-OS-015',
'dest_folder' => 'Self-Service',
'transform' => 'sparse',
'power_on' => false )
Any clues?

Related

Deploy to multiple servers with different project roots using Laravel Envoy

When deploying to multiple servers using Laravel Envoy, how can you specify the project root per server?. The example provided in the documentation assumes that the project root is the same path for both servers.
Assume web-1 has project root as /var/html/www and web-2 has project root as /var/foo/bar. How can I access the different server's project root at runtime?
There are different ways to use Laravel Envoy for what you want to achieve. For example, based on your description, something like the following would work in your Envoy.blade.php file after running envoy run deploy.
#servers(['web-1' => '127.0.0.1', 'web-2' => '127.0.0.1'])
#setup
function logMessage($message) {
return "echo '\033[32m" .$message. "\033[0m';\n";
}
#endsetup
#story('deploy')
deploy-web-1
deploy-web-2
#endstory
#task('deploy-web-1', ['on' => ['web-1']])
cd /Users/Shared
{{ logMessage('🚀 Task complete for web-1') }}
#endtask
#task('deploy-web-2', ['on' => ['web-2']])
cd /Users/khill
{{ logMessage('🚀 Task complete for web-2') }}
#endtask
you have to try this
$webServerIps = [
'web-1' => 'xxx.xxx.xxx.xxx',
'web-2' => 'xxx.xxx.xxx.xxx',
];
#servers(array_merge($webServerIps, ['persistent' => 'xxx.xxx.xxx.xxx', 'worker'
=> 'xxx.xxx.xxx.xxx', 'local' => '127.0.0.1']))
i hope you got your solution .
also you can follow this link for more help

Hybridauth + composer: how to add custom providers

I'm converting a php project to use composer as dependency manager.
The dependencies are loaded via this line in my main script.
require 'vendor/autoload.php';
One of these dependencies is hybridauth (version 2.9). Since using Composer, it throws 'file not found' errors when looking for custom providers files.
For instance, my main controller calls Hybrid like this:
$config_file_path = dirname(__FILE__) .'/hybridauth/config.php';
$hybridauth = new Hybrid_Auth( $config_file_path );
Now, here is the config file. The provider i'm using is "Facebooktest".
Note that I had to specify the path via the [wrapper][path]; array key to get to the next error message.
return
array(
"base_url" => WWWROOT."/auth",
"providers" => array(
"Facebook" => array(
"enabled" => true,
"keys" => array("id" => "xxxxxxx", "secret" => "xxxxxxxx"),
"scope" => "email",
"trustForwarded" => false
),
"Facebooktest" => array(
"enabled" => true,
"keys" => array("id" => "xxxxxxx", "secret" => "xxxxxx"),
"scope" => "email",
"trustForwarded" => false,
"wrapper"=> array(
"class"=>'Hybrid_Providers_Facebooktest',
"path"=> './controllers/hybridauth/Hybrid/Providers/Facebooktest.php'
)
)
),
"debug_mode" => false,
"debug_file" => "",
);
The error message (with trace):
require_once(/path/to/composer-project/vendor/hybridauth/hybridauth/hybridauth/Hybrid/thirdparty/Facebook/autoload.php): failed to open stream: No such file or directory
[vendor/bcosca/fatfree/lib/base.php:2174] Base->error()
[controllers/hybridauth/Hybrid/Providers/Facebooktest.php:61] Base->{closure}()
[controllers/hybridauth/Hybrid/Providers/Facebooktest.php:61] require_once()
[vendor/hybridauth/hybridauth/hybridauth/Hybrid/Provider_Model.php:99] Hybrid_Providers_Facebooktest->initialize()
[vendor/hybridauth/hybridauth/hybridauth/Hybrid/Provider_Adapter.php:101] Hybrid_Provider_Model->__construct()
[vendor/hybridauth/hybridauth/hybridauth/Hybrid/Auth.php:278] Hybrid_Provider_Adapter->factory()
[vendor/hybridauth/hybridauth/hybridauth/Hybrid/Auth.php:230] Hybrid_Auth::setup()
[controllers/auth-action.get.php:19] Hybrid_Auth::authenticate()
I find it strange that I now need to modify paths inside the "vendor/hybridauth/" project. It defeats the purpose of using a dependency manager. Surely, I must be doing it wrong.
Can you advise?
Check my answer to another question here
If you have recently installed Hybridauth through composer you probably have downloaded v2.9.2, which contain a bug in their Facebook class that replace the vendor path from yours to hybridauth/vendor, causing such issue.
I suspect you created that Facebooktest class by copying their Facebook class and therefore sustained that error. Either update to their dev branch and copy that Facebook class, or simply use other provider class as template for your custom provider class.

Documentation for chef's attribute construct in metadata.rb file

I am new to chef and seeing the following code in metadata.rb file for a project handed over to me from someone.
attribute 'setup',
:required => 'required',
:default => 'internal',
:format => {
:category => '1.Global',
:order => 1,
:filter => {'all' => {'visible' => 'true'}},
:form => {'field' => 'select', 'options_for_select' => [
['External', 'external'], ['Internal','internal']
]
}
}
I have gone through both https://docs.chef.io/config_rb_metadata.html and
https://docs.chef.io/attributes.html but unable to understand most of the non-obvious constructs like category, order, filter, form etc.
Are these not part of the standard chef packages?
The metadata fields still exist but nothing in the Chef ecosystem ever used them (except maybe old versions of Rightscale but that's not really "Chef ecosystem" anymore). Because of this we remove most of the docs about the feature. You can delete at will most likely, unless you have custom tools that use the data.

Tomact7 chef cookbook ssl problems

I'm trying to set up a chef recipe for automatic deployment of my app over ssl with tomcat chef cookbook.
It works fine without ssl, but when I try to set the attributes for ssl support I'm getting error:
undefined method `truststore_password' for Custom resource tomcat_instance from cookbook tomcat.
My role:
name "myapp"
override_attributes ({
"java" => {
"jdk_version"=> "6"
},
"oracle" => {
"accept_oracle_download_terms" => true
},
"tomcat" => {
"base_version" => 7,
"java_options" => "${JAVA_OPTS} -Xmx128M -Djava.awt.headless=true",
"secure" => true,
"client_auth" => true,
"scheme" => "https",
"ssl_enabled_protocols" => "TLSv1",
"keystore_password" => "mypass",
"truststore_password" => "mypass",
"ciphers" => "SSL_RSA_WITH_RC4_128_SHA",
"keystore_file" => "/etc/tomcat7/client.jks",
"truststore_file" => "/etc/tomcat7/cert.jks"
}
})
run_list "recipe[java]", "recipe[tomcat]"
Maybe I'm missing something, because I can't find any good tutorials on how to do this I'm also using chef-solo with vagrant.
If you look at the Tomcat cookbook documentation, you will see the following regarding the truststore_password attribute:
node['tomcat']['truststore_password'] - Generated by the secure_password method from the
openssl cookbook; if you are using Chef Solo,
set this attribute on the node
Perhaps this means that you can not set the attribute in your role definition whilst using Chef Solo, and you have to manually add it to the node attributes JSON file.

create a virtual server under a specific subnet

I am using softlayer's ruby API, and i am trying to create a virtual server under a specific subnet in a VLAN and i couldnt find a way of doing it.
At the moment i am using the following json:
creation_hash = {
'complexType' => 'SoftLayer_Virtual_Guest',
'hostname' => XXX,
'domain' => XXXX
'datacenter' => { 'name' => #datacenter },
'startCpus' => sl_machine_type(#params['instance_type'])['cpu'],
'maxMemory' => sl_machine_type(#params['instance_type'])['memory'],
'hourlyBillingFlag' => true,
'blockDeviceTemplateGroup' => { 'globalIdentifier' => #params['image_id'] },
'localDiskFlag' => false,
'dedicatedAccountHostOnlyFlag' => true,
'primaryBackendNetworkComponent' => {
'networkVlan' => {
'id' => #private_vlan['id']
}
},
'networkComponents' => [{ 'maxSpeed' => 1000 }],
'privateNetworkOnlyFlag' => true
}
so when i choose a VLAN, it chooses a random subnet under that VLAN.
how can i specify a subnet ? i didnt find this option in the documentation.
Unfortunately it is not possible to specify which subnet a server should be provisioned into.
The provisioning system will choose an IP from the VLAN's primary subnet.
The wording is a bit vague in this article, but it states that IPs are automatically assigned. I will get it updated to state that it is not possible to request a specific block of IPs for the primary.
Adding an IP to the server from a secondary subnet directly after provisioning could be a possible work around. This could be done with a post install script or config manager(salt, chef, etc), if automation is needed. It would also allow you to control specifically which IPs are used for each server.

Resources