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

Add support to rsync fixtures into SUTs #49

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
19 changes: 19 additions & 0 deletions lib/beaker_puppet_helpers/module_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,24 @@ def install_local_module_on(hosts, source = '.')
File.unlink(source_path) if source_path
end
end

# Copies all local dependencies into a SUT via rsync+ssh
#
# install_local_module_on creates an archive, scps it and then unpack it.
# That takes up a lot of time when you've many modules. rsync+ssh is a faster alternative,
# but it requires rsync in the SUT and on the Host.
# Use the spec_prep rake task to deploy the dependencies locally.
#
# @param [Beaker::Host, Array<Beaker::Host>, String, Symbol] hosts
# One or more hosts to act upon, or a role (String or Symbol) that
# identifies one or more hosts.
# @param [String] source
# The directory where the modules sit
# @param [String] destination
# The directory where the modules will be placed
def install_puppet_modules_via_rsync(hosts, source = 'spec/fixtures/modules/', destination = '/etc/puppetlabs/code/environments/production/modules')
Copy link
Member

Choose a reason for hiding this comment

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

Normally we try to use settings. If you do, you probably can't use the rsync_to helper and your code looks more as it did in the previous version. Just make it destination = nil and if nil, read the value from Puppet's settings. I don't think we have a helper for that (anymore).

It probably comes down to using puppet config print environmentpath and puppet config print environment to determine the destination. That should also help with non-standard configurations.

I also wonder if there should be a default for source because I think making a mandatory parameter is better. That way users of the API are forced to think about it.

Another thought: in foreman-infra we use environment.conf to load multiple directories with modules. In my design I kept module vs repo testing separate. For voxpupuli-acceptance is the tooling intended to make individual module testing easy. This library should make testing Puppet easy. That sort of makes an argument for it to be in voxpupuli-acceptance.

Copy link
Member Author

Choose a reason for hiding this comment

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

My idea was that this helper method isn't Vox Pupuli specific so I added it here and not in voxpupuli-acceptance. I applied the defaults that we/beaker sets during tests at the moment. Let me know if you prefer it in voxpupuli-acceptance and I can move it.

Copy link
Member

Choose a reason for hiding this comment

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

My feeling now is that the implementation is so trivial. However, if you are smarter and read the destination from Puppet's config on the target machine then it certainly makes sense.

At this moment I'm a bit unsure what's best.

real_source = File.realpath(source)
rsync_to(hosts, real_source, destination)
end
end
end