Provision VM on EC2 using hammer cli

Hello,

I am new to foreman and hammer and have been trying the cli.
I want to provision a VM on EC2 using hammer cli. I have already added
compute resource for ec2.
The VM itself gets provisioned successfully. I can see it on the ec2
console. But two strange things are happenning -

  1. I am getting an error -
    Could not create the host:
    Failed to get IP for testhostonec14.com: undefined method
    `public_ip_addresses' for #<Fog::Compute::AWS::Server:0x0000000714b548>
  2. The instance starts running immediately on creation. I don't want it to
    run automatically. Only want to create the instance.

The cli that i am using is as follows -
hammer host create --compute-resource-id=1
–compute-attributes="flavor_id=t1.micro,managed_ip=2"
–volume="capacity=1G" --name="testhostonec14" --environment-id=1
–architecture-id=1 --domain-id=2 --puppet-proxy-id=1
–operatingsystem-id=2 partition-table-id=6
–interface="type=network,network=default"

I think all the ids are proper, but I am not really sure about the value of
managed_ip. On the we ui, the drop down for managed_ip has two entries -
Public and Private. I figured managed_ip should contain the number of the
required entry, though not sure if I am doing the correct thing.

Apart from that, though the instance shows as 'running' in the ec2 console,
i cannot ping to the machine.
I can assign an elastic ip to the instance, yet cannot ping to it using the
elastic ip.

Need help here. Please let me know if anymore information is required.

Best regards,
Abhijeet

Hello,
setting managed_ip to lowercase 'private' or 'public' should work. Try
if it helps.

Regards
Tomas

··· On 03/26/2014 11:30 AM, Abhijeet Joshi wrote: > Hello, > > I am new to foreman and hammer and have been trying the cli. > I want to provision a VM on EC2 using hammer cli. I have already added > compute resource for ec2. > The VM itself gets provisioned successfully. I can see it on the ec2 > console. But two strange things are happenning - > 1) I am getting an error - > Could not create the host: > Failed to get IP for testhostonec14.com: undefined method > `public_ip_addresses' for # > 2) The instance starts running immediately on creation. I don't want it > to run automatically. Only want to create the instance. > > The cli that i am using is as follows - > hammer host create --compute-resource-id=1 > --compute-attributes="flavor_id=t1.micro,managed_ip=2" > --volume="capacity=1G" --name="testhostonec14" --environment-id=1 > --architecture-id=1 --domain-id=2 --puppet-proxy-id=1 > --operatingsystem-id=2 partition-table-id=6 > --interface="type=network,network=default" > > I think all the ids are proper, but I am not really sure about the value > of managed_ip. On the we ui, the drop down for managed_ip has two > entries - Public and Private. I figured managed_ip should contain the > number of the required entry, though not sure if I am doing the correct > thing. > > Apart from that, though the instance shows as 'running' in the ec2 > console, i cannot ping to the machine. > I can assign an elastic ip to the instance, yet cannot ping to it using > the elastic ip. > > Need help here. Please let me know if anymore information is required. > > Best regards, > Abhijeet >

Re 1) What version of Foreman do you run? Your problem may be related to
Bug #4616: Problems provisioning hosts in EC2 with 1.4.1-2 - Foreman, it is fixed in Foreman 1.4.2.

Re 2) There is option --build=false in host create. Wouldn't that help?

Regards,
Martin

