hashicorp / hashicorp/packer-plugin-lxc
lxc builder ignoring command wrapper
- Dominant language
- Go
- Stars
- 7
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.
#### Overview of the Issue
lxc is ignoring the command wrapper option meaning i cant run the container as a normal user
#### Reproduction Steps
run packer init and packer build on example packer file
```hcl
packer {
required_plugins {
ansible = {
source = "github.com/hashicorp/ansible"
version = "~> 1"
}
lxc = {
source = "github.com/hashicorp/lxc"
version = "~> 1"
}
}
}
source "lxc" "test" {
config_file = "/etc/lxc/default.conf"
template_name = "download"
template_parameters = ["--", "-d", "almalinux", "-a", "amd64", "-r", 9 ]
command_wrapper = "systemd-run --unit=my-unit --user --scope -p 'Delegate=yes' -- {{.Command}}"
}
```
### Plugin and Packer version
packer plugins installed
/home/olivia/.config/packer/plugins/github.com/hashicorp/ansible/packer-plugin-ansible_v1.1.2_x5.0_linux_amd64
/home/olivia/.config/packer/plugins/github.com/hashicorp/lxc/packer-plugin-lxc_v1.0.2_x5.0_linux_amd64
packer version
Packer v1.11.2
### Simplified Packer Buildfile
If the file is longer than a few dozen lines, please include the URL to the
[gist](https://gist.github.com/) of the log or use the [Github detailed
format](https://gist.github.com/ericclemmons/b146fe5da72ca1f706b2ef72a20ac39d)
instead of posting it directly in the issue.
### Operating system and Environment details
arch host
lxc ver lxc 1:6.0.3-1
### Log Fragments and crash.log files
```
2025/01/24 18:10:47 [INFO] Packer version: 1.11.2 [go1.23.1 linux amd64]
2025/01/24 18:10:47 Detected xdg config directory from env var: /home/olivia/.config
2025/01/24 18:10:47 [INFO] PACKER_CONFIG env var not set; checking the default config file path
2025/01/24 18:10:47 [INFO] PACKER_CONFIG env var set; attempting to open config file: /home/olivia/.packerconfig
2025/01/24 18:10:47 [WARN] Config file doesn't exist: /home/olivia/.packerconfig
2025/01/24 18:10:47 Detected xdg config directory from env var: /home/olivia/.config
2025/01/24 18:10:47 [INFO] Setting cache directory: /home/olivia/.cache/packer
2025/01/24 18:10:47 Detected xdg config directory from env var: /home/olivia/.config
2025/01/24 18:10:47 [TRACE] listing potential installations for "github.com/hashicorp/lxc" that match "~> 1". plugingetter.ListInstallationsOptions{PluginDirectory:"/home/olivia/.config/packer/plugins", BinaryInstallationOptions:plugingetter.BinaryInstallationOptions{APIVersionMajor:"5", APIVersionMinor:"0", OS:"linux", ARCH:"amd64", Ext:"", Checksummers:[]plugingetter.Checksummer{plugingetter.Checksummer{Type:"sha256", Hash:(*sha256.digest)(0xc000a0c100)}}, ReleasesOnly:false}}
2025/01/24 18:10:47 [TRACE] Found the following "github.com/hashicorp/lxc" installations: [{/home/olivia/.config/packer/plugins/github.com/hashicorp/lxc/packer-plugin-lxc_v1.0.2_x5.0_linux_amd64 v1.0.2 x5.0}]
2025/01/24 18:10:47 [INFO] found external [-packer-default-plugin-name-] builders from lxc plugin
2025/01/24 18:10:47 [TRACE] listing potential installations for "github.com/hashicorp/ansible" that match "~> 1". plugingetter.ListInstallationsOptions{PluginDirectory:"/home/olivia/.config/packer/plugins", BinaryInstallationOptions:plugingetter.BinaryInstallationOptions{APIVersionMajor:"5", APIVersionMinor:"0", OS:"linux", ARCH:"amd64", Ext:"", Checksummers:[]plugingetter.Checksummer{plugingetter.Checksummer{Type:"sha256", Hash:(*sha256.digest)(0xc000a0c100)}}, ReleasesOnly:false}}
2025/01/24 18:10:47 [TRACE] Found the following "github.com/hashicorp/ansible" installations: [{/home/olivia/.config/packer/plugins/github.com/hashicorp/ansible/packer-plugin-ansible_v1.1.2_x5.0_linux_amd64 v1.1.2 x5.0}]
2025/01/24 18:10:47 found external [-packer-default-plugin-name- local] provisioner from ansible plugin
2025/01/24 18:10:47 [TRACE] listing potential installations for that match "". plugingetter.ListInstallationsOptions{PluginDirectory:"/home/olivia/.config/packer/plugins", BinaryInstallationOptions:plugingetter.BinaryInstallationOptions{APIVersionMajor:"5", APIVersionMinor:"0", OS:"linux", ARCH:"amd64", Ext:"", Checksummers:[]plugingetter.Checksummer{plugingetter.Checksummer{Type:"sha256", Hash:(*sha256.digest)(0xc0009ba080)}}, ReleasesOnly:false}}
2025/01/24 18:10:47 found external [-packer-default-plugin-name- local] provisioner from ansible plugin
2025/01/24 18:10:47 [INFO] found external [-packer-default-plugin-name-] builders from lxc plugin
2025/01/24 18:10:47 [INFO] Starting external plugin /home/olivia/.config/packer/plugins/github.com/hashicorp/lxc/packer-plugin-lxc_v1.0.2_x5.0_linux_amd64 start builder -packer-default-plugin-name-
2025/01/24 18:10:47 Starting plugin: /home/olivia/.config/packer/plugins/github.com/hashicorp/lxc/packer-plugin-lxc_v1.0.2_x5.0_linux_amd64 []string{"/home/olivia/.config/packer/plugins/github.com/hashicorp/lxc/packer-plugin-lxc_v1.0.2_x5.0_linux_amd64", "start", "builder", "-packer-default-plugin-name-"}
2025/01/24 18:10:47 Waiting for RPC address for: /home/olivia/.config/packer/plugins/github.com/hashicorp/lxc/packer-plugin-lxc_v1.0.2_x5.0_linux_amd64
2025/01/24 18:10:47 packer-plugin-lxc_v1.0.2_x5.0_linux_amd64 plugin: 2025/01/24 18:10:47 Plugin address: unix /tmp/packer-plugin1934693479
2025/01/24 18:10:47 packer-plugin-lxc_v1.0.2_x5.0_linux_amd64 plugin: 2025/01/24 18:10:47 Waiting for connection...
2025/01/24 18:10:47 Received unix RPC address for /home/olivia/.config/packer/plugins/github.com/hashicorp/lxc/packer-plugin-lxc_v1.0.2_x5.0_linux_amd64: addr is /tmp/packer-plugin1934693479
2025/01/24 18:10:47 packer-plugin-lxc_v1.0.2_x5.0_linux_amd64 plugin: 2025/01/24 18:10:47 Serving a plugin connection...
2025/01/24 18:10:47 packer-plugin-lxc_v1.0.2_x5.0_linux_amd64 plugin: 2025/01/24 18:10:47 [TRACE] starting builder -packer-default-plugin-name-
2025/01/24 18:10:47 [INFO] Starting external plugin /home/olivia/.config/packer/plugins/github.com/hashicorp/ansible/packer-plugin-ansible_v1.1.2_x5.0_linux_amd64 start provisioner -packer-default-plugin-name-
2025/01/24 18:10:47 Starting plugin: /home/olivia/.config/packer/plugins/github.com/hashicorp/ansible/packer-plugin-ansible_v1.1.2_x5.0_linux_amd64 []string{"/home/olivia/.config/packer/plugins/github.com/hashicorp/ansible/packer-plugin-ansible_v1.1.2_x5.0_linux_amd64", "start", "provisioner", "-packer-default-plugin-name-"}
2025/01/24 18:10:47 Waiting for RPC address for: /home/olivia/.config/packer/plugins/github.com/hashicorp/ansible/packer-plugin-ansible_v1.1.2_x5.0_linux_amd64
2025/01/24 18:10:47 packer-plugin-ansible_v1.1.2_x5.0_linux_amd64 plugin: 2025/01/24 18:10:47 Plugin address: unix /tmp/packer-plugin285342195
2025/01/24 18:10:47 packer-plugin-ansible_v1.1.2_x5.0_linux_amd64 plugin: 2025/01/24 18:10:47 Waiting for connection...
2025/01/24 18:10:47 Received unix RPC address for /home/olivia/.config/packer/plugins/github.com/hashicorp/ansible/packer-plugin-ansible_v1.1.2_x5.0_linux_amd64: addr is /tmp/packer-plugin285342195
2025/01/24 18:10:47 packer-plugin-ansible_v1.1.2_x5.0_linux_amd64 plugin: 2025/01/24 18:10:47 Serving a plugin connection...
2025/01/24 18:10:47 packer-plugin-ansible_v1.1.2_x5.0_linux_amd64 plugin: 2025/01/24 18:10:47 [TRACE] starting provisioner -packer-default-plugin-name-
2025/01/24 18:10:47 packer-plugin-ansible_v1.1.2_x5.0_linux_amd64 plugin: 2025/01/24 18:10:47 ansible-playbook version: 2.18.1
2025/01/24 18:10:47 Build debug mode: false
2025/01/24 18:10:47 Force build: false
2025/01/24 18:10:47 On error:
2025/01/24 18:10:47 Waiting on builds to complete...
2025/01/24 18:10:47 Starting build run: lxc.test
2025/01/24 18:10:47 Running builder: lxc
2025/01/24 18:10:47 [INFO] (telemetry) Starting builder lxc.test
2025/01/24 18:10:47 packer-plugin-lxc_v1.0.2_x5.0_linux_amd64 plugin: 2025/01/24 **18:10:47 Executing args: []string{"env", "lxc-create", "-n", "packer-test", "-t", "download", "--", "--", "-d", "almalinux", "-a", "amd64", "-r", "9"}**
2025/01/24 18:10:47 packer-plugin-lxc_v1.0.2_x5.0_linux_amd64 plugin: 2025/01/24 18:10:47 stdout:
2025/01/24 18:10:47 packer-plugin-lxc_v1.0.2_x5.0_linux_amd64 plugin: 2025/01/24 18:10:47 stderr: ERROR: In a user namespace without a map
2025/01/24 18:10:47 packer-plugin-lxc_v1.0.2_x5.0_linux_amd64 plugin: lxc-create: packer-test: ../src/lxc/lxccontainer.c: create_run_template: 1601 Failed to create container from template
2025/01/24 18:10:47 packer-plugin-lxc_v1.0.2_x5.0_linux_amd64 plugin: lxc-create: packer-test: ../src/lxc/tools/lxc_create.c: lxc_create_main: 318 Failed to create container packer-test
==> lxc.test: lxc-create: packer-test: ../src/lxc/lxccontainer.c: create_run_template: 1601 Failed to create container from template
==> lxc.test: lxc-create: packer-test: ../src/lxc/tools/lxc_create.c: lxc_create_main: 318 Failed to create container packer-test
2025/01/24 18:10:47 packer-plugin-lxc_v1.0.2_x5.0_linux_amd64 plugin: 2025/01/24 18:10:47 Executing args: []string{"lxc-destroy", "-f", "-n", "packer-test"}
2025/01/24 18:10:47 packer-plugin-lxc_v1.0.2_x5.0_linux_amd64 plugin: 2025/01/24 18:10:47 stdout:
2025/01/24 18:10:47 packer-plugin-lxc_v1.0.2_x5.0_linux_amd64 plugin: 2025/01/24 18:10:47 stderr: lxc-destroy: packer-test: ../src/lxc/tools/lxc_destroy.c: lxc_destroy_main: 241 Container is not defined
2025/01/24 18:10:47 [INFO] (telemetry) ending lxc.test
lxc-create: packer-test: ../src/lxc/lxccontainer.c: create_run_template: 1601 Failed to create container from template
lxc-create: packer-test: ../src/lxc/tools/lxc_create.c: lxc_create_main: 318 Failed to create container packer-test
==> Wait completed after 47 milliseconds 18 microseconds
2025/01/24 18:10:47 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
2025/01/24 18:10:47 machine readable: lxc.test,error []string{"Error creating container: Command error: ERROR: In a user namespace without a map\nlxc-create: packer-test: ../src/lxc/lxccontainer.c: create_run_template: 1601 Failed to create container from template\nlxc-create: packer-test: ../src/lxc/tools/lxc_create.c: lxc_create_main: 318 Failed to create container packer-test"}
lxc-create: packer-test: ../src/lxc/lxccontainer.c: create_run_template: 1601 Failed to create container from template
lxc-create: packer-test: ../src/lxc/tools/lxc_create.c: lxc_create_main: 318 Failed to create container packer-test
==> Builds finished but no artifacts were created.
2025/01/24 18:10:47 [INFO] (telemetry) Finalizing.
2025/01/24 18:10:47 waiting for all plugin processes to complete...
2025/01/24 18:10:47 /home/olivia/.config/packer/plugins/github.com/hashicorp/ansible/packer-plugin-ansible_v1.1.2_x5.0_linux_amd64: plugin process exited
2025/01/24 18:10:47 /home/olivia/.config/packer/plugins/github.com/hashicorp/lxc/packer-plugin-lxc_v1.0.2_x5.0_linux_amd64: plugin process exited
```
Contributor guide
Research direction
Reproduce the issue with the supplied HCL configuration and compare the command_wrapper setting with the logged Executing args for lxc-create and lxc-destroy. Trace the LXC builder's command execution entry point to determine why the wrapper is absent; done when the configured systemd-run wrapper is used and the container build runs as the normal user.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, linux
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100