github.com/kimor79/packer@v0.8.7-0.20151221212622-d507b18eb4cf/website/source/docs/post-processors/artifice.html.markdown (about) 1 --- 2 description: | 3 The artifice post-processor overrides the artifact list from an upstream builder 4 or post-processor. All downstream post-processors will see the new artifacts you 5 specify. The primary use-case is to build artifacts inside a packer builder -- 6 for example, spinning up an EC2 instance to build a docker container -- and then 7 extracting the docker container and throwing away the EC2 instance. 8 layout: docs 9 page_title: 'Artifice Post-Processor' 10 ... 11 12 # Artifice Post-Processor 13 14 \~> This is a beta feature, and may change significantly before it is 15 finalized. Please open a [GitHub issue to provide 16 feedback](https://github.com/mitchellh/packer/issues). 17 18 Type: `artifice` 19 20 The artifice post-processor overrides the artifact list from an upstream builder 21 or post-processor. All downstream post-processors will see the new artifacts you 22 specify. The primary use-case is to build artifacts inside a packer builder -- 23 for example, spinning up an EC2 instance to build a docker container -- and then 24 extracting the docker container and throwing away the EC2 instance. 25 26 After overriding the artifact with artifice, you can use it with other 27 post-processors like 28 [compress](https://packer.io/docs/post-processors/compress.html), 29 [docker-push](https://packer.io/docs/post-processors/docker-push.html), 30 [Atlas](https://packer.io/docs/post-processors/atlas.html), or a third-party 31 post-processor. 32 33 Artifice allows you to use the familiar packer workflow to create a fresh, 34 stateless build environment for each build on the infrastructure of your 35 choosing. You can use this to build just about anything: buildpacks, containers, 36 jars, binaries, tarballs, msi installers, and more. 37 38 ## Workflow 39 40 Artifice helps you tie together a few other packer features: 41 42 - A builder, which spins up a VM (or container) to build your artifact 43 - A provisioner, which performs the steps to create your artifact 44 - A file provisioner, which downloads the artifact from the VM 45 - The artifice post-processor, which identifies which files have been 46 downloaded from the VM 47 - Additional post-processors, which push the artifact to Atlas, Docker 48 hub, etc. 49 50 You will want to perform as much work as possible inside the VM. Ideally the 51 only other post-processor you need after artifice is one that uploads your 52 artifact to the appropriate repository. 53 54 ## Configuration 55 56 The configuration allows you to specify which files comprise your artifact. 57 58 ### Required: 59 60 - `files` (array of strings) - A list of files that comprise your artifact. 61 These files must exist on your local disk after the provisioning phase of 62 packer is complete. These will replace any of the builder's original 63 artifacts (such as a VM snapshot). 64 65 ### Example Configuration 66 67 This minimal example: 68 69 1. Spins up a cloned VMware virtual machine 70 2. Installs a [consul](https://consul.io/) release 71 3. Downloads the consul binary 72 4. Packages it into a `.tar.gz` file 73 5. Uploads it to Atlas. 74 75 VMX is a fast way to build and test locally, but you can easily substitute 76 another builder. 77 78 ``` {.javascript} 79 { 80 "builders": [ 81 { 82 "type": "vmware-vmx", 83 "source_path": "/opt/ubuntu-1404-vmware.vmx", 84 "ssh_username": "vagrant", 85 "ssh_password": "vagrant", 86 "shutdown_command": "sudo shutdown -h now", 87 "headless":"true", 88 "skip_compaction":"true" 89 } 90 ], 91 "provisioners": [ 92 { 93 "type": "shell", 94 "inline": [ 95 "sudo apt-get install -y python-pip", 96 "sudo pip install ifs", 97 "sudo ifs install consul --version=0.5.2" 98 ] 99 }, 100 { 101 "type": "file", 102 "source": "/usr/local/bin/consul", 103 "destination": "consul", 104 "direction": "download" 105 } 106 ], 107 "post-processors": [ 108 [ 109 { 110 "type": "artifice", 111 "files": ["consul"] 112 }, 113 { 114 "type": "compress", 115 "output": "consul-0.5.2.tar.gz" 116 }, 117 { 118 "type":"atlas", 119 "artifact": "hashicorp/consul", 120 "artifact_type": "archive" 121 } 122 ] 123 ] 124 } 125 ``` 126 127 **Notice that there are two sets of square brackets in the post-processor 128 section.** This creates a post-processor chain, where the output of the 129 proceeding artifact is passed to subsequent post-processors. If you use only one 130 set of square braces the post-processors will run individually against the build 131 artifact (the vmx file in this case) and it will not have the desired result. 132 133 "post-processors": [ 134 [ <--- Start post-processor chain 135 { 136 "type": "artifice", 137 "files": ["consul"] 138 }, 139 { 140 "type": "atlas", 141 ... 142 } 143 ], <--- End post-processor chain 144 { 145 "type":"compress" <-- Standalone post-processor 146 } 147 ] 148 149 You can create multiple post-processor chains to handle multiple builders (for 150 example, building linux and windows binaries during the same build).