··· On 03/26/2014 11:30 AM, Abhijeet Joshi wrote: > Hello, > > I am new to foreman and hammer and have been trying the cli. > I want to provision a VM on EC2 using hammer cli. I have already added > compute resource for ec2. > The VM itself gets provisioned successfully. I can see it on the ec2 > console. But two strange things are happenning - > 1) I am getting an error - > Could not create the host: > Failed to get IP for testhostonec14.com: undefined method > `public_ip_addresses' for # > 2) The instance starts running immediately on creation. I don't want > it to run automatically. Only want to create the instance. > > The cli that i am using is as follows - > hammer host create --compute-resource-id=1 > --compute-attributes="flavor_id=t1.micro,managed_ip=2" > --volume="capacity=1G" --name="testhostonec14" --environment-id=1 > --architecture-id=1 --domain-id=2 --puppet-proxy-id=1 > --operatingsystem-id=2 partition-table-id=6 > --interface="type=network,network=default" > > I think all the ids are proper, but I am not really sure about the > value of managed_ip. On the we ui, the drop down for managed_ip has > two entries - Public and Private. I figured managed_ip should contain > the number of the required entry, though not sure if I am doing the > correct thing. > > Apart from that, though the instance shows as 'running' in the ec2 > console, i cannot ping to the machine. > I can assign an elastic ip to the instance, yet cannot ping to it > using the elastic ip. > > Need help here. Please let me know if anymore information is required. > > Best regards, > Abhijeet > -- > You received this message because you are subscribed to the Google > Groups "Foreman users" group. > To unsubscribe from this group and stop receiving emails from it, send > an email to foreman-users+unsubscribe@googlegroups.com > . > To post to this group, send email to foreman-users@googlegroups.com > . > Visit this group at http://groups.google.com/group/foreman-users. > For more options, visit https://groups.google.com/d/optout.

@Tomas.
That didnt work. Still getting the same problem.

··· On Thursday, March 27, 2014 2:44:30 PM UTC+5:30, Tomas Strachota wrote: > > On 03/26/2014 11:30 AM, Abhijeet Joshi wrote: > > Hello, > > > > I am new to foreman and hammer and have been trying the cli. > > I want to provision a VM on EC2 using hammer cli. I have already added > > compute resource for ec2. > > The VM itself gets provisioned successfully. I can see it on the ec2 > > console. But two strange things are happenning - > > 1) I am getting an error - > > Could not create the host: > > Failed to get IP for testhostonec14.com: undefined method > > `public_ip_addresses' for # > > 2) The instance starts running immediately on creation. I don't want it > > to run automatically. Only want to create the instance. > > > > The cli that i am using is as follows - > > hammer host create --compute-resource-id=1 > > --compute-attributes="flavor_id=t1.micro,managed_ip=2" > > --volume="capacity=1G" --name="testhostonec14" --environment-id=1 > > --architecture-id=1 --domain-id=2 --puppet-proxy-id=1 > > --operatingsystem-id=2 partition-table-id=6 > > --interface="type=network,network=default" > > > > I think all the ids are proper, but I am not really sure about the value > > of managed_ip. On the we ui, the drop down for managed_ip has two > > entries - Public and Private. I figured managed_ip should contain the > > number of the required entry, though not sure if I am doing the correct > > thing. > > > > Apart from that, though the instance shows as 'running' in the ec2 > > console, i cannot ping to the machine. > > I can assign an elastic ip to the instance, yet cannot ping to it using > > the elastic ip. > > > > Need help here. Please let me know if anymore information is required. > > > > Best regards, > > Abhijeet > > > > Hello, > setting managed_ip to lowercase 'private' or 'public' should work. Try > if it helps. > > Regards > Tomas > >

>>Re 1) What version of Foreman do you run? Your problem may be related to
Bug #4616: Problems provisioning hosts in EC2 with 1.4.1-2 - Foreman, it is fixed in Foreman 1.4.2.
Yes that was an older version. I tried this with 1.4.2. I also modified the
parameters a bit. Now that error is not shown. But I am getting another
error. Yet the machine is created in ec2 and it gets listed in hammer host
list command. But the error message is not desirable.

hammer -v --show-ids host create --compute-resource-id=1
–compute-attributes="flavor_id=t1.micro,managed_ip=public,image_id=ami-75342c01"
–volume="capacity=1G" --name="RHF6" --environment-id=1 --architecture-id=1
–domain-id=1 --puppet-proxy-id=1 --operatingsystem-id=2
–partition-table-id= --interface="type=network,network=default"
–build=false
[ERROR 2014-03-28 03:38:11 Exception] <NilClass> nil

