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 / salt masterless: packer is unable to copy states tree correctly: bad directories (/root and / confusion) #6

Open
ghost opened this issue Apr 22, 2021 · 0 comments

Comments

@ghost
Copy link

ghost commented Apr 22, 2021

This issue was originally opened by @gaetanquentin as hashicorp/packer#10023. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


Overview of the Issue

packer salt module can't copy states tree when used with lxd: bad directories

Reproduction Steps

PACKER_LOG=1 packer build -on-error=ask -var-file=../../lab/01_common/default-variables.json lxd-ubuntu-20.04-saltmaster-2020.json

Packer/salt/lxd versions

packer >= 1.6.0: currently 1.6.4
salt version: 3001.1
lxd version: 4.6 (snap)

Simplified Packer Buildfile

variables:
"salt_local_pillars_dir": "/home/gquentin/Work/repositories/git/automation/Provisionners/SaltStack/pillar",
"salt_remote_pillars_dir": "/srv/pillar",
"salt_local_states_dir": "/home/gquentin/Work/repositories/git/automation/Provisionners/SaltStack/states",
"salt_remote_states_dir": "/srv",
"salt_temp_config_dir": "/tmp/salt"

other:
{
"builders": [
{
"type": "lxd",
"name": "ubuntu-20-04",
"image": "images:ubuntu/20.04",
"output_image": "ubuntu-20-04",
"publish_properties": {
"description": "Ubuntu focal amd64 with saltmaster 3001 built with packer "
},
"profile": "default",
"launch_config": {
"security.privileged": "false"
}
}
],

[ ..]

{
"type": "salt-masterless",
"local_state_tree": "{{user salt_local_states_dir}}",
"remote_state_tree": "{{user salt_remote_states_dir}}",
"local_pillar_roots": "{{user salt_local_pillars_dir}}",
"remote_pillar_roots": "{{user salt_remote_pillars_dir}}",
"temp_config_dir": "{{user salt_temp_config_dir}}",
"custom_state": "sys.tools,sys.locale,sys.sysctl,sys.network,apps.configmanager.salt.master,apps.versioncontrol.git",
"skip_bootstrap": "true",
"bootstrap_args": "-x python3 stable 3001.1 ",
"pause_before": "20s"
},
[ ..]

Operating system and Environment details

Host: ubuntu 20.04
lxd container image: ubuntu 20.04

Log Fragments and crash.log files

    ubuntu-20-04: Uploading local state tree: /home/gquentin/Work/repositories/git/automation/Provisionners/SaltStack/states
2020/10/01 13:20:45 packer-builder-lxd plugin: lxc file push --debug -pr /home/gquentin/Work/repositories/git/automation/Provisionners/SaltStack/states packer-ubuntu-20-04/states
2020/10/01 13:20:45 packer-builder-lxd plugin: Running cp command: lxc file push --debug -pr /home/gquentin/Work/repositories/git/automation/Provisionners/SaltStack/states packer-ubuntu-20-04/states

=> here you can see packer copying states dir in the root (/) of target container

    ubuntu-20-04: Moving states to /tmp/salt/states
2020/10/01 13:20:47 packer-builder-lxd plugin: Executing with lxc exec in container: packer-ubuntu-20-04 sudo sudo mv 'states' '/tmp/salt/states'
2020/10/01 13:20:47 packer-builder-lxd plugin: Executing lxc exec: /bin/sh []string{"/bin/sh", "-c", "lxc exec packer-ubuntu-20-04 -- /bin/sh -c \"sudo sudo mv 'states' '/tmp/salt/states'\""}
==> ubuntu-20-04: mv: cannot stat 'states': No such file or directory

=> here you can see in "sudo mv states /tmp/salt/states" that packer try to move states from /root/states and not /states  since default lxc exec env is user root in /root

more theses directories are not theses specified in input variables 

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

0 participants