hashicorp / packer

Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
http://www.packer.io
Other
15.06k stars 3.32k forks source link

lxd will not produce any artifacts when name parameter is set. #5377

Closed lbytnar closed 6 years ago

lbytnar commented 7 years ago

Affected versions: Packer 1.1.0 Host platform: Ubuntu 16.04.3 LTS Builder: lxd Provisioner: ansible-local with Ansible v2.3.2.0

Below packer config fails to produce any artifacts

    {
        "type": "lxd",
        "name": "u1",
        "image": "ubuntu-daily:xenial"
    }

Here is the output

Building lxd xenial
==> Builds finished but no artifacts were created.

If I remove name leaving just

    {
        "type": "lxd",
        "image": "ubuntu-daily:xenial"
    }

Then all works as expected

Building lxd xenial
lxd output will be in this color.

==> lxd: Creating container...
==> lxd: Provisioning with shell script: /tmp/packer-shell220599120
==> lxd: Stopping container...
==> lxd: Publishing container...
==> lxd: Created image: 6d56b1d0dd667f92e7d7431202d332b33d06530552fdc9615029475e2159c833
==> lxd: Unregistering and deleting deleting container...
2017/09/22 16:27:47 [INFO] Packer version: 1.1.0
2017/09/22 16:27:47 Packer Target OS/Arch: linux amd64
2017/09/22 16:27:47 Built with Go Version: go1.9
2017/09/22 16:27:47 Detected home directory from env var: /home/lucaszb
2017/09/22 16:27:47 Using internal plugin for qemu
2017/09/22 16:27:47 Using internal plugin for amazon-ebssurrogate
2017/09/22 16:27:47 Using internal plugin for cloudstack
2017/09/22 16:27:47 Using internal plugin for docker
2017/09/22 16:27:47 Using internal plugin for hyperv-iso
2017/09/22 16:27:47 Using internal plugin for lxc
2017/09/22 16:27:47 Using internal plugin for parallels-iso
2017/09/22 16:27:47 Using internal plugin for amazon-ebs
2017/09/22 16:27:47 Using internal plugin for amazon-instance
2017/09/22 16:27:47 Using internal plugin for azure-arm
2017/09/22 16:27:47 Using internal plugin for googlecompute
2017/09/22 16:27:47 Using internal plugin for lxd
2017/09/22 16:27:47 Using internal plugin for virtualbox-ovf
2017/09/22 16:27:47 Using internal plugin for amazon-chroot
2017/09/22 16:27:47 Using internal plugin for file
2017/09/22 16:27:47 Using internal plugin for oracle-oci
2017/09/22 16:27:47 Using internal plugin for parallels-pvm
2017/09/22 16:27:47 Using internal plugin for digitalocean
2017/09/22 16:27:47 Using internal plugin for oneandone
2017/09/22 16:27:47 Using internal plugin for profitbricks
2017/09/22 16:27:47 Using internal plugin for triton
2017/09/22 16:27:47 Using internal plugin for vmware-vmx
2017/09/22 16:27:47 Using internal plugin for alicloud-ecs
2017/09/22 16:27:47 Using internal plugin for amazon-ebsvolume
2017/09/22 16:27:47 Using internal plugin for null
2017/09/22 16:27:47 Using internal plugin for openstack
2017/09/22 16:27:47 Using internal plugin for virtualbox-iso
2017/09/22 16:27:47 Using internal plugin for vmware-iso
2017/09/22 16:27:47 Using internal plugin for shell-local
2017/09/22 16:27:47 Using internal plugin for chef-solo
2017/09/22 16:27:47 Using internal plugin for converge
2017/09/22 16:27:47 Using internal plugin for chef-client
2017/09/22 16:27:47 Using internal plugin for file
2017/09/22 16:27:47 Using internal plugin for salt-masterless
2017/09/22 16:27:47 Using internal plugin for ansible
2017/09/22 16:27:47 Using internal plugin for ansible-local
2017/09/22 16:27:47 Using internal plugin for shell
2017/09/22 16:27:47 Using internal plugin for windows-restart
2017/09/22 16:27:47 Using internal plugin for puppet-masterless
2017/09/22 16:27:47 Using internal plugin for puppet-server
2017/09/22 16:27:47 Using internal plugin for powershell
2017/09/22 16:27:47 Using internal plugin for windows-shell
2017/09/22 16:27:47 Using internal plugin for amazon-import
2017/09/22 16:27:47 Using internal plugin for compress
2017/09/22 16:27:47 Using internal plugin for docker-push
2017/09/22 16:27:47 Using internal plugin for manifest
2017/09/22 16:27:47 Using internal plugin for vagrant-cloud
2017/09/22 16:27:47 Using internal plugin for alicloud-import
2017/09/22 16:27:47 Using internal plugin for artifice
2017/09/22 16:27:47 Using internal plugin for atlas
2017/09/22 16:27:47 Using internal plugin for docker-import
2017/09/22 16:27:47 Using internal plugin for checksum
2017/09/22 16:27:47 Using internal plugin for docker-save
2017/09/22 16:27:47 Using internal plugin for googlecompute-export
2017/09/22 16:27:47 Using internal plugin for vsphere
2017/09/22 16:27:47 Using internal plugin for docker-tag
2017/09/22 16:27:47 Using internal plugin for shell-local
2017/09/22 16:27:47 Using internal plugin for vagrant
2017/09/22 16:27:47 Using internal plugin for vsphere-template
2017/09/22 16:27:47 Detected home directory from env var: /home/lucaszb
2017/09/22 16:27:47 Attempting to open config file: /home/lucaszb/.packerconfig
2017/09/22 16:27:47 [WARN] Config file doesn't exist: /home/lucaszb/.packerconfig
2017/09/22 16:27:47 Packer config: &{DisableCheckpoint:false DisableCheckpointSignature:false PluginMinPort:10000 PluginMaxPort:25000 Builders:map[digitalocean:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-digitalocean amazon-ebsvolume:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-amazon-ebsvolume hyperv-iso:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-hyperv-iso amazon-ebs:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-amazon-ebs vmware-vmx:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-vmware-vmx vmware-iso:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-vmware-iso file:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-file oracle-oci:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-oracle-oci oneandone:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-oneandone null:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-null qemu:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-qemu virtualbox-ovf:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-virtualbox-ovf amazon-ebssurrogate:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-amazon-ebssurrogate triton:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-triton alicloud-ecs:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-alicloud-ecs amazon-instance:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-amazon-instance lxd:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-lxd amazon-chroot:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-amazon-chroot profitbricks:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-profitbricks openstack:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-openstack docker:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-docker parallels-iso:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-parallels-iso azure-arm:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-azure-arm cloudstack:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-cloudstack lxc:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-lxc virtualbox-iso:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-virtualbox-iso googlecompute:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-googlecompute parallels-pvm:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-builder-parallels-pvm] PostProcessors:map[amazon-import:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-amazon-import docker-push:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-docker-push manifest:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-manifest checksum:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-checksum googlecompute-export:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-googlecompute-export vagrant:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-vagrant docker-import:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-docker-import docker-save:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-docker-save vsphere-template:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-vsphere-template compress:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-compress alicloud-import:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-alicloud-import vsphere:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-vsphere vagrant-cloud:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-vagrant-cloud artifice:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-artifice atlas:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-atlas docker-tag:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-docker-tag shell-local:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-post-processor-shell-local] Provisioners:map[shell:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-shell windows-restart:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-windows-restart powershell:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-powershell windows-shell:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-windows-shell file:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-file ansible:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-ansible ansible-local:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-ansible-local puppet-masterless:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-puppet-masterless salt-masterless:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-salt-masterless puppet-server:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-puppet-server chef-solo:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-chef-solo converge:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-converge chef-client:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-chef-client shell-local:/usr/local/bin/packer-PACKERSPACE-plugin-PACKERSPACE-packer-provisioner-shell-local]}
2017/09/22 16:27:47 Detected home directory from env var: /home/lucaszb
2017/09/22 16:27:47 Setting cache directory: /home/lucaszb/...packer_cache
2017/09/22 16:27:47 ui: Debug mode enabled. Builds will not be parallelized.
2017/09/22 16:27:47 Build debug mode: true
2017/09/22 16:27:47 Force build: false
2017/09/22 16:27:47 On error: 
2017/09/22 16:27:47 Waiting on builds to complete...
2017/09/22 16:27:47 Builds completed. Waiting on interrupt barrier...
2017/09/22 16:27:47 ui: 
==> Builds finished but no artifacts were created.
2017/09/22 16:27:47 Detected home directory from env var: /home/lucaszb
2017/09/22 16:27:47 waiting for all plugin processes to complete...
SwampDragons commented 6 years ago

