| def do_spacewalk_register(mod_name, name, cfg, cloud, log, secrets): | |
| # TODO(harlowja): turn this into a real cloud-init native module... | |
| cfg = cfg.get("spacewalk", {}) | |
| spacewalk_proxy = cfg.get('proxy') | |
| spacewalk_activation_key = cfg.get('activation_key') | |
| if spacewalk_proxy and spacewalk_activation_key: | |
| # See: https://github.com/tmclaugh/puppet-spacewalk/blob/master/manifests/client.pp | |
| distro = cloud.distro | |
| distro.install_packages(['rhn-setup']) | |
| # Check to see if already registered and don't bother; this is | |
| # apparently done by trying to sync and if that fails then we | |
| # assume we aren't registered; which is sorta ghetto... | |
| already_registered = False | |
| try: | |
| util.subp(['rhn-profile-sync', '--verbose'], capture=False) | |
| already_registered = True | |
| except util.ProcessExecutionError as e: | |
| if e.exit_code != 1: | |
| raise | |
| if not already_registered: | |
| util.subp([ | |
| 'rhnreg_ks', | |
| '--serverUrl=https://%s/XMLRPC' % spacewalk_proxy, | |
| '--sslCACert=/usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT', | |
| '--activationkey=%s' % spacewalk_activation_key, | |
| '--profilename=%s' % cloud.datasource.get_hostname(fqdn=True), | |
| ], capture=False) | |
| else: | |
| log.debug(("Skipping module named %s.%s," | |
| " 'spacewalk_proxy' or 'spacewalk_activation_key' key(s)" | |
| " were not found in configured data"), mod_name, name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment