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

rhsm_config (still not working) #117 #120

Open
ralfbosz opened this issue Mar 15, 2023 · 5 comments
Open

rhsm_config (still not working) #117 #120

ralfbosz opened this issue Mar 15, 2023 · 5 comments
Assignees
Labels
bug NO TESTS Push Request has new code but no validating tests
Milestone

Comments

@ralfbosz
Copy link

The config still does not change when using rhsm_config:

rhsm_config { '/etc/rhsm/rhsm.conf':
  server_port     => 443,
}

From a debug-run:

Debug: Updates to subscription configuration are '{:server_hostname=>"rhsm.redhat.com", :server_insecure=>0, :server_no_proxy=>"", :server_port=>443, :server_prefix=>"/rhsm", :server_proxy_hostname=>"", :server_proxy_password=>"", :server_proxy_port=>"", :server_proxy_user=>"", :server_server_timeout=>180, :server_ssl_verify_depth=>3, :rhsm_auto_enable_yum_plugins=>1, :rhsm_baseurl=>"https://suct2v1249.luna.kpn.org/pulp/content/", :rhsm_ca_cert_dir=>"/etc/rhsm/ca/", :rhsm_consumercertdir=>"/etc/pki/consumer", :rhsm_entitlementcertdir=>"/etc/pki/entitlement", :rhsm_full_refresh_on_yum=>0, :rhsm_manage_repos=>1, :rhsm_pluginconfdir=>"/etc/rhsm/pluginconf.d", :rhsm_plugindir=>"/usr/share/rhsm-plugins", :rhsm_productcertdir=>"/etc/pki/product", :rhsm_repo_ca_cert=>"%(ca_cert_dir)skatello-server-ca.pem", :rhsm_repomd_gpg_url=>"", :rhsm_report_package_profile=>1, :rhsmcertd_autoattachinterval=>1440, :rhsmcertd_certcheckinterval=>240, :rhsmd_processtimeout=>300, :logging_default_log_level=>"INFO"}'
Debug: {:apply=>nil, :remove=>nil}
Debug: rhsm.flush: given nothing to remove.
Debug: rhsm.flush: given nothing to configure.
Debug: Executing: '/usr/sbin/subscription-manager config --list'
Debug: Config was {:server_hostname=>"rhsm.redhat.com", :server_insecure=>0, :server_no_proxy=>"", :server_port=>8443, :server_prefix=>"/rhsm", :server_proxy_hostname=>"", :server_proxy_password=>"", :server_proxy_port=>"", :server_proxy_scheme=>"http", :server_proxy_user=>"", :server_server_timeout=>180, :server_ssl_verify_depth=>3, :rhsm_auto_enable_yum_plugins=>1, :rhsm_baseurl=>"https://suct2v1249.luna.kpn.org/pulp/content/", :rhsm_ca_cert_dir=>"/etc/rhsm/ca/", :rhsm_consumercertdir=>"/etc/pki/consumer", :rhsm_entitlementcertdir=>"/etc/pki/entitlement", :rhsm_full_refresh_on_yum=>1, :rhsm_inotify=>1, :rhsm_manage_repos=>1, :rhsm_package_profile_on_trans=>1, :rhsm_pluginconfdir=>"/etc/rhsm/pluginconf.d", :rhsm_plugindir=>"/usr/share/rhsm-plugins", :rhsm_productcertdir=>"/etc/pki/product", :rhsm_repo_ca_cert=>"%(ca_cert_dir)skatello-server-ca.pem", :rhsm_repomd_gpg_url=>"", :rhsm_report_package_profile=>1, :rhsmcertd_autoattachinterval=>1440, :rhsmcertd_certcheckinterval=>240, :rhsmcertd_disable=>0, :rhsmcertd_splay=>1, :rhsmd_processtimeout=>300, :logging_default_log_level=>"INFO", :name=>"/etc/rhsm/rhsm.conf", :provider=>:subscription_manager, :ensure=>:present}

It seems that the cmds[:apply] is nill. Tested it with a debug and Puppet.debug line in the code and it is empty. No idea how to fix it.

@GertjanBijl
Copy link

GertjanBijl commented May 5, 2023

