-
Notifications
You must be signed in to change notification settings - Fork 115
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
prepare puppet classes needed for FAM tests in setup_fam #16728
Merged
jameerpathan111
merged 1 commit into
SatelliteQE:master
from
evgeni:prepare-puppet-classes
Oct 24, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,6 +91,38 @@ def setup_fam(module_target_sat, module_sca_manifest, install_import_ansible_rol | |
f'''sed -i 's|subscription_manifest_path:.*|subscription_manifest_path: "data/{module_sca_manifest.name}"|g' {config_file}''' | ||
) | ||
|
||
repo_path = '/fake_puppet1/system/releases/p/puppetlabs/' | ||
module_tarball = 'puppetlabs-ntp-3.0.3.tar.gz' | ||
local_path = '/tmp' | ||
module_target_sat.execute( | ||
f'curl --output {local_path}/{module_tarball} {settings.robottelo.repos_hosting_url}{repo_path}{module_tarball}', | ||
) | ||
module_target_sat.execute( | ||
f'puppet module install --ignore-dependencies {local_path}/{module_tarball}' | ||
) | ||
|
||
def create_fake_module(module_target_sat, module_name, module_classes): | ||
base_dir = '/etc/puppetlabs/code/environments/production/modules' | ||
module_dir = f'{base_dir}/{module_name}' | ||
manifest_dir = f'{module_dir}/manifests' | ||
module_target_sat.execute(f'mkdir -p {manifest_dir}') | ||
for module_class in module_classes: | ||
full_class = module_name if module_class == 'init' else f'{module_name}::{module_class}' | ||
module_target_sat.execute( | ||
f'echo "class {full_class}(){{}}" > {manifest_dir}/{module_class}.pp' | ||
) | ||
|
||
create_fake_module( | ||
module_target_sat, | ||
'prometheus', | ||
['init', 'haproxy_exporter', 'redis_exporter', 'statsd_exporter'], | ||
) | ||
|
||
smart_proxy = module_target_sat.nailgun_smart_proxy.read() | ||
smart_proxy.import_puppetclasses() | ||
|
||
create_fake_module(module_target_sat, 'fakemodule', ['init']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One could argue this should rather happen inside |
||
|
||
|
||
@pytest.mark.pit_server | ||
@pytest.mark.run_in_one_thread | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jameer asked via Slack what's exactly happening here, and I think we can write it down here in the PR for anyone who will come back and read it later:
I need puppet modules for the tests. 1/ the prometheus module (with those exporter subclasses) and 2/ "some rando module, just something that can be imported"
in both cases, I don't actually care about them to have any working puppet code in them, as long as the names (of modules/classes) are as I want them to
a trivial Puppet class definition is:
or also
if I want to ignore newlines/readability
so the code (
create_fake_module
) goes and given the name of a module (e.g.prometheus
) and classes inside that module (e.g.['init', 'haproxy_exporter', 'redis_exporter', 'statsd_exporter']
) it:/etc/puppetlabs/code/environments/production/modules/prometheus/manifests
) (and it's parents,mkdir -p
does that for us)init.pp
withclass prometheus(){}
, ahaproxy_exporter.pp
withclass prometheus::haproxy_exporter(){}
, etc…For Puppet/Foreman this looks like totally legit normal Puppet modules, they can be imported into Foreman and applied to Hosts/Hostsgroups, and that's all we care about