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