I ran into this too, and I found that the regex added in e12d8a9 was not working on RHEL6 and RHEL7, but it does work on RHEL8 and RHEL9.
Versions of subscription-manager checked:
RHEL6: subscription-manager-1.20.10-8.el6.x86_64 -> Does not work
RHEL7: subscription-manager-1.24.51-1.el7_9.x86_64 -> Does not work
RHEL8: subscription-manager-1.28.32-1.el8.x86_64 -> Works
RHEL9: subscription-manager-1.29.30.1-1.el9_1.x86_64 -> Works

In case of RHEL8 or RHEL9, the output of the subscription-manager config --help command results in something like this:

usage: subscription-manager config [OPTIONS]

List, set, or remove the configuration parameters in use by this system

optional arguments:
  -h, --help            show this help message and exit
  --list                list the configuration for this system
  --remove REMOVE       remove configuration entry by section.name
  --server.port SERVER.PORT
                        Section: server, Name: port
  --server.server_timeout SERVER.SERVER_TIMEOUT
                        Section: server, Name: server_timeout
  --server.proxy_scheme SERVER.PROXY_SCHEME
                        Section: server, Name: proxy_scheme
  --server.proxy_port SERVER.PROXY_PORT
                        Section: server, Name: proxy_port
  --server.no_proxy SERVER.NO_PROXY
                        Section: server, Name: no_proxy

with a space as separator.

In case of RHEL6 or RHEL7 the output of the subscription-manager config --help command results in something like this:

Usage: subscription-manager config [OPTIONS]

List, set, or remove the configuration parameters in use by this system

Options:
  -h, --help            show this help message and exit
  --list                list the configuration for this system
  --remove=REMOVE       remove configuration entry by section.name
  --server.proxy_hostname=SERVER.PROXY_HOSTNAME
                        Section: server, Name: proxy_hostname
  --server.server_timeout=SERVER.SERVER_TIMEOUT
                        Section: server, Name: server_timeout
  --server.proxy_user=SERVER.PROXY_USER
                        Section: server, Name: proxy_user
  --server.no_proxy=SERVER.NO_PROXY
                        Section: server, Name: no_proxy

with an '=' as separator.

Because the code to parse this output reads:

m = line.match(%r{^\s+--([a-z_0-9]+\.[a-z_0-9]+) [A-Z]+.*})

The regex expects the separator to be a single space only.

If the line is altered to
m = line.match(%r{^\s+--([a-z_0-9]+\.[a-z_0-9]+)[=\s][A-Z]+.*})
it works in both (RHEL6/7 and RHEL8/9) cases.

Note: I did not test on RHEL5, that OS is now well beyond extended support, so I don't see a reason to still support it.

@GertjanBijl
Copy link

Opened #121 to fix this issue.

@GertjanBijl
Copy link

@waveclaw, can you please shine your light on this? The fix is really easy.

@waveclaw
Copy link
Owner

waveclaw commented Jul 8, 2023

@waveclaw, can you please shine your light on this? The fix is really easy.

No, it's not 'really easy.' This is not a 'just update the regex' situation. If you had provided an actual merge-request you would have seen the breakage on the unit test.

I have to re-write the provider to support that small looking change plus additional OS detection code. That has knock-on effects up to forcing a new major release when the state parsing changes in any way.

I'm mostly supporting Oracle, Alma and Rocky Linux. Behavior is different but the OS detection finds it as RedHat. That is obviously a problem for legacy versions like 6 and current but older releases like 7.

I'm probably faced with checking if subscription-manager is 1.25 or later as that brought in the new 'equal-less' options parsing without pushing the major release of a backwards-incompatible API change.

@waveclaw waveclaw self-assigned this Jul 8, 2023
@waveclaw waveclaw added bug NO TESTS Push Request has new code but no validating tests labels Jul 8, 2023
@waveclaw waveclaw added this to the 5.0.0 milestone Jul 8, 2023
@GertjanBijl
Copy link

Sorry for short cutting the solution, I thought I did the right thing by creating PR, but apparently I didn't. I'm normally using Gitlab or Bitbucket on prem, so I'm missing the experience on Github. I'd love to see a unit test against my proposed change, so how can I achieve that? I'm very willing to fix this properly, as it still affects our environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug NO TESTS Push Request has new code but no validating tests
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

3 participants