github.com/kikitux/packer@v0.10.1-0.20160322154024-6237df566f9f/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  
    56  -   `inventory_groups` (string) - A comma-separated list of groups to which
    57      packer will assign the host `127.0.0.1`. A value of `my_group_1,my_group_2`
    58      will generate an Ansible inventory like:
    59  
    60  ```{.text}
    61  [my_group_1]
    62  127.0.0.1
    63  [my_group_2]
    64  127.0.0.1
    65  ```
    66  
    67  -   `inventory_file` (string) - The inventory file to be used by ansible. This
    68      file must exist on your local system and will be uploaded to the
    69      remote machine.
    70  
    71  When using an inventory file, it's also required to `--limit` the hosts to the
    72  specified host you're buiding. The `--limit` argument can be provided in the
    73  `extra_arguments` option.
    74  
    75  An example inventory file may look like:
    76  
    77  ```{.text}
    78  [chi-dbservers]
    79  db-01 ansible_connection=local
    80  db-02 ansible_connection=local
    81  
    82  [chi-appservers]
    83  app-01 ansible_connection=local
    84  app-02 ansible_connection=local
    85  
    86  [chi:children]
    87  chi-dbservers
    88  chi-appservers
    89  
    90  [dbservers:children]
    91  chi-dbservers
    92  
    93  [appservers:children]
    94  chi-appservers
    95  ```
    96  
    97  -   `playbook_dir` (string) - a path to the complete ansible directory structure
    98      on your local system to be copied to the remote machine as the
    99      `staging_directory` before all other files and directories.
   100  
   101  -   `playbook_paths` (array of strings) - An array of paths to playbook files on
   102      your local system. These will be uploaded to the remote machine under
   103      `staging_directory`/playbooks. By default, this is empty.
   104  
   105  -   `group_vars` (string) - a path to the directory containing ansible group
   106      variables on your local system to be copied to the remote machine. By
   107      default, this is empty.
   108  
   109  -   `host_vars` (string) - a path to the directory containing ansible host
   110      variables on your local system to be copied to the remote machine. By
   111      default, this is empty.
   112  
   113  -   `role_paths` (array of strings) - An array of paths to role directories on
   114      your local system. These will be uploaded to the remote machine under
   115      `staging_directory`/roles. By default, this is empty.
   116  
   117  -   `staging_directory` (string) - The directory where all the configuration of
   118      Ansible by Packer will be placed. By default this
   119      is "/tmp/packer-provisioner-ansible-local". This directory doesn't need to
   120      exist but must have proper permissions so that the SSH user that Packer uses
   121      is able to create directories and write into this folder. If the permissions
   122      are not correct, use a shell provisioner prior to this to configure
   123      it properly.