cc @ChrisLundquist

ChrisLundquist commented 6 years ago

I'll take a look tonight

On Tue, Oct 17, 2017 at 11:48 AM SwampDragons notifications@github.com wrote:

cc @ChrisLundquist https://github.com/chrislundquist

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hashicorp/packer/issues/5377#issuecomment-337330846, or mute the thread https://github.com/notifications/unsubscribe-auth/AALECByM98l07XtpB2q7nj9KvY9JbdAhks5stPaXgaJpZM4Pg71M .

ChrisLundquist commented 6 years ago

Hmm:

# git rev-parse HEAD
f3c64ce81aca9391fc11571a56e4e1b1f5f1a100

Using lxd.json as:

{
   "builders": [
     {
        "type": "lxd",
        "name": "u1",
        "image": "ubuntu-daily:xenial"
     }
   ]
 }

Running the build with it:

# ./bin/packer build lxd.json 
u1 output will be in this color.

==> u1: Creating container...
==> u1: Stopping container...
==> u1: Publishing container...
==> u1: Created image: 21e13ca5d84239b9dbeac3acb879893859683f97130ca8763acdc8691aa9e430
==> u1: Unregistering and deleting deleting container...
Build 'u1' finished.

==> Builds finished. The artifacts of successful builds are:
--> u1: image: 21e13ca5d84239b9dbeac3acb879893859683f97130ca8763acdc8691aa9e430

