Default template for new server

Hi all,

I just started use puppet (3.2) and foremen (1.1). My set up looks like
this:

  1. I have puppet master and foreman set up on the same server, with hiera
  2. I have an empty default.pp in /etc/puppet/manifest/nodes, which are
    included in sites.pp
  3. Hiera was set up to apply some default classes depending on the node
    attributes, such as kernel for creating my admin accounts, etc.
  4. When creating a new VM in vcloud, a customization script will run,
    including this command: puppet agent -t --server mypuppet.server.com
  5. Enabled auto sign on puppet master

I would like the new VM to be registered/created in puppet master/foreman
automatically.

However, when a new VM spinning up, puppet agent registers to my puppet
master and foreman, (I don't define a new host in foreman beforehand) I got
the following error in the log of customization script:

> Error 400 on SERVER: Failed when searching for node rhel664bitgold: Failed
> to find rhel664bitgold via exec: Execution of '/etc/puppet/node.rb
> rhel664bitgold' returned 1

An new host was created in foreman but with error. If I run the same puppet
command again, everything works fine.

Form what I understand, foreman should merge the default.pp and classes
from puppet master, then send it back to agent, like it didn't when the
command executed second time. However, when the host doesn't exist in
foremen, node.rb return error. Is it a bug or expected behavior? Thanks.

Cheers,
Pan

That's not expected, the node.rb script should first upload the facts
for the host to Foreman which causes the host to be created, then it
queries Foreman for the ENC information and returns this to Puppet.

Could you look at a few things please?

a) the value of "facts" and "storeconfigs" settings at the top of
/etc/puppet/node.rb, these should be "true" and "false" respectively

b) /var/log/foreman/production.log should list a "POST
/fact_values/create" log entry when the host checks in, which should end
in a "200 OK" response. See if this had any errors, or if it wasn't there.

c) run "sudo -u puppet /etc/puppet/node.rb rhel664bitgold" and see if it
returns any errors

··· On 13/06/13 00:33, Pan Luo wrote: > Hi all, > > I just started use puppet (3.2) and foremen (1.1). My set up looks like > this: > 1. I have puppet master and foreman set up on the same server, with hiera > 2. I have an empty default.pp in /etc/puppet/manifest/nodes, which are > included in sites.pp > 3. Hiera was set up to apply some default classes depending on the node > attributes, such as kernel for creating my admin accounts, etc. > 4. When creating a new VM in vcloud, a customization script will run, > including this command: puppet agent -t --server mypuppet.server.com > 5. Enabled auto sign on puppet master > > I would like the new VM to be registered/created in puppet > master/foreman automatically. > > However, when a new VM spinning up, puppet agent registers to my puppet > master and foreman, (I don't define a new host in foreman beforehand) I > got the following error in the log of customization script: > > Error 400 on SERVER: Failed when searching for node rhel664bitgold: > Failed to find rhel664bitgold via exec: Execution of > '/etc/puppet/node.rb rhel664bitgold' returned 1 > > > An new host was created in foreman but with error. If I run the same > puppet command again, everything works fine. > > Form what I understand, foreman should merge the default.pp and classes > from puppet master, then send it back to agent, like it didn't when the > command executed second time. However, when the host doesn't exist in > foremen, node.rb return error. Is it a bug or expected behavior? Thanks.


Dominic Cleal
Red Hat Engineering

Thanks Dominic.
b. I got the following error:
Failed to import facts: SQLite3::ConstraintException: hosts.name may
not be NULL: INSERT INTO "hosts" ("ip", "location_id",
"source_file_id", "medium_id", "subnet_id", "root_pass",
"last_report", "mac", "comment", "name", "puppet_ca_proxy_id",
"serial", "image_id", "image_file", "architecture_id", "owner_id",
"updated_at", "hostgroup_id", "created_at", "last_freshcheck",
"enabled", "last_compile", "owner_type", "organization_id", "disk",
"ptable_id", "environment_id", "environment", "domain_id",
"puppet_status", "build", "use_image", "certname",
"compute_resource_id", "installed_at", "model_id", "managed", "uuid",
"operatingsystem_id", "puppet_proxy_id") VALUES (NULL, NULL, NULL,
NULL, NULL, NULL, NULL, '', NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, '2013-06-13 07:37:14.717111', NULL, '2013-06-13
07:37:14.717111', NULL, 't', NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, 0, 'f', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
Rendered text template (0.0ms)
Completed 400 Bad Request in 11ms (Views: 0.6ms | ActiveRecord: 1.1ms)
c: node.rb was giving me some error like: "— false …" (can't
remember accurately)

However, I figured out from b. I was giving my VM just hostname
without domain. When I gave it FQDN, it works fine.

Cheers,
Pan

··· a: my facts and storeconfigs are correct.

On Thu, Jun 13, 2013 at 2:26 AM, Dominic Cleal dcleal@redhat.com wrote:

On 13/06/13 00:33, Pan Luo wrote:

Hi all,

I just started use puppet (3.2) and foremen (1.1). My set up looks like
this:

  1. I have puppet master and foreman set up on the same server, with hiera
  2. I have an empty default.pp in /etc/puppet/manifest/nodes, which are
    included in sites.pp
  3. Hiera was set up to apply some default classes depending on the node
    attributes, such as kernel for creating my admin accounts, etc.
  4. When creating a new VM in vcloud, a customization script will run,
    including this command: puppet agent -t --server mypuppet.server.com
  5. Enabled auto sign on puppet master

I would like the new VM to be registered/created in puppet
master/foreman automatically.

However, when a new VM spinning up, puppet agent registers to my puppet
master and foreman, (I don’t define a new host in foreman beforehand) I
got the following error in the log of customization script:

Error 400 on SERVER: Failed when searching for node rhel664bitgold:
Failed to find rhel664bitgold via exec: Execution of
'/etc/puppet/node.rb rhel664bitgold' returned 1

An new host was created in foreman but with error. If I run the same
puppet command again, everything works fine.

Form what I understand, foreman should merge the default.pp and classes
from puppet master, then send it back to agent, like it didn’t when the
command executed second time. However, when the host doesn’t exist in
foremen, node.rb return error. Is it a bug or expected behavior? Thanks.

That’s not expected, the node.rb script should first upload the facts
for the host to Foreman which causes the host to be created, then it
queries Foreman for the ENC information and returns this to Puppet.

Could you look at a few things please?

a) the value of “facts” and “storeconfigs” settings at the top of
/etc/puppet/node.rb, these should be “true” and “false” respectively

b) /var/log/foreman/production.log should list a “POST
/fact_values/create” log entry when the host checks in, which should end
in a “200 OK” response. See if this had any errors, or if it wasn’t there.

c) run “sudo -u puppet /etc/puppet/node.rb rhel664bitgold” and see if it
returns any errors


Dominic Cleal
Red Hat Engineering


You received this message because you are subscribed to a topic in the Google Groups “Foreman users” group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/foreman-users/6l_9B0g-9_Q/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, 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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.