>>Re 2) There is option --build=false in host create. Wouldn't that help?
Tried that. Doesnt help. The instance starts running immidiately.

Best regards,
Abhijeet

··· On Thursday, March 27, 2014 8:46:44 PM UTC+5:30, Martin Bačovský wrote: > > On 03/26/2014 11:30 AM, Abhijeet Joshi wrote: > > Hello, > > I am new to foreman and hammer and have been trying the cli. > I want to provision a VM on EC2 using hammer cli. I have already added > compute resource for ec2. > The VM itself gets provisioned successfully. I can see it on the ec2 > console. But two strange things are happenning - > 1) I am getting an error - > Could not create the host: > Failed to get IP for testhostonec14.com: undefined method > `public_ip_addresses' for # > 2) The instance starts running immediately on creation. I don't want it > to run automatically. Only want to create the instance. > > The cli that i am using is as follows - > hammer host create --compute-resource-id=1 > --compute-attributes="flavor_id=t1.micro,managed_ip=2" > --volume="capacity=1G" --name="testhostonec14" --environment-id=1 > --architecture-id=1 --domain-id=2 --puppet-proxy-id=1 > --operatingsystem-id=2 partition-table-id=6 > --interface="type=network,network=default" > > I think all the ids are proper, but I am not really sure about the value > of managed_ip. On the we ui, the drop down for managed_ip has two entries - > Public and Private. I figured managed_ip should contain the number of the > required entry, though not sure if I am doing the correct thing. > > Apart from that, though the instance shows as 'running' in the ec2 > console, i cannot ping to the machine. > I can assign an elastic ip to the instance, yet cannot ping to it using > the elastic ip. > > Need help here. Please let me know if anymore information is required. > > Best regards, > Abhijeet > -- > You received this message because you are subscribed to the Google Groups > "Foreman users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to foreman-user...@googlegroups.com . > To post to this group, send email to forema...@googlegroups.com > . > Visit this group at http://groups.google.com/group/foreman-users. > For more options, visit https://groups.google.com/d/optout. > > Re 1) What version of Foreman do you run? Your problem may be related to > http://projects.theforeman.org/issues/4616, it is fixed in Foreman 1.4.2. > > Re 2) There is option --build=false in host create. Wouldn't that help? > > Regards, > Martin >

> >>Re 1) What version of Foreman do you run? Your problem may be
> related to Bug #4616: Problems provisioning hosts in EC2 with 1.4.1-2 - Foreman
> <Bug #4616: Problems provisioning hosts in EC2 with 1.4.1-2 - Foreman>, it is fixed in Foreman
> 1.4.2.
> Yes that was an older version. I tried this with 1.4.2. I also
> modified the parameters a bit. Now that error is not shown. But I am
> getting another error. Yet the machine is created in ec2 and it gets
> listed in hammer host list command. But the error message is not
> desirable.
>
> hammer -v --show-ids host create --compute-resource-id=1
> --compute-attributes="flavor_id=t1.micro,managed_ip=public,image_id=ami-75342c01"
> --volume="capacity=1G" --name="RHF6" --environment-id=1
> --architecture-id=1 --domain-id=1 --puppet-proxy-id=1
> --operatingsystem-id=2 --partition-table-id=
> --interface="type=network,network=default" --build=false
> [ERROR 2014-03-28 03:38:11 Exception] <NilClass> nil
Now it looks like a bug in Hammer. Could you, please, try Hammer 0.1.0?
If the error persists, could you send me output of run with "-d" switch
(it is available since 0.1.0): hammer -d host create --…

> >>Re 2) There is option --build=false in host create. Wouldn't that help?
> Tried that. Doesnt help. The instance starts running immidiately.
I was not able to find solution for this, but I have no experience with
EC2. It seems that control of start is available only for Libvirt and
oVirt. Maybe someone else could help here. Is it possible from the UI?

Regards,

Martin

··· On 03/28/2014 08:42 AM, Abhijeet Joshi wrote:

Best regards,
Abhijeet

On Thursday, March 27, 2014 8:46:44 PM UTC+5:30, Martin Bačovský wrote:

On 03/26/2014 11:30 AM, Abhijeet Joshi wrote:
Hello,

I am new to foreman and hammer and have been trying the cli.
I want to provision a VM on EC2 using hammer cli. I have already
added compute resource for ec2.
The VM itself gets provisioned successfully. I can see it on the
ec2 console. But two strange things are happenning -
1) I am getting an error -
Could not create the host:
  Failed to get IP for testhostonec14.com
<http://testhostonec14.com>: undefined method
`public_ip_addresses' for
#<Fog::Compute::AWS::Server:0x0000000714b548>
2) The instance starts running immediately on creation. I don't
want it to run automatically. Only want to create the instance.

The cli that i am using is as follows -
hammer host create --compute-resource-id=1
 --compute-attributes="flavor_id=t1.micro,managed_ip=2"
--volume="capacity=1G" --name="testhostonec14" --environment-id=1
--architecture-id=1 --domain-id=2 --puppet-proxy-id=1
--operatingsystem-id=2 partition-table-id=6
--interface="type=network,network=default"

I think all the ids are proper, but I am not really sure about
the value of managed_ip. On the we ui, the drop down for
managed_ip has two entries - Public and Private. I figured
managed_ip should contain the number of the required entry,
though not sure if I am doing the correct thing.

Apart from that, though the instance shows as 'running' in the
ec2 console, i cannot ping to the machine.
I can assign an elastic ip to the instance, yet cannot ping to it
using the elastic ip.

Need help here. Please let me know if anymore information is
required.

Best regards,
Abhijeet
-- 
You received this message because you are subscribed to the
Google Groups "Foreman users" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to foreman-user...@googlegroups.com <javascript:>.
To post to this group, send email to forema...@googlegroups.com
<javascript:>.
Visit this group at http://groups.google.com/group/foreman-users
<http://groups.google.com/group/foreman-users>.
For more options, visit https://groups.google.com/d/optout
<https://groups.google.com/d/optout>.
Re 1) What version of Foreman do you run? Your problem may be
related to http://projects.theforeman.org/issues/4616
<http://projects.theforeman.org/issues/4616>, it is fixed in
Foreman 1.4.2.

Re 2) There is option --build=false in host create. Wouldn't that
help?

Regards,
Martin


You received this message because you are subscribed to the Google
Groups “Foreman users” group.
To unsubscribe from this group and stop receiving emails from it, send
an email to foreman-users+unsubscribe@googlegroups.com
mailto:foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com
mailto:foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.

@Martin,
Updated hammer and ran the command again with -d . Same error. Heres the
output

