Project

General

Profile

Actions

Support #18953

open

Duplicated host created after facts upload

Added by Leland Gordon about 7 years ago. Updated over 6 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
chef-handler-foreman
Target version:
-
Triaged:
Fixed in Releases:
Found in Releases:

Description

Hello,

We are seeing an issue when we update a client.rb file and report into foreman, it duplicates the node in the UI.(Version 1.14.2) Do you know a way around this? Here is the client.rb
Client.rb:
require 'chef_handler_foreman'
foreman_server_options :url => 'https://foreman.ORG.com:8443'
foreman_facts_upload true
foreman_reports_upload true
reports_log_level "notice"

We also are curious if its possible to turn off puppet? We tried with the install command below and that doesnt seem to work:
foreman-installer \
--enable-foreman-plugin-chef \
--enable-foreman-plugin-tasks \
--enable-foreman-proxy-plugin-chef \
--no-enable-puppet \
--foreman-server-ssl-crl=""


Files

chef-client-log.txt chef-client-log.txt 546 KB Leland Gordon, 03/21/2017 06:59 PM
Actions #1

Updated by Marek Hulán about 7 years ago

Is the client running windows? I think this could happen if the hostname would contain upper cased letters. The host should be matched by the reported fqdn, if it creates a duplicate, it means it was unable to find the existing one. It could be also caused by the organization mismatch, do you have organizations enabled in your Foreman?

Actions #2

Updated by Marek Hulán about 7 years ago

  • Subject changed from Chef Questions to Duplicated host created after facts upload
Actions #3

Updated by Leland Gordon about 7 years ago

Marek Hulán wrote:

Is the client running windows? I think this could happen if the hostname would contain upper cased letters. The host should be matched by the reported fqdn, if it creates a duplicate, it means it was unable to find the existing one. It could be also caused by the organization mismatch, do you have organizations enabled in your Foreman?

We do have upper case in our FQDN, what is the fix for that? Also, I was wondering if there is a way to send an override attribute when I provision a node and give it an environment and role in foreman?

How do I know if organizations are enabled in foreman?

Actions #4

Updated by Leland Gordon about 7 years ago

Wondering if anyone had a chance to look at this issue?

Actions #5

Updated by Marek Hulán about 7 years ago

We do have upper case in our FQDN, what is the fix for that?

I though it was fixed already but I need to double check. I'll try to reproduce but it would greatly help if you could send me the log from chef-client if you run it with debug log level (chef-client --log_level debug). It contains all data sent to Foreman.

Also, I was wondering if there is a way to send an override attribute when I provision a node and give it an environment and role in foreman?

I'm not sure I understand the question, there's a Chef tab in the provisioning form where you can specify the chef environment and the run list. This will be applied during provisioning when we bootstrap the chef-client.

How do I know if organizations are enabled in foreman?

You would see Organizations menu item under Administer menu. You would need to explicitly enable it so I don't think you use it if you're unsure.

Actions #6

Updated by Leland Gordon about 7 years ago

Mhulan,

Attached is the chef client log. To clarify my second question, I want to send an attribute with the node. For example a 'site name' when provisioning from Foreman. so I can then reference that attribute in my recipes with node[site_name]

Actions #7

Updated by Marek Hulán about 7 years ago

Thanks, it will take me some time to go over the log. Now I understand what you're trying to achieve, basically you want to add node attributes from Foreman. You can simply define the parameter "site_name" in Parameters tab. As long as everything is correctly configured, it would be present so in chef recipe you can use node['site_name']

For more information, please see the plugin manual it needs better formatting but it's described in details there in Parameters chapter.

Actions #8

Updated by Leland Gordon about 7 years ago

Hey Mhulan,

Did you get a chance to take a look? Also, thank you for the parameters information we are going to try that today! No rush on this just wanted to check in. Thank you!!

Actions #9

Updated by Marek Hulán about 7 years ago

Not yet, there was a lot to finish before Foreman 1.15 is branched out. I hope to get to it at beginning of next week.

Actions #10

Updated by Leland Gordon about 7 years ago

Mhulan,

How do we go about bootstrapping a windows node from foreman? is this built in for WinRM?

Thanks,
Leland

Actions #11

Updated by Leland Gordon about 7 years ago

Hey Mhulan,

Any updates on these Q's yet?

Thanks,
Leland

Actions #12

Updated by Levi Smith about 7 years ago

  • Category set to chef-handler-foreman

Not sure if this helps (either party). But I ran into this issue while using the smart proxy as the foreman url rather than just foreman. I kept getting host with the node name and one as the FQDN.

I add this (below) to our client.rb and it stopped the duplicate issue.

