Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

snagoor
Copy link
Member

@snagoor snagoor commented Aug 30, 2018

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
Copy link
Member Author

snagoor commented Sep 11, 2018

@evgeni can you help me with this PR

@evgeni
Copy link
Member

evgeni commented Sep 18, 2018

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

@snagoor
Copy link
Member Author

snagoor commented Sep 20, 2018

@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
Copy link
Member

evgeni commented Sep 21, 2018

@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?

Copy link
Member

@evgeni evgeni left a comment

Choose a reason for hiding this comment

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

see comment above

@evgeni
Copy link
Member

evgeni commented Dec 18, 2018

@snagoor ping? :)

@snagoor
Copy link
Member Author

snagoor commented Jan 25, 2019

@snagoor ping? :)

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

bootstrap.py Outdated Show resolved Hide resolved
bootstrap.py Outdated Show resolved Hide resolved
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
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:

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
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.

None yet

2 participants