github.com/StackPointCloud/packer@v0.10.2-0.20180716202532-b28098e0f79b/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 [Atlas](https://www.packer.io/docs/post-processors/atlas.html), or a third-party 29 post-processor. 30 31 Artifice allows you to use the familiar packer workflow to create a fresh, 32 stateless build environment for each build on the infrastructure of your 33 choosing. You can use this to build just about anything: buildpacks, containers, 34 jars, binaries, tarballs, msi installers, and more. 35 36 ## Workflow 37 38 Artifice helps you tie together a few other packer features: 39 40 - A builder, which spins up a VM (or container) to build your artifact 41 - A provisioner, which performs the steps to create your artifact 42 - A file provisioner, which downloads the artifact from the VM 43 - The artifice post-processor, which identifies which files have been 44 downloaded from the VM 45 - Additional post-processors, which push the artifact to Atlas, Docker 46 hub, etc. 47 48 You will want to perform as much work as possible inside the VM. Ideally the 49 only other post-processor you need after artifice is one that uploads your 50 artifact to the appropriate repository. 51 52 ## Configuration 53 54 The configuration allows you to specify which files comprise your artifact. 55 56 ### Required: 57 58 - `files` (array of strings) - A list of files that comprise your artifact. 59 These files must exist on your local disk after the provisioning phase of 60 packer is complete. These will replace any of the builder's original 61 artifacts (such as a VM snapshot). 62 63 ### Example Configuration 64 65 This minimal example: 66 67 1. Spins up a cloned VMware virtual machine 68 2. Installs a [consul](https://www.consul.io/) release 69 3. Downloads the consul binary 70 4. Packages it into a `.tar.gz` file 71 5. Uploads it to Atlas. 72 73 VMX is a fast way to build and test locally, but you can easily substitute 74 another builder. 75 76 ``` json 77 { 78 "builders": [ 79 { 80 "type": "vmware-vmx", 81 "source_path": "/opt/ubuntu-1404-vmware.vmx", 82 "ssh_username": "vagrant", 83 "ssh_password": "vagrant", 84 "shutdown_command": "sudo shutdown -h now", 85 "headless":"true", 86 "skip_compaction":"true" 87 } 88 ], 89 "provisioners": [ 90 { 91 "type": "shell", 92 "inline": [ 93 "sudo apt-get install -y python-pip", 94 "sudo pip install ifs", 95 "sudo ifs install consul --version=0.5.2" 96 ] 97 }, 98 { 99 "type": "file", 100 "source": "/usr/local/bin/consul", 101 "destination": "consul", 102 "direction": "download" 103 } 104 ], 105 "post-processors": [ 106 [ 107 { 108 "type": "artifice", 109 "files": ["consul"] 110 }, 111 { 112 "type": "compress", 113 "output": "consul-0.5.2.tar.gz" 114 }, 115 { 116 "type":"atlas", 117 "artifact": "hashicorp/consul", 118 "artifact_type": "archive" 119 } 120 ] 121 ] 122 } 123 ``` 124 125 **Notice that there are two sets of square brackets in the post-processor 126 section.** This creates a post-processor chain, where the output of the 127 proceeding artifact is passed to subsequent post-processors. If you use only one 128 set of square braces the post-processors will run individually against the build 129 artifact (the vmx file in this case) and it will not have the desired result. 130 131 ``` json 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 ``` 150 151 You can create multiple post-processor chains to handle multiple builders (for 152 example, building linux and windows binaries during the same build).