I need to write script that run on linux and do the below:
Create VM from template.
Set hostname and ip for the new VM based on user parameter.
I installed the perl sdk and run the below command
vmclone.pl --username "user" --password "passwd" --url ${VSPVERE_URL}/sdk/webService --vmhost myhost --vmname my_template --vmname_destination NEW_VM
My problem now is how I can connect via script to NEW_VM and update there the /etc/host file?
Thanks
As part of cloning a server using the VMware Perl API, there is an option to be able to change the server's hostname, independent of the new server's operating system. VMware tools must be installed on the template that you are cloning from. This is possible because VMware Tools knows how to customize the server.
See CloneVM_Task in the VMware docs.
For example, where $vmname is the hostname you want to give the server:
my $config_spec = VirtualMachineConfigSpec->new(
name => $vmname,
memoryMB => 1024,
numCPUs => 1);
my $clone_spec = VirtualMachineCloneSpec->new(
powerOn => 0,
template => 0,
config => $config_spec);
$vmtemplate->CloneVM_Task(
folder => $vm_folder_view,
name => $vmname,
spec => $clone_spec);
(Please note that there may be some required arguments that I have missed in my sample)
Related
I'm using vagrant to build a virtual environment. I have some question about provisioning with puppet. I understood that I can create modules on my own or to use existing modules (for example puppet forge ones). To use existing modules i follow this approach:
In Vagrant file I install modules I need
config.vm.provision :shell do |shell|
shell.inline = "mkdir -p /etc/puppet/modules;
puppet module install puppetlabs-postgresql"
and then in /puppet/manifest/site.pp
node 'db' {
class { 'postgresql::server':
listen_addresses => '*',
postgres_password => 'postgres',}
postgresql::server::db { 'music':
user => 'post',
password => postgresql_password('post', 'post'),}
postgresql::server::pg_hba_rule { 'allow application network to access database':
description =>....}}
I have many VM so I have to declare in this file the conf I need for each of them. Is this a valid way to proceed in using existing puppet modules? Or there is any kind of different pattern to follow?
If you have different VM to setup with different configuration, you should look at hiera to extract the config into a yaml and reference each node configuration into the puppet file.
I am attempting to deploy a war file (Oracle's APEX Listener) to a GlassFish 3.1.2.2 server deployed on an RHEL server (I am also seeing the same issues on an Ubuntu server at home).
I used the following command to create the domain:
$GLASSFISH_HOME/bin/asadmin create-domain --portbase 8100 myDomain
[I am also creating multiple domains on the same GlassFish server (one GF instance with multiple domains) using values of 8200, 8300, and 8400 for the portbase value and using different domain names.]
I then start the domain using:
$GLASSFISH_HOME/bin/asadmin start-domain myDomain
Next, I attempt to deploy the APEX.WAR file using:
$GLASSFISH_HOME/bin/asadmin deploy --contextroot apex apex.war
But, I get the following error:
Remote server does not listen for requests on [localhost:4848]. Is the server up? Unable to get remote commands. Closest matching local
command(s):
help Command deploy failed.
I have also used the following commands with the same result:
$GLASSFISH_HOME/bin/asadmin deploy apex.war
$GLASSFISH_HOME/bin/asadmin deploy --target myDomain apex.war
$GLASSFISH_HOME/bin/asadmin deploy --target domain apex.war
And I get the same error each time.
I can deploy the file using the admin gui, but this is for a customer installation and I would really like to do as much as possible from the bash shell script I have created.
I am also installing the Java 1.7.0_45 JDK and modifying the $GLASSFISH_HOME/config/asenv.conf file to include AS_JAVA=
The error is actually correct because the admin port is 8148. But, how do I get GlassFish to "know" to use 8148 instead of 4848.
I have also tried this by:
$GLASSFISH_HOME/bin/asadmin create-domain --adminport 8148
--domainproperties http.ssl.port=8152
but this gets the same results as above.
Thanks for reading this tome of a post and any info on how to fix this would be greatly appreciated!
/dave
You can specify the port to which asadmin should connect as a parameter like this:
asadmin --port 4949 start-domain
If this isn't enough you can even specify the hostname with --host.
Have a look at the official documentation to see all possible parameters.
i get the same error ,you should do like this:
$GLASSFISH_HOME/bin/asadmin --port 8148 deploy apex.war
and input username and password the default user is admin and password is adminadmin
good luck for you!
I'm a Vagrant n00b who's having issues getting Vagrant and Chef's knife command to play nice together as I'm setting up a pretty simple CentOS LAMP box using chef-solo.
Here's a quick rundown of ths issue:
I've created a basic Vagrantfile using the CentOS 6.3 w/ Chef base box on vagrantbox.es. You can see the basics in this gist.
I've downloaded all the cookbooks via knife cookbook site install nameofcookbook using a configuration that puts them in ./chef/cookbooks.
I've successfully run vagrant up to You can see the basics in this gist.
I've tested apache, php, etc. All good.
Now comes the trick: with the VM running, I run knife to add another package (in this case i3).
From here on, Vagrant fails to perform various tasks in the VM:
When I run vagrant provision I get an error like this
The chef binary (either `chef-solo` or `chef-client`) was not found on
the VM and is required for chef provisioning. Please verify that chef
is installed and that the binary is available on the PATH.
When I run vagrant halt I get an error that the ssh command exited with a non-zero error code.
I am able to run vagrant ssh however, and confirm that (a) chef-solo does, in fact, exist in the box and (b) I can shutdown via the commandline in the box.
When I run vagrant up I get an error like this:
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
mkdir -p /vagrant</li>
I'm stumped. I've had this happen on two boxes already, and I know that Knife and Vagrant should be able to play well together.
What am I doing wrong?
Any help much appreciated, I've very excited about digging into Vagrant!
chef.add_recipe "sudo"
Nuked your sudo file after the first run.
Add the appropriate json to your vagrant file for your vagrant user.
Something like:
config.vm.provision :chef_solo do |chef|
# add your recipes
# chef.add_recipe "foo"
# chef.add_role "bar"
chef.json = {
"authorization" => {
"sudo" => {
"users" => [ "vagrant" ],
"passwordless" => true,
}
}
}
end
I am creating two CentOS Boxes with a Vagrantfile, and using two unique host names for them, in their respectibe blocks
box1_config.vm.host_name = "Base1"
box1_config.vm.network:hostonly, "192.168.50.4"
box2_config.vm.host_name = "Base2"
box2_config.vm.network:hostonly, "192.168.50.5"
The OS starts without any issues, but I don't know what hostname to use to access them.
I tried following as argument to "vagrant ssh", but none worked and I get error: "This command requires a specific VM name to target in a multi-VM environment"
Tried with:
host_name
IP Address
The VM Name in VirtualBox
Any clues where I might be going wrong?
The argument for vagrant ssh is the symbol attached to the vm definition block. For example (from the vagrant docs):
Vagrant::Config.run do |config|
config.vm.define :web do |web_config|
web_config.vm.box = "web"
web_config.vm.forward_port 80, 8080
end
config.vm.define :db do |db_config|
db_config.vm.box = "db"
db_config.vm.forward_port 3306, 3306
end
end
you would do
vagrant ssh web
or
vagrant ssh db
since those are the names of the box as defined in the config.
HTH.
I'm new to Windows Azure. I'm trying to install a fresh MongoDB on Azure VM (virtual machine). I can log in to the machine. I read this article http://www.mongodb.org/display/DOCS/MongoDB+on+Azure+VM+-+Windows+Installer that describes how to set it up, but I'm confused about the command
.\deploy-mongo.ps1 <node-count> <dns-prefix> <image-name> <password> <location> <pub-settings-file-path> [replica-set-name]
I'm trying to install single MongoDB on azure in a Azure Windows VM that has 20GB harddisk drive.
What is ns-prefix, image-name? Can you give me an example of what that is?
My VM DNS is http://example23231.cloudapp.net. Is it the VM DNS or what?
The is that also VM image-name like examplevm1_2012_22.vhd?
To do what you want you would use
.\deploy-mongo.ps1 1 example23231 MyMongoImage MyPassword "West US" PathToPubSettings file
The above command will create a single Azure VM instance which is at example23231.cloudapp.net with RDP enabled. It will also download and install MongoDB as a windows service.
If you have an image with name MyMongoImage which is WinRM enabled it will be used. Else an image with that name is created in your default storage account for subsequent uses.
The default image is the standard Windows 2k8R2 image which is 30GB. Note the mongodb datapath is set to the OS drive by default