Skip to content

Commit e46b856

Browse files
committed
lxd provisioner support
1 parent 55f7d1f commit e46b856

File tree

6 files changed

+27
-3
lines changed

6 files changed

+27
-3
lines changed

docs/md/content/litmus-concepts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The following list is the current set of components and implementation choices.
2222
* test dependencies: .fixtures.yml
2323
* Test Infrastructure:
2424
* puppetlabs-provision module
25-
* hypervisors: docker, vagrant, vmpooler, abs
25+
* hypervisors: docker, lxd, vagrant, vmpooler, abs
2626
* external provisioners: e.g. terraform
2727
* test systems:
2828
* litmusimage

docs/md/content/usage/commands/litmus-core-commands.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ For example:
4040

4141
```bash
4242
pdk bundle exec rake 'litmus:provision[vmpooler, redhat-9-x86_64]'
43+
pdk bundle exec rake 'litmus:provision[lxd, images:debian/11]'
4344
pdk bundle exec rake 'litmus:provision[docker, litmusimage/ubuntu:22.04]'
4445
pdk bundle exec rake 'litmus:provision[vagrant, gusztavvargadr/windows-server]'
4546
```
@@ -56,6 +57,8 @@ version: 2
5657
groups:
5758
- name: docker_nodes
5859
targets: []
60+
- name: lxd_nodes
61+
targets: []
5962
- name: ssh_nodes
6063
targets:
6164
- uri: localhost:2222
@@ -82,7 +85,7 @@ Note that you can test some modules against localhost — the machine you are ru
8285
8386
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).
8487
85-
Alternatively, you can use a dedicated VM that uses another provisioner, for example vmpooler or vagrant.
88+
Alternatively, you can use a dedicated VM that uses another provisioner, for example vmpooler, vagrant or lxd.
8689
8790
### Provisioning via YAML
8891
@@ -118,6 +121,11 @@ default:
118121
vagrant:
119122
provisioner: vagrant
120123
images: ['centos/stream9', 'generic/ubuntu2204', 'gusztavvargadr/windows-server']
124+
lxd:
125+
provisioner: lxd
126+
images: ['images:ubuntu/22.04', 'images:centos/7']
127+
params:
128+
vm: true
121129
docker_deb:
122130
provisioner: docker
123131
images: ['litmusimage/debian:10', 'litmusimage/debian:11', 'litmusimage/debian:12']

docs/md/content/usage/tools-included-in-Litmus.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ These tools are built into the Litmus commands:
1818
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)!
1919

2020
rake task -> litmus -> bolt -> provision -> docker
21+
-> lxd
2122
-> vagrant
2223
-> abs (internal)
2324
-> vmpooler (internal)
@@ -39,5 +40,6 @@ rake task -> serverspec -> rspec
3940
#### Tearing down targets
4041

4142
rake task -> bolt provision -> docker
43+
-> lxd
4244
-> abs (internal)
4345
-> vmpooler

lib/puppet_litmus/rake_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
module PuppetLitmus::RakeHelper
88
# DEFAULT_CONFIG_DATA should be frozen for our safety, but it needs to work around https://github.com/puppetlabs/bolt/pull/1696
99
DEFAULT_CONFIG_DATA = { 'modulepath' => File.join(Dir.pwd, 'spec', 'fixtures', 'modules') } # .freeze # rubocop:disable Style/MutableConstant
10-
SUPPORTED_PROVISIONERS = %w[abs docker docker_exp provision_service vagrant vmpooler].freeze
10+
SUPPORTED_PROVISIONERS = %w[abs docker docker_exp lxd provision_service vagrant vmpooler].freeze
1111

1212
# Gets a string representing the operating system and version.
1313
#

lib/puppet_litmus/spec_helper_acceptance.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ def self.configure!
2828
host = ENV.fetch('TARGET_HOST', nil)
2929
set :backend, :docker
3030
set :docker_container, host
31+
elsif target_in_group(inventory_hash, ENV.fetch('TARGET_HOST', nil), 'lxd_nodes')
32+
host = ENV.fetch('TARGET_HOST', nil)
33+
set :backend, :lxd
34+
set :login_shell, true
35+
set :lxd_remote, node_config.dig('lxd', 'remote') unless node_config.dig('lxd', 'remote').nil?
36+
set :lxd_instance, host
3137
elsif target_in_group(inventory_hash, ENV.fetch('TARGET_HOST', nil), 'ssh_nodes')
3238
set :backend, :ssh
3339
options = Net::SSH::Config.for(host)

spec/lib/puppet_litmus/rake_helper_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@
5151
provision_hash: { 'default' => { 'provisioner' => 'vagrant', 'images' => ['centos7'] } },
5252
results: [],
5353
params: { 'action' => 'provision', 'platform' => 'centos7', 'inventory' => Dir.pwd }
54+
},
55+
{
56+
provisioner: 'lxd',
57+
platform: 'images:centos/7',
58+
inventory_vars: nil,
59+
provision_hash: { 'default' => { 'provisioner' => 'lxd', 'images' => ['images:centos/7'] } },
60+
results: [],
61+
params: { 'action' => 'provision', 'platform' => 'images:centos/7', 'inventory' => Dir.pwd }
5462
}
5563
].freeze
5664

0 commit comments

Comments
 (0)