diff --git a/website/pages/docs/provisioners/ansible-local.mdx b/website/pages/docs/provisioners/ansible-local.mdx index 1c2591285..221c890e1 100644 --- a/website/pages/docs/provisioners/ansible-local.mdx +++ b/website/pages/docs/provisioners/ansible-local.mdx @@ -32,13 +32,77 @@ do this. The example below is fully functional. + + + ```json { - "type": "ansible-local", - "playbook_file": "local.yml" + "builders": [ + { + "type": "docker", + "image": "williamyeh/ansible:ubuntu14.04", + "export_path": "packer_example", + "run_command": [ "-d", "-i", "-t", "--entrypoint=/bin/bash", "{{.Image}}" ] + } + ], + "variables": + { + "topping": "mushroom" + }, + "provisioners": [ + { + "type": "ansible-local", + "playbook_file": "./playbook.yml", + "extra_arguments": ["--extra-vars", "\"pizza_toppings={{ user `topping`}}\""] + } + ] } ``` + + + +```hcl +variable "topping" { + type = string + default = "mushroom" +} + +source "docker" "example" { + image = "williamyeh/ansible:ubuntu14.04" + export_path = "packer_example" + run_command = ["-d", "-i", "-t", "--entrypoint=/bin/bash", "{{.Image}}"] +} + +build { + sources = [ + "source.docker.example" + ] + + provisioner "ansible-local" { + playbook_file = "./playbook.yml" + extra_arguments = ["--extra-vars", "\"pizza_toppings=${var.topping}\""] + } +} +``` + + + + +where ./playbook.yml contains + +``` +--- +- name: hello world + hosts: 127.0.0.1 + connection: local + + tasks: + - command: echo {{ pizza_toppings }} + - debug: msg="{{ pizza_toppings }}" + +``` + ## Configuration Reference The reference of available configuration options is listed below.