From 0a3ff3b190d5116e5b3578bff85b29e9bbe1f29d Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Tue, 11 Aug 2020 16:20:56 -0700 Subject: [PATCH] ansible-local hcl docs --- .../pages/docs/provisioners/ansible-local.mdx | 68 ++++++++++++++++++- 1 file changed, 66 insertions(+), 2 deletions(-) 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.