[root@ProvisionServer hammer]# hammer -d -v --show-ids host create
–compute-resource-id=1
–compute-attributes="flavor_id=t1.micro,managed_ip=public,image_id=ami-75342c01"
–volume="capacity=1G" --name="RHFreeNEw3" --environment-id=1
–architecture-id=1 --domain-id=1 --puppet-proxy-id=1
–operatingsystem-id=2 --partition-table-id=
–interface="type=network,network=default"
[ INFO 2014-03-31 08:24:54 Init] Initialization of Hammer CLI (0.1.0) has
started…
[DEBUG 2014-03-31 08:24:54 Init] Running at ruby 1.8.7-p352
[ INFO 2014-03-31 08:24:54 Init] Configuration from the file
/etc/hammer/cli_config.yml has been loaded
[ WARN 2014-03-31 08:24:54 Modules] Legacy configuration of modules
detected. Check section about configuration in user manual
[DEBUG 2014-03-31 08:24:54 Connection] Registered: foreman
[ INFO 2014-03-31 08:24:54 API] GET /apidoc/apipie_checksum
[DEBUG 2014-03-31 08:24:54 API] Params: {}
[ INFO 2014-03-31 08:24:54 Modules] Extension module hammer_cli_foreman
(0.1.0) loaded
[DEBUG 2014-03-31 08:24:54 Init] Using locale 'en'
[DEBUG 2014-03-31 08:24:54 Init] 'mo' files for locale domain 'hammer-cli'
loaded from '/usr/lib/ruby/gems/1.8/gems/hammer_cli-0.1.0/locale'
[DEBUG 2014-03-31 08:24:54 Init] 'mo' files for locale domain
'hammer-cli-foreman' loaded from
'/usr/lib/ruby/gems/1.8/gems/hammer_cli_foreman-0.1.0/locale'
[ INFO 2014-03-31 08:24:54 HammerCLI::MainCommand] Called with options:
{"option_debug"=>true, "option_show_ids"=>true, "option_verbose"=>true}
[ INFO 2014-03-31 08:24:54 HammerCLIForeman::Host] Called with options: {}
[ INFO 2014-03-31 08:24:54 HammerCLIForeman::Host::CreateCommand] Called
with options: {"option_enabled"=>true, "option_managed"=>true,
"option_interface_list"=>[{"network"=>"default", "type"=>"network"}],
"option_build"=>true, "option_puppet_proxy_id"=>"1",
"option_name"=>"RHFreeNEw3", "option_compute_resource_id"=>"1",
"option_compute_attributes"=>{"managed_ip"=>"public",
"image_id"=>"ami-75342c01", "flavor_id"=>"t1.micro"},
"option_architecture_id"=>"1", "option_partition_table_id"=>"",
"option_operatingsystem_id"=>"2", "option_environment_id"=>"1",
"option_volume_list"=>[{"capacity"=>"1G"}], "option_domain_id"=>"1"}
[ INFO 2014-03-31 08:24:54 API] GET /apidoc/apipie_checksum
[DEBUG 2014-03-31 08:24:54 API] Params: {}
[ INFO 2014-03-31 08:24:54 API] POST /api/hosts
[DEBUG 2014-03-31 08:24:54 API] Params: {
"host" => {
"compute_attributes" => {
"managed_ip" => "public",
"image_id" => "ami-75342c01",
"nics_attributes" => {
"0" => {
"network" => "default",
"type" => "network"
}
},
"interfaces_attributes" => {
"0" => {
"network" => "default",
"type" => "network"
}
},
"volumes_attributes" => {
"0" => {
"capacity" => "1G"
}
},
"flavor_id" => "t1.micro"
},
"architecture_id" => "1",
"name" => "RHFreeNEw3",
"operatingsystem_id" => "2",
"enabled" => true,
"compute_resource_id" => "1",
"ptable_id" => "",
"managed" => true,
"build" => true,
"puppet_proxy_id" => "1",
"environment_id" => "1",
"host_parameters_attributes" => {},
"domain_id" => "1"
}
}
[ERROR 2014-03-31 08:25:20 Exception] <NilClass> nil
Could not create the host

Best regards,
Abhijeet