Looks happy?

# lxc image list
+---------------+--------------+--------+-------------------------------------------+--------+----------+------------------------------+
|     ALIAS     | FINGERPRINT  | PUBLIC |                DESCRIPTION                |  ARCH  |   SIZE   |         UPLOAD DATE          |
+---------------+--------------+--------+-------------------------------------------+--------+----------+------------------------------+
| packer-u1     | 21e13ca5d842 | no     |                                           | x86_64 | 195.01MB | Oct 18, 2017 at 4:13am (UTC) |

@lbytnar what more can you tell me?

Update: I tried checking out v1.1.0 to see if it was fixed somehow between the version, but I have success on that version as well. I'm building on golang 1.8, and yours was built on 1.9 I don't think that would cause an issue like this.

One thing I'm not testing at the moment are interactions with provisioners.

@lbytnar Would you be able to try my above lxd.json and see what happens on your end?

lbytnar commented 6 years ago

Hi @ChrisLundquist,

This seems to be partially fixed in 1.1.0. See below :

Version 1.1.0 without -only

# /usr/local/bin/packer_1.1.0 build  packer.json  
u1 output will be in this color.

==> u1: Creating container...
==> u1: Stopping container...
==> u1: Publishing container...
==> u1: Created image: de816aab8d80a167802f21b00b12d46d089cbfbdd0190baafac354771c41a722
==> u1: Unregistering and deleting deleting container...
Build 'u1' finished.

==> Builds finished. The artifacts of successful builds are:
--> u1: image: de816aab8d80a167802f21b00b12d46d089cbfbdd0190baafac354771c41a722

Version 1.1.0 with -only

# /usr/local/bin/packer_1.1.0 build -only lxd packer.json 

==> Builds finished but no artifacts were created.

Version 1.0.0 without -only

# /usr/local/bin/packer_1.0.0 build packer.json  
Failed to initialize build 'u1': builder type not found: lxd
u1 output will be in this color.

==> Builds finished but no artifacts were created.

Version 1.0.0 with -only

# /usr/local/bin/packer_1.0.0 build -only lxd packer.json 

==> Builds finished but no artifacts were created.

So it seems to be narrow down to the -only parameter, otherwise looks good. Thank you for checking and testing.

lbytnar commented 6 years ago

Ah, when the name is defined then -only parameter checks the it rather than the type:

# /usr/local/bin/packer_1.1.0 build -only u1 packer.json
u1 output will be in this color.

==> u1: Creating container...
==> u1: Stopping container...
==> u1: Publishing container...
==> u1: Created image: a565b6242939b4efc1619294c391aa891ebafc7d0c453a4f7c476f55f2ce7e00
==> u1: Unregistering and deleting deleting container...
Build 'u1' finished.

==> Builds finished. The artifacts of successful builds are:
--> u1: image: a565b6242939b4efc1619294c391aa891ebafc7d0c453a4f7c476f55f2ce7e00

It doesn't work in 1.0.0.

edit I wrongly assumed that it should be the type instead of the name. The default name is lxd that is why it worked without parameter.

Sorry for time wasted, you can close this issue.

SwampDragons commented 6 years ago

👍 thanks for taking a look @ChrisLundquist

ghost commented 4 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.