Restapi to add host to foreman

greetings,

im mostly using puppet as an ENC and front-end for puppet. i didnt enable
the TFTP and kickstart functions.
instead, i tried to use restapis and scripts to add/edit the hosts that has
puppet agent and need to be added to puppet.

in the latest foreman version.

i tried, the following curl. to add host client.example.com and add that to
hostgroup 1. yet it failed.

$ curl -s -H "Accept:application/json"
> -k -u admin:changeme
> -d "host[name]=client.example.com" -d "host[hostgroup_id]=1"
> https://foreman.example.com/hosts

{"errors":["IP address has already been taken","IP address is invalid","MAC
address has already been taken","MAC address can't be blank","MAC address
is invalid","Architecture can't be blank","Operatingsystem can't be
blank","Domain can't be blank","Partition Table cant be blank unless a
custom partition has been defined"]}

it seems i need to specify everything it needs???
thats not good, coz i dont use those sections.

for one node i have already in foreman(which was added automatically coz of
puppet register, and by editing that node, i didnt even see the tabs for OS
and Network, etc.)

So im asking if theres a way i can add host like that.

i can try to do editing instead and puppet register auto added the host.
yet i need to know how to edit an existing host too.
i tried the json input, it gave me 500 error, i guess its due to the lack
of those info as well.

appreciate any help. thanks!!!

> greetings,
>
> im mostly using puppet as an ENC and front-end for puppet. i didnt enable
> the TFTP and kickstart functions.
> instead, i tried to use restapis and scripts to add/edit the hosts that
> has puppet agent and need to be added to puppet.
>
> in the latest foreman version.
>
> i tried, the following curl. to add host client.example.com and add that
> to hostgroup 1. yet it failed.
>
> $ curl -s -H "Accept:application/json"
> > -k -u admin:changeme
> > -d "host[name]=client.example.com" -d "host[hostgroup_id]=1"
> > https://foreman.example.com/hosts
>
>
> {"errors":["IP address has already been taken","IP address is
> invalid","MAC address has already been taken","MAC address can't be
> blank","MAC address is invalid","Architecture can't be
> blank","Operatingsystem can't be blank","Domain can't be blank","Partition
> Table cant be blank unless a custom partition has been defined"]}
>
>
> it seems i need to specify everything it needs???
> thats not good, coz i dont use those sections.
>
> usually you can use hostgroup as a default, so everything will be the same
like in the hostgroup settings you selected.

additionally, if you setup a proxy with dhcp, it could offer you ip
addresses and you wont have to manage that at all.

Ohad

··· On Tue, Jul 16, 2013 at 2:06 PM, Xin Ma wrote:

for one node i have already in foreman(which was added automatically coz
of puppet register, and by editing that node, i didnt even see the tabs for
OS and Network, etc.)

So im asking if theres a way i can add host like that.

i can try to do editing instead and puppet register auto added the host.
yet i need to know how to edit an existing host too.
i tried the json input, it gave me 500 error, i guess its due to the lack
of those info as well.

appreciate any help. thanks!!!


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/groups/opt_out.