github.com/ncodes/nomad@v0.5.7-0.20170403112158-97adf4a74fb3/website/source/docs/commands/plan.html.md.erb (about) 1 --- 2 layout: "docs" 3 page_title: "Commands: plan" 4 sidebar_current: "docs-commands-plan" 5 description: > 6 The plan command is used to dry-run a job update to determine its effects. 7 --- 8 9 # Command: plan 10 11 The `plan` command can be used to envoke the scheduler in a dry-run mode with 12 new jobs or when updating existing jobs to determine what would happen if the 13 job is submitted. Job files must conform to the [job 14 specification](/docs/job-specification/index.html) format. 15 16 ## Usage 17 18 ``` 19 nomad plan [options] <path> 20 ``` 21 22 The plan command requires a single argument, specifying the path to a file 23 containing a [HCL job specification](/docs/job-specification/index.html). This 24 file will be read and the resulting parsed job will be validated. If the 25 supplied path is "-", the job file is read from STDIN. Otherwise it is read 26 from the file at the supplied path or downloaded and read from URL specified. 27 Nomad downloads the job file using 28 [`go-getter`](https://github.com/hashicorp/go-getter) 29 and supports `go-getter` syntax. 30 31 Plan invokes a dry-run of the scheduler to determine the effects of submitting 32 either a new or updated version of a job. The plan will not result in any 33 changes to the cluster but gives insight into whether the job could be run 34 successfully and how it would affect existing allocations. 35 36 A job modify index is returned with the plan. This value can be used when 37 submitting the job using [`nomad run 38 -check-index`](/docs/commands/run.html#check-index), which will check that the 39 job was not modified between the plan and run command before invoking the 40 scheduler. This ensures the job has not been modified since the plan. 41 42 A structured diff between the local and remote job is displayed to 43 give insight into what the scheduler will attempt to do and why. 44 45 If the job has specified the region, the `-region` flag and `NOMAD_REGION` 46 environment variable are overridden and the job's region is used. 47 48 Plan will return one of the following exit codes: 49 50 * 0: No allocations created or destroyed. 51 * 1: Allocations created or destroyed. 52 * 255: Error determining plan results. 53 54 ## General Options 55 56 <%= partial "docs/commands/_general_options" %> 57 58 ## Plan Options 59 60 * `-diff`: Determines whether the diff between the remote job and planned job is 61 shown. Defaults to true. 62 63 * `-verbose`: Increase diff verbosity. 64 65 ## Examples 66 67 Plan a new job that has not been previously submitted: 68 69 ``` 70 $ nomad run job1.nomad 71 nomad plan example.nomad 72 + Job: "example" 73 + Task Group: "cache" (1 create) 74 + Task: "redis" (forces create) 75 76 Scheduler dry-run: 77 - All tasks successfully allocated. 78 79 Job Modify Index: 0 80 To submit the job with version verification run: 81 82 nomad run -check-index 0 example.nomad 83 84 When running the job with the check-index flag, the job will only be run if the 85 server side version matches the job modify index returned. If the index has 86 changed, another user has modified the job and the plan's results are 87 potentially invalid. 88 ``` 89 90 91 Increase the count of an existing without sufficient cluster capacity: 92 93 ``` 94 $ nomad plan example.nomad 95 +/- Job: "example" 96 +/- Task Group: "cache" (7 create, 1 in-place update) 97 +/- Count: "1" => "8" (forces create) 98 Task: "redis" 99 100 Scheduler dry-run: 101 - WARNING: Failed to place all allocations. 102 Task Group "cache" (failed to place 3 allocations): 103 * Resources exhausted on 1 nodes 104 * Dimension "cpu exhausted" exhausted on 1 nodes 105 106 Job Modify Index: 15 107 To submit the job with version verification run: 108 109 nomad run -check-index 15 example.nomad 110 111 When running the job with the check-index flag, the job will only be run if the 112 server side version matches the job modify index returned. If the index has 113 changed, another user has modified the job and the plan's results are 114 potentially invalid. 115 ``` 116 117 Update an existing job such that it would cause a rolling update: 118 119 ``` 120 $ nomad plan example.nomad 121 +/- Job: "example" 122 +/- Task Group: "cache" (3 create/destroy update) 123 +/- Task: "redis" (forces create/destroy update) 124 +/- Config { 125 +/- image: "redis:2.8" => "redis:3.2" 126 port_map[0][db]: "6379" 127 } 128 129 Scheduler dry-run: 130 - All tasks successfully allocated. 131 - Rolling update, next evaluation will be in 10s. 132 133 Job Modify Index: 7 134 To submit the job with version verification run: 135 136 nomad run -check-index 7 example.nomad 137 138 When running the job with the check-index flag, the job will only be run if the 139 server side version matches the job modify index returned. If the index has 140 changed, another user has modified the job and the plan's results are 141 potentially invalid. 142 ``` 143 144 Add a task to the task group using verbose mode: 145 146 ``` 147 $ nomad plan -verbose example.nomad 148 +/- Job: "example" 149 +/- Task Group: "cache" (3 create/destroy update) 150 + Task: "my-website" (forces create/destroy update) 151 + Driver: "docker" 152 + KillTimeout: "5000000000" 153 + Config { 154 + image: "node:6.2" 155 + port_map[0][web]: "80" 156 } 157 + Resources { 158 + CPU: "500" 159 + DiskMB: "300" 160 + IOPS: "0" 161 + MemoryMB: "256" 162 + Network { 163 + MBits: "10" 164 + Dynamic Port { 165 + Label: "web" 166 } 167 } 168 } 169 + LogConfig { 170 + MaxFileSizeMB: "10" 171 + MaxFiles: "10" 172 } 173 + Service { 174 + Name: "website" 175 + PortLabel: "web" 176 + Check { 177 Command: "" 178 + Interval: "10000000000" 179 + Name: "alive" 180 Path: "" 181 Protocol: "" 182 + Timeout: "2000000000" 183 + Type: "tcp" 184 } 185 } 186 Task: "redis" 187 188 Scheduler dry-run: 189 - All tasks successfully allocated. 190 - Rolling update, next evaluation will be in 10s. 191 192 Job Modify Index: 7 193 To submit the job with version verification run: 194 195 nomad run -check-index 7 example.nomad 196 197 When running the job with the check-index flag, the job will only be run if the 198 server side version matches the job modify index returned. If the index has 199 changed, another user has modified the job and the plan's results are 200 potentially invalid. 201 ```