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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions bootstrap.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,8 @@ def exec_service(service, command, failonerror=True):
install_katello_agent()
API_PORT = get_api_port()
smart_proxy_id = return_matching_foreman_key('smart_proxies', 'name="%s"' % options.foreman_fqdn, 'id', False)
puppet_master_smart_proxy_id = return_matching_foreman_key('smart_proxies', 'name="%s"' % options.puppet_server, 'id', True)
puppet_ca_smart_proxy_id = return_matching_foreman_key('smart_proxies', 'name="%s"' % options.puppet_ca_server, 'id', True)
current_host_id = return_matching_foreman_key('hosts', 'name="%s"' % FQDN, 'id', False)
capsule_features = get_capsule_features(smart_proxy_id)

Expand All @@ -1434,9 +1436,15 @@ def exec_service(service, command, failonerror=True):

# Configure new proxy_id for Puppet (if not skipped), and OpenSCAP (if available and not skipped)
if 'foreman' not in options.skip and 'puppet' not in options.skip:
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:

print_running("Calling Foreman API to update Puppet Master for %s to %s" % (FQDN, options.puppet_server))
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?

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 'foreman' not in options.skip and 'Openscap' in capsule_features:
print_running("Calling Foreman API to update OpenSCAP proxy for %s to %s" % (FQDN, options.foreman_fqdn))
update_host_capsule_mapping("openscap_proxy_id", smart_proxy_id, current_host_id)
Expand Down