··· On Friday, March 28, 2014 5:45:11 PM UTC+5:30, Martin Bačovský wrote: > > On 03/28/2014 08:42 AM, Abhijeet Joshi wrote: > > >>Re 1) What version of Foreman do you run? Your problem may be related to > http://projects.theforeman.org/issues/4616, it is fixed in Foreman 1.4.2. > Yes that was an older version. I tried this with 1.4.2. I also modified > the parameters a bit. Now that error is not shown. But I am getting another > error. Yet the machine is created in ec2 and it gets listed in hammer host > list command. But the error message is not desirable. > > hammer -v --show-ids host create --compute-resource-id=1 > --compute-attributes="flavor_id=t1.micro,managed_ip=public,image_id=ami-75342c01" > --volume="capacity=1G" --name="RHF6" --environment-id=1 --architecture-id=1 > --domain-id=1 --puppet-proxy-id=1 --operatingsystem-id=2 > --partition-table-id= --interface="type=network,network=default" > --build=false > [ERROR 2014-03-28 03:38:11 Exception] nil > > Now it looks like a bug in Hammer. Could you, please, try Hammer 0.1.0? If > the error persists, could you send me output of run with "-d" switch (it is > available since 0.1.0): hammer -d host create --...... > > >>Re 2) There is option --build=false in host create. Wouldn't that > help? > Tried that. Doesnt help. The instance starts running immidiately. > > I was not able to find solution for this, but I have no experience with > EC2. It seems that control of start is available only for Libvirt and > oVirt. Maybe someone else could help here. Is it possible from the UI? > > Regards, > > Martin > > > Best regards, > Abhijeet > > On Thursday, March 27, 2014 8:46:44 PM UTC+5:30, Martin Bačovský wrote: >> >> On 03/26/2014 11:30 AM, Abhijeet Joshi wrote: >> >> Hello, >> >> I am new to foreman and hammer and have been trying the cli. >> I want to provision a VM on EC2 using hammer cli. I have already added >> compute resource for ec2. >> The VM itself gets provisioned successfully. I can see it on the ec2 >> console. But two strange things are happenning - >> 1) I am getting an error - >> Could not create the host: >> Failed to get IP for testhostonec14.com: undefined method >> `public_ip_addresses' for # >> 2) The instance starts running immediately on creation. I don't want it >> to run automatically. Only want to create the instance. >> >> The cli that i am using is as follows - >> hammer host create --compute-resource-id=1 >> --compute-attributes="flavor_id=t1.micro,managed_ip=2" >> --volume="capacity=1G" --name="testhostonec14" --environment-id=1 >> --architecture-id=1 --domain-id=2 --puppet-proxy-id=1 >> --operatingsystem-id=2 partition-table-id=6 >> --interface="type=network,network=default" >> >> I think all the ids are proper, but I am not really sure about the >> value of managed_ip. On the we ui, the drop down for managed_ip has two >> entries - Public and Private. I figured managed_ip should contain the >> number of the required entry, though not sure if I am doing the correct >> thing. >> >> Apart from that, though the instance shows as 'running' in the ec2 >> console, i cannot ping to the machine. >> I can assign an elastic ip to the instance, yet cannot ping to it using >> the elastic ip. >> >> Need help here. Please let me know if anymore information is required. >> >> Best regards, >> Abhijeet >> -- >> You received this message because you are subscribed to the Google Groups >> "Foreman users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to foreman-user...@googlegroups.com. >> To post to this group, send email to forema...@googlegroups.com. >> Visit this group at http://groups.google.com/group/foreman-users. >> For more options, visit https://groups.google.com/d/optout. >> >> Re 1) What version of Foreman do you run? Your problem may be related to >> http://projects.theforeman.org/issues/4616, it is fixed in Foreman 1.4.2. >> >> Re 2) There is option --build=false in host create. Wouldn't that help? >> >> Regards, >> Martin >> > -- > You received this message because you are subscribed to the Google Groups > "Foreman users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to foreman-user...@googlegroups.com . > To post to this group, send email to forema...@googlegroups.com > . > Visit this group at http://groups.google.com/group/foreman-users. > For more options, visit https://groups.google.com/d/optout. > > >

Hello Martin,

Did you get a chance to look at the error stack

-Abhijeet

I am not getting this error now. Looks like I wasn't providing the correct
templates. After providing the PXELinux, provision and finish templates,
the VMs are getting created perfectly thru GUI as well as CLI.

Though the provisioning is happening in the background, I am getting a
request timeout error for which I have started a separate
thread. https://groups.google.com/forum/#!topic/foreman-users/u-41WHMicIE

Thanks for all the help.

Best regards,
Abhijeet

··· On Tuesday, April 8, 2014 2:36:49 PM UTC+5:30, Abhijeet Joshi wrote: > > Hello Martin, > > Did you get a chance to look at the error stack > > -Abhijeet > >