Add simpler example for chef client in local mode
The existing documentation example looks intimidating as it includes: * variable interpolation * configuration of the chef provisioner * and it misses the `config_template` file In the issue comments, [simpler and complete example](https://github.com/hashicorp/packer/issues/3355#issuecomment-198134727) exists already and works out of the box. This change adds the simpler and complete example, while leaving the more complicated example intact.
This commit is contained in:
parent
5206427a47
commit
8fdd20ec2d
|
@ -286,7 +286,65 @@ directories, append a shell provisioner after Chef to modify them.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
### Chef Client Local Mode
|
### Chef Client Local Mode - Simple
|
||||||
|
|
||||||
|
The following example shows how to run the `chef-client` provisioner in local
|
||||||
|
mode.
|
||||||
|
|
||||||
|
**Packer variables**
|
||||||
|
|
||||||
|
Set the necessary Packer variables using environment variables or provide a [var
|
||||||
|
file](/docs/templates/user-variables.html).
|
||||||
|
|
||||||
|
``` json
|
||||||
|
"variables": {
|
||||||
|
"chef_dir": "/tmp/packer-chef-client"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Setup the** `chef-client` **provisioner**
|
||||||
|
|
||||||
|
Make sure we have the correct directories and permissions for the `chef-client`
|
||||||
|
provisioner. You will need to bootstrap the Chef run by providing the necessary
|
||||||
|
cookbooks using Berkshelf or some other means.
|
||||||
|
|
||||||
|
``` json
|
||||||
|
"provisioners": [
|
||||||
|
...
|
||||||
|
{ "type": "shell", "inline": [ "mkdir -p {{user `chef_dir`}}" ] },
|
||||||
|
{ "type": "file", "source": "./roles", "destination": "{{user `chef_dir`}}" },
|
||||||
|
{ "type": "file", "source": "./cookbooks", "destination": "{{user `chef_dir`}}" },
|
||||||
|
{ "type": "file", "source": "./data_bags", "destination": "{{user `chef_dir`}}" },
|
||||||
|
{ "type": "file", "source": "./environments", "destination": "{{user `chef_dir`}}" },
|
||||||
|
{ "type": "file", "source": "./scripts/install_chef.sh", "destination": "{{user `chef_dir`}}/install_chef.sh" },
|
||||||
|
{
|
||||||
|
"type": "chef-client",
|
||||||
|
"install_command": "sudo bash {{user `chef_dir`}}/install_chef.sh",
|
||||||
|
"server_url": "http://localhost:8889",
|
||||||
|
"config_template": "./config/client.rb.template",
|
||||||
|
"run_list": [ "role[testing]" ],
|
||||||
|
"skip_clean_node": true,
|
||||||
|
"skip_clean_client": true
|
||||||
|
}
|
||||||
|
...
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
And ./config/client.rb.template referenced by the above configuration:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
log_level :info
|
||||||
|
log_location STDOUT
|
||||||
|
local_mode true
|
||||||
|
chef_zero.enabled true
|
||||||
|
ssl_verify_mode "verify_peer"
|
||||||
|
role_path "{{user `chef_dir`}}/roles"
|
||||||
|
data_bag_path "{{user `chef_dir`}}/data_bags"
|
||||||
|
environment_path "{{user `chef_dir`}}/environments"
|
||||||
|
cookbook_path [ "{{user `chef_dir`}}/cookbooks" ]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Chef Client Local Mode - Passing variables
|
||||||
|
|
||||||
The following example shows how to run the `chef-client` provisioner in local
|
The following example shows how to run the `chef-client` provisioner in local
|
||||||
mode, while passing a `run_list` using a variable.
|
mode, while passing a `run_list` using a variable.
|
||||||
|
|
Loading…
Reference in New Issue