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