github.com/aspring/packer@v0.8.1-0.20150629211158-9db281ac0f89/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_groups` (string) - You can let Packer generate a temporary inventory
    45    for you. It will contains only `127.0.0.1`. Thanks to `inventory_groups`,
    46    packer will set the current machine into different groups and will
    47    generate an inventory like:
    48  
    49    [my_group_1]
    50    127.0.0.1
    51    [my_group_2]
    52    127.0.0.1
    53  
    54  * `inventory_file` (string) - The inventory file to be used by ansible.
    55    This file must exist on your local system and will be uploaded to the
    56    remote machine.
    57  
    58    When using an inventory file, it's also required to `--limit` the hosts to
    59    the specified host you're buiding. The `--limit` argument can be provided in
    60    the `extra_arguments` option.
    61  
    62    An example inventory file may look like:
    63  
    64    ```text
    65    [chi-dbservers]
    66    db-01 ansible_connection=local
    67    db-02 ansible_connection=local
    68  
    69    [chi-appservers]
    70    app-01 ansible_connection=local
    71    app-02 ansible_connection=local
    72  
    73    [chi:children]
    74    chi-dbservers
    75    chi-appservers
    76  
    77    [dbservers:children]
    78    chi-dbservers
    79  
    80    [appservers:children]
    81    chi-appservers
    82    ```
    83  
    84  * `playbook_dir` (string) - a path to the complete ansible directory
    85    structure on your local system to be copied to the remote machine
    86    as the `staging_directory` before all other files and directories.
    87  
    88  * `playbook_paths` (array of strings) - An array of paths to playbook files on
    89    your local system. These will be uploaded to the remote machine under
    90    `staging_directory`/playbooks. By default, this is empty.
    91  
    92  * `group_vars` (string) - a path to the directory containing ansible
    93    group variables on your local system to be copied to the
    94    remote machine. By default, this is empty.
    95  
    96  * `host_vars` (string) - a path to the directory containing ansible
    97    host variables on your local system to be copied to the
    98    remote machine. By default, this is empty.
    99  
   100  * `role_paths` (array of strings) - An array of paths to role directories on
   101    your local system. These will be uploaded to the remote machine under
   102    `staging_directory`/roles. By default, this is empty.
   103  
   104  * `staging_directory` (string) - The directory where all the configuration of
   105    Ansible by Packer will be placed. By default this is "/tmp/packer-provisioner-ansible-local".
   106    This directory doesn't need to exist but must have proper permissions so that
   107    the SSH user that Packer uses is able to create directories and write into
   108    this folder. If the permissions are not correct, use a shell provisioner prior
   109    to this to configure it properly.