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

lxd provisioner support #544

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion docs/md/content/litmus-concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The following list is the current set of components and implementation choices.
* test dependencies: .fixtures.yml
* Test Infrastructure:
* puppetlabs-provision module
* hypervisors: docker, vagrant, vmpooler, abs
* hypervisors: docker, lxd, vagrant, vmpooler, abs
* external provisioners: e.g. terraform
* test systems:
* litmusimage
Expand Down
10 changes: 9 additions & 1 deletion docs/md/content/usage/commands/litmus-core-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ For example:

```bash
pdk bundle exec rake 'litmus:provision[vmpooler, redhat-9-x86_64]'
pdk bundle exec rake 'litmus:provision[lxd, images:debian/11]'
pdk bundle exec rake 'litmus:provision[docker, litmusimage/ubuntu:22.04]'
pdk bundle exec rake 'litmus:provision[vagrant, gusztavvargadr/windows-server]'
```
Expand All @@ -56,6 +57,8 @@ version: 2
groups:
- name: docker_nodes
targets: []
- name: lxd_nodes
targets: []
- name: ssh_nodes
targets:
- uri: localhost:2222
Expand All @@ -82,7 +85,7 @@ Note that you can test some modules against localhost — the machine you are ru

For testing services that require a service manager (like systemd), the default Docker images might not be enough. In this case, there is a collection of Docker images, with a service manager enabled, based on our [litmus image repository](https://github.com/puppetlabs/litmusimage). For available images, see the [docker hub](https://hub.docker.com/u/litmusimage).

Alternatively, you can use a dedicated VM that uses another provisioner, for example vmpooler or vagrant.
Alternatively, you can use a dedicated VM that uses another provisioner, for example vmpooler, vagrant or lxd.

### Provisioning via YAML

Expand Down Expand Up @@ -118,6 +121,11 @@ default:
vagrant:
provisioner: vagrant
images: ['centos/stream9', 'generic/ubuntu2204', 'gusztavvargadr/windows-server']
lxd:
provisioner: lxd
images: ['images:ubuntu/22.04', 'images:centos/7']
params:
vm: true
docker_deb:
provisioner: docker
images: ['litmusimage/debian:10', 'litmusimage/debian:11', 'litmusimage/debian:12']
Expand Down
2 changes: 2 additions & 0 deletions docs/md/content/usage/tools-included-in-Litmus.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ These tools are built into the Litmus commands:
To provision systems we created a [module](https://github.com/puppetlabs/provision) that will provision containers / images / hardware in ABS (internal to Puppet) and Docker instances. Provision is extensible, so other provisioners can be added - please raise an [issue](https://github.com/puppetlabs/provision/issues) on the Provision repository, or create your own and submit a [PR](https://github.com/puppetlabs/provision/pulls)!

rake task -> litmus -> bolt -> provision -> docker
-> lxd
-> vagrant
-> abs (internal)
-> vmpooler (internal)
Expand All @@ -39,5 +40,6 @@ rake task -> serverspec -> rspec
#### Tearing down targets

rake task -> bolt provision -> docker
-> lxd
-> abs (internal)
-> vmpooler
2 changes: 1 addition & 1 deletion lib/puppet_litmus/rake_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
module PuppetLitmus::RakeHelper
# DEFAULT_CONFIG_DATA should be frozen for our safety, but it needs to work around https://github.com/puppetlabs/bolt/pull/1696
DEFAULT_CONFIG_DATA = { 'modulepath' => File.join(Dir.pwd, 'spec', 'fixtures', 'modules') } # .freeze # rubocop:disable Style/MutableConstant
SUPPORTED_PROVISIONERS = %w[abs docker docker_exp provision_service vagrant vmpooler].freeze
SUPPORTED_PROVISIONERS = %w[abs docker docker_exp lxd provision_service vagrant vmpooler].freeze

# Gets a string representing the operating system and version.
#
Expand Down
6 changes: 6 additions & 0 deletions lib/puppet_litmus/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ def self.configure!
host = ENV.fetch('TARGET_HOST', nil)
set :backend, :dockercli
set :docker_container, host
elsif target_in_group(inventory_hash, ENV.fetch('TARGET_HOST', nil), 'lxd_nodes')
host = ENV.fetch('TARGET_HOST', nil)
set :backend, :lxd
set :login_shell, true
set :lxd_remote, node_config.dig('lxd', 'remote') unless node_config.dig('lxd', 'remote').nil?
set :lxd_instance, host
elsif target_in_group(inventory_hash, ENV.fetch('TARGET_HOST', nil), 'ssh_nodes')
set :backend, :ssh
options = Net::SSH::Config.for(host)
Expand Down
8 changes: 8 additions & 0 deletions spec/lib/puppet_litmus/rake_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@
provision_hash: { 'default' => { 'provisioner' => 'vagrant', 'images' => ['centos7'] } },
results: [],
params: { 'action' => 'provision', 'platform' => 'centos7', 'inventory' => Dir.pwd }
},
{
provisioner: 'lxd',
platform: 'images:centos/7',
inventory_vars: nil,
provision_hash: { 'default' => { 'provisioner' => 'lxd', 'images' => ['images:centos/7'] } },
results: [],
params: { 'action' => 'provision', 'platform' => 'images:centos/7', 'inventory' => Dir.pwd }
}
].freeze

Expand Down