github.com/daniellockard/packer@v0.7.6-0.20141210173435-5a9390934716/website/source/docs/provisioners/ansible-local.html.markdown (about) 1 --- 2 layout: "docs" 3 page_title: "Ansible (Local) Provisioner" 4 description: |- 5 The `ansible-local` Packer provisioner configures Ansible to run on the machine by Packer from local Playbook and Role files. Playbooks and Roles can be uploaded from your local machine to the remote machine. Ansible is run in local mode via the `ansible-playbook` command. 6 --- 7 8 # Ansible Local Provisioner 9 10 Type: `ansible-local` 11 12 The `ansible-local` Packer provisioner configures Ansible to run on the machine by 13 Packer from local Playbook and Role files. Playbooks and Roles can be uploaded 14 from your local machine to the remote machine. Ansible is run in [local mode](http://docs.ansible.com/playbooks_delegation.html#local-playbooks) via the `ansible-playbook` command. 15 16 ## Basic Example 17 18 The example below is fully functional. 19 20 ```javascript 21 { 22 "type": "ansible-local", 23 "playbook_file": "local.yml" 24 } 25 ``` 26 27 ## Configuration Reference 28 29 The reference of available configuration options is listed below. 30 31 Required: 32 33 * `playbook_file` (string) - The playbook file to be executed by ansible. 34 This file must exist on your local system and will be uploaded to the 35 remote machine. 36 37 Optional: 38 39 * `command` (string) - The command to invoke ansible. Defaults to "ansible-playbook". 40 41 * `extra_arguments` (array of strings) - An array of extra arguments to pass to the 42 ansible command. By default, this is empty. 43 44 * `inventory_file` (string) - The inventory file to be used by ansible. 45 This file must exist on your local system and will be uploaded to the 46 remote machine. 47 48 When using an inventory file, it's also required to `--limit` the hosts to 49 the specified host you're buiding. The `--limit` argument can be provided in 50 the `extra_arguments` option. 51 52 An example inventory file may look like: 53 54 ```text 55 [chi-dbservers] 56 db-01 ansible_connection=local 57 db-02 ansible_connection=local 58 59 [chi-appservers] 60 app-01 ansible_connection=local 61 app-02 ansible_connection=local 62 63 [chi:children] 64 chi-dbservers 65 chi-appservers 66 67 [dbservers:children] 68 chi-dbservers 69 70 [appservers:children] 71 chi-appservers 72 ``` 73 74 * `playbook_dir` (string) - a path to the complete ansible directory 75 structure on your local system to be copied to the remote machine 76 as the `staging_directory` before all other files and directories. 77 78 * `playbook_paths` (array of strings) - An array of paths to playbook files on 79 your local system. These will be uploaded to the remote machine under 80 `staging_directory`/playbooks. By default, this is empty. 81 82 * `group_vars` (string) - a path to the directory containing ansible 83 group variables on your local system to be copied to the 84 remote machine. By default, this is empty. 85 86 * `host_vars` (string) - a path to the directory containing ansible 87 host variables on your local system to be copied to the 88 remote machine. By default, this is empty. 89 90 * `role_paths` (array of strings) - An array of paths to role directories on 91 your local system. These will be uploaded to the remote machine under 92 `staging_directory`/roles. By default, this is empty. 93 94 * `staging_directory` (string) - The directory where all the configuration of 95 Ansible by Packer will be placed. By default this is "/tmp/packer-provisioner-ansible-local". 96 This directory doesn't need to exist but must have proper permissions so that 97 the SSH user that Packer uses is able to create directories and write into 98 this folder. If the permissions are not correct, use a shell provisioner prior 99 to this to configure it properly.