Automate host insertion/update

Hi All!

I am looking for a way to automate virtual machine provisioning with
puppet.

For this, I am considering to use foreman external node capability to
keep the specification off all nodes known to puppet.

My question is, is there an automated way to insert or alter a host in
foreman data model without using the web interface… such as a Restful
API for instance…

Thanks in advance,
Gus

Hi Gus,

Foreman does support restful API.

there are a couple of things to notice:

  1. Rails keep an authentication (cross site scripting) headers, so you will
    need to use those (see an example here: http://gist.github.com/239561)
  2. All values which are in dropdown boxes, are usually plain numerical id
    representation, might need to fetch the html to know the right text values
    (which fit to the numerical ids).

another option is to use the script/runner in rails, which allows you to
create the machines directly, but I agree that the restful API is probably
better on the long run.

let me know if you need any help,
Ohad

··· On Fri, Jun 4, 2010 at 1:11 AM, Gus wrote:

Hi All!

I am looking for a way to automate virtual machine provisioning with
puppet.

For this, I am considering to use foreman external node capability to
keep the specification off all nodes known to puppet.

My question is, is there an automated way to insert or alter a host in
foreman data model without using the web interface… such as a Restful
API for instance…

Thanks in advance,
Gus


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.comforeman-users%2Bunsubscribe@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.

a little play around with the api, created a simple machanize based
solution:

you could extend this to query and set the right values.

cheers,
Ohad

··· On Fri, Jun 4, 2010 at 10:02 AM, Ohad Levy wrote:

Hi Gus,

Foreman does support restful API.

there are a couple of things to notice:

  1. Rails keep an authentication (cross site scripting) headers, so you will
    need to use those (see an example here: http://gist.github.com/239561)
  2. All values which are in dropdown boxes, are usually plain numerical id
    representation, might need to fetch the html to know the right text values
    (which fit to the numerical ids).

another option is to use the script/runner in rails, which allows you to
create the machines directly, but I agree that the restful API is probably
better on the long run.

let me know if you need any help,
Ohad

On Fri, Jun 4, 2010 at 1:11 AM, Gus gustavosoares@gmail.com wrote:

Hi All!

I am looking for a way to automate virtual machine provisioning with
puppet.

For this, I am considering to use foreman external node capability to
keep the specification off all nodes known to puppet.

My question is, is there an automated way to insert or alter a host in
foreman data model without using the web interface… such as a Restful
API for instance…

Thanks in advance,
Gus


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.comforeman-users%2Bunsubscribe@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.

ok, ohad.

thanks! I will take a look :slight_smile:

cheers,
Gus

··· On Fri, Jun 4, 2010 at 5:53 AM, Ohad Levy wrote:

a little play around with the api, created a simple machanize based
solution:

http://gist.github.com/425171

you could extend this to query and set the right values.

cheers,
Ohad

On Fri, Jun 4, 2010 at 10:02 AM, Ohad Levy ohadlevy@gmail.com wrote:

Hi Gus,

Foreman does support restful API.

there are a couple of things to notice:

  1. Rails keep an authentication (cross site scripting) headers, so you
    will need to use those (see an example here:
    http://gist.github.com/239561)
  2. All values which are in dropdown boxes, are usually plain numerical id
    representation, might need to fetch the html to know the right text values
    (which fit to the numerical ids).

another option is to use the script/runner in rails, which allows you to
create the machines directly, but I agree that the restful API is probably
better on the long run.

let me know if you need any help,
Ohad

On Fri, Jun 4, 2010 at 1:11 AM, Gus gustavosoares@gmail.com wrote:

Hi All!

I am looking for a way to automate virtual machine provisioning with
puppet.

For this, I am considering to use foreman external node capability to
keep the specification off all nodes known to puppet.

My question is, is there an automated way to insert or alter a host in
foreman data model without using the web interface… such as a Restful
API for instance…

Thanks in advance,
Gus


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.comforeman-users%2Bunsubscribe@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.comforeman-users%2Bunsubscribe@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.

Hi!

I have managed to create a host through using REST with mechanize.

However, I'm having some trouble to click on the Add parameter link in order
to create a
host with more than one variable…

Has anyone an example of this?

Cheers,
Gus

··· On Fri, Jun 4, 2010 at 9:47 AM, Gustavo Soares wrote:

ok, ohad.

thanks! I will take a look :slight_smile:

cheers,
Gus

On Fri, Jun 4, 2010 at 5:53 AM, Ohad Levy ohadlevy@gmail.com wrote:

a little play around with the api, created a simple machanize based
solution:

http://gist.github.com/425171

you could extend this to query and set the right values.

cheers,
Ohad

On Fri, Jun 4, 2010 at 10:02 AM, Ohad Levy ohadlevy@gmail.com wrote:

Hi Gus,

Foreman does support restful API.

there are a couple of things to notice:

  1. Rails keep an authentication (cross site scripting) headers, so you
    will need to use those (see an example here:
    http://gist.github.com/239561)
  2. All values which are in dropdown boxes, are usually plain numerical id
    representation, might need to fetch the html to know the right text values
    (which fit to the numerical ids).

another option is to use the script/runner in rails, which allows you to
create the machines directly, but I agree that the restful API is probably
better on the long run.

let me know if you need any help,
Ohad

On Fri, Jun 4, 2010 at 1:11 AM, Gus gustavosoares@gmail.com wrote:

Hi All!

I am looking for a way to automate virtual machine provisioning with
puppet.

For this, I am considering to use foreman external node capability to
keep the specification off all nodes known to puppet.

My question is, is there an automated way to insert or alter a host in
foreman data model without using the web interface… such as a Restful
API for instance…

Thanks in advance,
Gus


You received this message because you are subscribed to the Google
Groups “Foreman users” group.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.comforeman-users%2Bunsubscribe@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.comforeman-users%2Bunsubscribe@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.

Hi Gus,

just updated the gist to include a second parameter.

Let me know if it works for you,
Ohad

··· On Thu, Jun 10, 2010 at 11:18 PM, Gustavo Soares wrote:

Hi!

I have managed to create a host through using REST with mechanize.

However, I’m having some trouble to click on the Add parameter link in
order to create a
host with more than one variable…

Has anyone an example of this?

Cheers,
Gus

On Fri, Jun 4, 2010 at 9:47 AM, Gustavo Soares gustavosoares@gmail.comwrote:

ok, ohad.

thanks! I will take a look :slight_smile:

cheers,
Gus

On Fri, Jun 4, 2010 at 5:53 AM, Ohad Levy ohadlevy@gmail.com wrote:

a little play around with the api, created a simple machanize based
solution:

http://gist.github.com/425171

you could extend this to query and set the right values.

cheers,
Ohad

On Fri, Jun 4, 2010 at 10:02 AM, Ohad Levy ohadlevy@gmail.com wrote:

Hi Gus,

Foreman does support restful API.

there are a couple of things to notice:

  1. Rails keep an authentication (cross site scripting) headers, so you
    will need to use those (see an example here:
    http://gist.github.com/239561)
  2. All values which are in dropdown boxes, are usually plain numerical
    id representation, might need to fetch the html to know the right text
    values (which fit to the numerical ids).

another option is to use the script/runner in rails, which allows you to
create the machines directly, but I agree that the restful API is probably
better on the long run.

let me know if you need any help,
Ohad

On Fri, Jun 4, 2010 at 1:11 AM, Gus gustavosoares@gmail.com wrote:

Hi All!

I am looking for a way to automate virtual machine provisioning with
puppet.

For this, I am considering to use foreman external node capability to
keep the specification off all nodes known to puppet.

My question is, is there an automated way to insert or alter a host in
foreman data model without using the web interface… such as a Restful
API for instance…

Thanks in advance,
Gus


You received this message because you are subscribed to the Google
Groups “Foreman users” group.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.comforeman-users%2Bunsubscribe@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.comforeman-users%2Bunsubscribe@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.comforeman-users%2Bunsubscribe@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.

Thank you Ohad.

I have already tried this. It seems that mechanize validates the form before
posting the data. This is why I need to clink add parameter link to retrieve
the new form fields.

To solve this, I have done exacty what your last gist suggest, but without
using mechanize…

If I set Content-Type header to application/json, rails ignores the
authtencitity token, making things a little bit easier… :slight_smile:

Cheers,
Gus

··· On Wed, Jun 16, 2010 at 2:10 AM, Ohad Levy wrote:

Hi Gus,

just updated the gist to include a second parameter.

Let me know if it works for you,
Ohad

On Thu, Jun 10, 2010 at 11:18 PM, Gustavo Soares gustavosoares@gmail.comwrote:

Hi!

I have managed to create a host through using REST with mechanize.

However, I’m having some trouble to click on the Add parameter link in
order to create a
host with more than one variable…

Has anyone an example of this?

Cheers,
Gus

On Fri, Jun 4, 2010 at 9:47 AM, Gustavo Soares gustavosoares@gmail.comwrote:

ok, ohad.

thanks! I will take a look :slight_smile:

cheers,
Gus

On Fri, Jun 4, 2010 at 5:53 AM, Ohad Levy ohadlevy@gmail.com wrote:

a little play around with the api, created a simple machanize based
solution:

http://gist.github.com/425171

you could extend this to query and set the right values.

cheers,
Ohad

On Fri, Jun 4, 2010 at 10:02 AM, Ohad Levy ohadlevy@gmail.com wrote:

Hi Gus,

Foreman does support restful API.

there are a couple of things to notice:

  1. Rails keep an authentication (cross site scripting) headers, so you
    will need to use those (see an example here:
    http://gist.github.com/239561)
  2. All values which are in dropdown boxes, are usually plain numerical
    id representation, might need to fetch the html to know the right text
    values (which fit to the numerical ids).

another option is to use the script/runner in rails, which allows you
to create the machines directly, but I agree that the restful API is
probably better on the long run.

let me know if you need any help,
Ohad

On Fri, Jun 4, 2010 at 1:11 AM, Gus gustavosoares@gmail.com wrote:

Hi All!

I am looking for a way to automate virtual machine provisioning with
puppet.

For this, I am considering to use foreman external node capability to
keep the specification off all nodes known to puppet.

My question is, is there an automated way to insert or alter a host in
foreman data model without using the web interface… such as a Restful
API for instance…

Thanks in advance,
Gus


You received this message because you are subscribed to the Google
Groups “Foreman users” group.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.comforeman-users%2Bunsubscribe@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.


You received this message because you are subscribed to the Google
Groups “Foreman users” group.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.comforeman-users%2Bunsubscribe@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.comforeman-users%2Bunsubscribe@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.comforeman-users%2Bunsubscribe@googlegroups.com
.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.