foreman_facts_blacklist ['domain'] 

Thanks,

Levi

Leland Gordon wrote:

Hey Mhulan,

Any updates on these Q's yet?

Thanks,
Leland

Actions #13

Updated by Leland Gordon almost 7 years ago

Levi, this worked and we are no longer duplicating after adding that line to our client.rb on the node. Thank you!

We are still looking for a way to bootstrap a windows node with foreman, any hints here?

Actions #14

Updated by Leland Gordon almost 7 years ago

Hello,

Just wanted to check in to see if there is a way to bootstrap a windows node on provision with foreman?

Thank you,
Leland

Actions #15

Updated by Marek Hulán almost 7 years ago

Hello, sorry I haven't got to the original issue. I saw there's a workaround so I deprioritized it a bit... To your question, I know there's a way to provision windows hosts with Foreman so one could possibly modify provisioning templates to install chef-client on windows. Someone added a support for puppet agent on windows recently ( https://github.com/theforeman/community-templates/commit/e46def3b0048eea4230c1ca7ff67088434533fb1 ) so that could be a good inspiration of what needs to be done. If you're interested in bootstrapping the client on existing hosts without provisioning, as long as there's reliable ssh server for windows (I've heard of some), you could use foreman remote execution tool to automate the process. Unfortunately, all hosts would have to exist in Foreman before job template can be run on them, so you'd probably need to create them manually first. You could use API to automate it, if you have too many of them.

Actions #16

Updated by Leland Gordon almost 7 years ago

Hey Marek,

Thanks for the reply, I will give the template a go. I do have a couple questions. So, on my windows host template I would need ruby to be available to run that script, is that right? Can I somehow put in a feature request to bootstrap windows in foreman natively?

Actions #17

Updated by Marek Hulán almost 7 years ago

The template is rendered on Foreman side and the result can be whatever text script. What I haven't realized though is the way how smart proxy runs it, it would need shell (sh) interpreter even if the output would be power shell script. I guess remote execution can't be easily used with Windows :-/

There was a request to add Windows provisioning support (#432) and it's considered implemented, see https://github.com/kireevco/wimaging and deep dive on how to use it https://www.youtube.com/watch?v=_R8-0KAkoPc I suppose those waik scripts could include chef-client bootstrap (once it's windows compatbile). Unfortunately I'm not Windows expert and I don't even have reproducing environment to play with so I can't help much further.

Actions #18

Updated by Leland Gordon almost 7 years ago

Hi Marek,

I was able to bootstrap my node using powershell in the sysprep for vsphere, which is working! One thing I am having trouble with is that when I provision using vsphere the host is created in foreman with the domain added. Ex. mary-clover.domain.goes.here. I want to provision without the domain name appended. Any advice here?

Actions #19

Updated by Marek Hulán almost 7 years ago

Only idea I have is to blacklist more attributes on chef-handler-foreman side but if it's reported as hostname, I'm not sure how to bypass it. Why do you want to avoid specifying the domain? It should get auto-created but should not have no extra value. If you also want to do the provisioning from the foreman, it's fine to have the domain there. As long as there's no proxy associated with it, it shouldn't try to setup any DNS records.

Actions #20

Updated by Leland Gordon almost 7 years ago

Hi Marek,

The node gets created without the domain when its bootstrapped normally. For example, when I bootstrap a node with command line chef, this key is added to the client.rb:
node_name "HOSTNAME-WITHOUT-DOMAIN". When this reports to foreman it creates a new node without the domain appended, creating an inconsistency because now I have VMWare controls in foreman for HOSTNAME-WITH-DOMAIN and the report is for HOSTNAME-WITHOUT-DOMAIN. I suppose I could put the hostname in client.rb with the domain, but the rest of our nodes are not in that format. Sorry for being such a hassle!

Actions #21

Updated by Leland Gordon almost 7 years ago

another question,

when i provision a server from foreman, it sits in a state "build pending", but im not sure what is actually pending? if I cancel it says install is OK. If I do nothing it eventually says that the token has expired on the node.

Actions #22

Updated by Marek Hulán over 6 years ago

Sorry for the late reply. I don't have more ideas regarding the hostnames. Re build pending, that usually happens when at the end of the provisioning, the kickstart/preseed template tries to inform Foreman that the provisioning is done but it fails. It uses HTTP call to Foreman. The host must be able to resolve the Foreman url (DNS working) and must have connectivity. There's a way to do it through Foreman proxy, in case the host does not have connectivity to Foreman.

I suggest you check the production.log on Foreman side to see whether the host contacted it or not. If not, then check to provisioning log on the host, /root/anaconda* for kickstart IIRC

Actions

Also available in: Atom PDF