Skip to content

set correct entries for Puppet Master and CA entries during execution - #262

Open
snagoor wants to merge 1 commit into
Katello:masterfrom
snagoor:fix-puppet-ca-master
Open

set correct entries for Puppet Master and CA entries during execution#262
snagoor wants to merge 1 commit into
Katello:masterfrom
snagoor:fix-puppet-ca-master

Conversation

@snagoor

@snagoor snagoor commented Aug 30, 2018

Copy link
Copy Markdown
Member

With #250, we now have the ability to set the arbitrary Puppet Master and CA options, but the current codebase sets both these values to smart_proxy_id, which in turn defaults to foreman_fqdn.

With this new change, added a couple of new entries to pull the right Puppet Master and CA Smart proxy IDs and set them accordingly.

@snagoor

snagoor commented Sep 11, 2018

Copy link
Copy Markdown
Member Author

@evgeni can you help me with this PR

@evgeni

evgeni commented Sep 18, 2018

Copy link
Copy Markdown
Member

@snagoor what kind of help do you need here? the code looks sane on the first glance.

@snagoor

snagoor commented Sep 20, 2018

Copy link
Copy Markdown
Member Author

@evgeni, Sorry for the confusion. What I meant was to review this code change at your leisure and let me know if there are any changes required.

@evgeni

evgeni commented Sep 21, 2018

Copy link
Copy Markdown
Member

@snagoor ah :)

So the code itself looks correct. We could argue if we want to "optimize" the runtime by only querying the IDs if the hostnames are different to foreman_fqdn, but I don't really think it's worth the effort.

However, I fear there is a conceptual problem here. You expect that puppet_server and puppet_ca_server exist in Foreman as Smart Proxies. But there is really no requirement for that. The user might very well run an external Puppet Server, or use a load-balanced hostname for it as we describe in Load-Balanced Smart Proxies with HAProxy. In both cases, you will get no results from the API.

What we could do is to call return_matching_foreman_key with null_result_ok=True and only call update_host_capsule_mapping if we actually got an id and not None.

What do you think?

@evgeni evgeni left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment above

@evgeni

evgeni commented Dec 18, 2018

Copy link
Copy Markdown
Member

@snagoor ping? :)

@snagoor

snagoor commented Jan 25, 2019

Copy link
Copy Markdown
Member Author

@snagoor ping? :)

Sorry, @evgeni for the delay. I will work on your suggestion

@snagoor
snagoor force-pushed the fix-puppet-ca-master branch from ff8b305 to f1299b9 Compare January 29, 2019 10:28
Comment thread bootstrap.py Outdated
Comment thread bootstrap.py Outdated
@snagoor
snagoor force-pushed the fix-puppet-ca-master branch from f1299b9 to a5d738b Compare February 18, 2019 09:59
Comment thread bootstrap.py
print_running("Calling Foreman API to update Puppet master and Puppet CA for %s to %s" % (FQDN, options.foreman_fqdn))
update_host_capsule_mapping("puppet_proxy_id", smart_proxy_id, current_host_id)
update_host_capsule_mapping("puppet_ca_proxy_id", smart_proxy_id, current_host_id)
if puppet_master_smart_proxy_id is not None and puppet_ca_smart_proxy_id is not None:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can write this without the is not None part, which I find better readable

Suggested change
if puppet_master_smart_proxy_id is not None and puppet_ca_smart_proxy_id is not None:
if puppet_master_smart_proxy_id and puppet_ca_smart_proxy_id:

Comment thread bootstrap.py
update_host_capsule_mapping("puppet_proxy_id", puppet_master_smart_proxy_id, current_host_id)
print_running("Calling Foreman API to update Puppet CA for %s to %s" % (FQDN, options.puppet_ca_server))
update_host_capsule_mapping("puppet_ca_proxy_id", puppet_ca_smart_proxy_id, current_host_id)
else:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we need this branching here. The if/else is only here to generate slightly different output, right? I think the user won't lose much if we drop the to %s part of the messages and then we can drop the whole if/else completely if we set puppet_master_smart_proxy_id and puppet_ca_smart_proxy_id to smart_proxy_id if the search didn't return anything.

Now, after writing this, I wonder if we need to set these to the Smart Proxy at all if the user asked for an external (not-found) Puppet setup. Because if the user bootstraps a machine against foreman.example.com, but is using puppet.example.com for Puppet Master and CA, why would we set the Puppet options in Foreman to foreman.example.com? That'd be wrong, no?

@sideangleside thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants