diff --git a/docs/md/content/litmus-concepts.md b/docs/md/content/litmus-concepts.md index 361edb16..8e62d0c6 100644 --- a/docs/md/content/litmus-concepts.md +++ b/docs/md/content/litmus-concepts.md @@ -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 diff --git a/docs/md/content/usage/commands/litmus-core-commands.md b/docs/md/content/usage/commands/litmus-core-commands.md index 89a31ebb..2959b06c 100644 --- a/docs/md/content/usage/commands/litmus-core-commands.md +++ b/docs/md/content/usage/commands/litmus-core-commands.md @@ -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]' ``` @@ -56,6 +57,8 @@ version: 2 groups: - name: docker_nodes targets: [] +- name: lxd_nodes + targets: [] - name: ssh_nodes targets: - uri: localhost:2222 @@ -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 @@ -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'] diff --git a/docs/md/content/usage/tools-included-in-Litmus.md b/docs/md/content/usage/tools-included-in-Litmus.md index aba33ef2..54f81445 100644 --- a/docs/md/content/usage/tools-included-in-Litmus.md +++ b/docs/md/content/usage/tools-included-in-Litmus.md @@ -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) @@ -39,5 +40,6 @@ rake task -> serverspec -> rspec #### Tearing down targets rake task -> bolt provision -> docker + -> lxd -> abs (internal) -> vmpooler diff --git a/lib/puppet_litmus/rake_helper.rb b/lib/puppet_litmus/rake_helper.rb index 09c08dcb..2a0d97c6 100644 --- a/lib/puppet_litmus/rake_helper.rb +++ b/lib/puppet_litmus/rake_helper.rb @@ -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. # diff --git a/lib/puppet_litmus/spec_helper_acceptance.rb b/lib/puppet_litmus/spec_helper_acceptance.rb index ecb9e252..8a15504e 100644 --- a/lib/puppet_litmus/spec_helper_acceptance.rb +++ b/lib/puppet_litmus/spec_helper_acceptance.rb @@ -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) diff --git a/spec/lib/puppet_litmus/rake_helper_spec.rb b/spec/lib/puppet_litmus/rake_helper_spec.rb index cbe6893d..c0699442 100644 --- a/spec/lib/puppet_litmus/rake_helper_spec.rb +++ b/spec/lib/puppet_litmus/rake_helper_spec.rb @@ -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