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

Fixes #32766 - adds scheme and pulp content path to setting value #200

Merged

Conversation

jjeffers
Copy link
Contributor

@jjeffers jjeffers commented Jun 9, 2021

The current value omits the scheme and pulp content path, which causes issues when syncing content across capsules (and probably will cause other failures too).

@@ -16,7 +16,7 @@
}

pulpcore::plugin { 'ansible':
config => "ANSIBLE_API_HOSTNAME = \"${pulpcore::servername}\"\nANSIBLE_CONTENT_HOSTNAME = \"${pulpcore::servername}\"",
config => "ANSIBLE_API_HOSTNAME = \"${pulpcore::servername}\"\nANSIBLE_CONTENT_HOSTNAME = \"https://${pulpcore::servername}/pulp/content/\"",
Copy link
Member

Choose a reason for hiding this comment

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

I don't like constructing a URL again and would prefer to reuse.

We have this here:

$content_path = '/pulp/content'

What we should do is construct the URL. Technically speaking it should also take $https_port into account and fail if https is turned off. So roughly:

if ! $pulpcore::apache_https_vhost {
  # TODO: or can it be served over HTTP?
  fail('HTTPS must be turned on for Ansible content')
} elsif $pulpcore::apache::https_port != 443 {
  # Technically we can't determine this when this module doesn't manage the vhost
  # It's up to the user to keep them in sync
  $external_content_url = "https://${pulpcore::servername}:${pulpcore::apache::https_port}${pulpcore::apache::content_path}"
} else {
  $external_content_url = "https://${pulpcore::servername}${pulpcore::apache::content_path}"
}

We're not so complete here:

https://github.com/theforeman/puppet-foreman_proxy_content/blob/fb401944723c5b93941aa98d16f377bded5627c0/manifests/init.pp#L299

It may be an idea to add a $external_content_url in apache.pp so that it can be used in puppet-foreman_proxy_content too.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It may be an idea to add a $external_content_url in apache.pp so that it can be used in puppet-foreman_proxy_content too.

I like this idea, and I think it's best that we tackle the change in apache.pp it in a separate PR.

We could fix the immediate issue here, then improve the cross-module implementation details in a PR that is "Refs #32766 - ..." (really two separate PRs, since we'd also want to update puppet-FPC at that point)

Copy link
Member

Choose a reason for hiding this comment

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

Agreed.

@ekohl ekohl added the Bug Something isn't working label Jun 9, 2021
@@ -25,7 +25,7 @@
.with_content(expected_vhost_content)
is_expected.to contain_concat__fragment('plugin-ansible')
.with_content(/^ANSIBLE_API_HOSTNAME = "foo.example.com"/)
.with_content(/^ANSIBLE_CONTENT_HOSTNAME = "foo.example.com"/)
.with_content(%r{^ANSIBLE_CONTENT_HOSTNAME = "https://foo.example.com/pulp/content/"})
Copy link
Collaborator

Choose a reason for hiding this comment

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

The percent literal is a lot nicer here. 👍

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

Minor question inline, but I'm ok with it.

pulpcore::plugin { 'ansible':
config => "ANSIBLE_API_HOSTNAME = \"${pulpcore::servername}\"\nANSIBLE_CONTENT_HOSTNAME = \"${pulpcore::servername}\"",
config => "ANSIBLE_API_HOSTNAME = \"${pulpcore::servername}\"\nANSIBLE_CONTENT_HOSTNAME = \"${external_content_url}/\"",
Copy link
Member

Choose a reason for hiding this comment

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

Just wondering: does it need a trailing slash?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assumed it was needed. However, I just tested this without a trailing slash. It appears that pulp3 handles this without the trailing slash without any issues.

@ekohl ekohl merged commit 17a84f3 into theforeman:master Jun 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Needs testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants