"Fossies" - the Fresh Open Source Software Archive

Member "vagrant-2.2.14/website/pages/docs/provisioning/ansible_common.mdx" (20 Nov 2020, 9392 Bytes) of package /linux/misc/vagrant-2.2.14.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 ---
    2 layout: docs
    3 page_title: Common Ansible Options - Provisioning
    4 sidebar_title: Common Ansible Options
    5 description: This page details the common options to the Vagrant Ansible provisioners.
    6 ---
    7 
    8 # Shared Ansible Options
    9 
   10 The following options are available to both Vagrant Ansible provisioners:
   11 
   12 - [`ansible`](/docs/provisioning/ansible)
   13 - [`ansible_local`](/docs/provisioning/ansible_local)
   14 
   15 These options get passed to the `ansible-playbook` command that ships with Ansible, either via command line arguments or environment variables, depending on Ansible own capabilities.
   16 
   17 Some of these options are for advanced usage only and should not be used unless you understand their purpose.
   18 
   19 - `become` (boolean) - Perform all the Ansible playbook tasks [as another user](http://docs.ansible.com/ansible/become.html), different from the user used to log into the guest system.
   20 
   21   The default value is `false`.
   22 
   23 - `become_user` (string) - Set the default username to be used by the Ansible `become` [privilege escalation](http://docs.ansible.com/ansible/become.html) mechanism.
   24 
   25   By default this option is not set, and the Ansible default value (`root`) will be used.
   26 
   27 - `compatibility_mode` (string) - Set the **minimal** version of Ansible to be supported. Vagrant will only use parameters that are compatible with the given version.
   28 
   29   Possible values:
   30 
   31   - `"auto"` _(Vagrant will automatically select the optimal compatibility mode by checking the Ansible version currently available)_
   32   - `"1.8"` _(Ansible versions prior to 1.8 should mostly work well, but some options might not be supported)_
   33   - `"2.0"` _(The generated Ansible inventory will be incompatible with Ansible 1.x)_
   34 
   35   By default this option is set to `"auto"`. If Vagrant is not able to detect any supported Ansible version, it will fall back on the compatibility mode `"1.8"` with a warning.
   36 
   37   Vagrant will error if the specified compatibility mode is incompatible with the current Ansible version.
   38 
   39   ~> **Attention:** Vagrant doesn't perform any validation between the `compatibility_mode` value and the value of the [`version`](#version) option.
   40 
   41   -> **Compatibility Note:** This option was introduced in Vagrant 2.0. The behavior of previous Vagrant versions can be simulated by setting the `compatibility_mode` to `"1.8"`.
   42 
   43 - `config_file` (string) - The path to an [Ansible Configuration file](https://docs.ansible.com/intro_configuration.html).
   44 
   45   By default, this option is not set, and Ansible will [search for a possible configuration file in some default locations](/docs/provisioning/ansible_intro#the-ansible-configuration-file).
   46 
   47 - `extra_vars` (string or hash) - Pass additional variables (with highest priority) to the playbook.
   48 
   49   This parameter can be a path to a JSON or YAML file, or a hash.
   50 
   51   Example:
   52 
   53   ```ruby
   54   ansible.extra_vars = {
   55     ntp_server: "pool.ntp.org",
   56     nginx: {
   57       port: 8008,
   58       workers: 4
   59     }
   60   }
   61   ```
   62 
   63   These variables take the highest precedence over any other variables.
   64 
   65 - `galaxy_command` (template string) - The command pattern used to install Galaxy roles when `galaxy_role_file` is set.
   66 
   67   The following (optional) placeholders can be used in this command pattern:
   68 
   69   - `%{role_file}` is replaced by the absolute path to the `galaxy_role_file` option
   70   - `%{roles_path}` is
   71     - replaced by the absolute path to the `galaxy_roles_path` option when such option is defined, or
   72     - replaced by the absolute path to a `roles` subdirectory sitting in the `playbook` parent directory.
   73 
   74   By default, this option is set to
   75 
   76   `ansible-galaxy install --role-file=%{role_file} --roles-path=%{roles_path} --force`
   77 
   78 - `galaxy_role_file` (string) - The path to the Ansible Galaxy role file.
   79 
   80   By default, this option is set to `nil` and Galaxy support is then disabled.
   81 
   82   Note: if an absolute path is given, the `ansible_local` provisioner will assume that it corresponds to the exact location on the guest system.
   83 
   84   ```ruby
   85   ansible.galaxy_role_file = "requirements.yml"
   86   ```
   87 
   88 - `galaxy_roles_path` (string) - The path to the directory where Ansible Galaxy roles must be installed
   89 
   90   By default, this option is set to `nil`, which means that the Galaxy roles will be installed in a `roles` subdirectory located in the parent directory of the `playbook` file.
   91 
   92 - `groups` (hash) - Set of inventory groups to be included in the [auto-generated inventory file](/docs/provisioning/ansible_intro).
   93 
   94   Example:
   95 
   96   ```ruby
   97   ansible.groups = {
   98     "web" => ["vm1", "vm2"],
   99     "db"  => ["vm3"]
  100   }
  101   ```
  102 
  103   Example with [group variables](https://docs.ansible.com/ansible/intro_inventory.html#group-variables):
  104 
  105   ```ruby
  106   ansible.groups = {
  107     "atlanta" => ["host1", "host2"],
  108     "atlanta:vars" => {"ntp_server" => "ntp.atlanta.example.com",
  109                        "proxy" => "proxy.atlanta.example.com"}
  110   }
  111   ```
  112 
  113   Notes:
  114 
  115   - Alphanumeric patterns are not supported (e.g. `db-[a:f]`, `vm[01:10]`).
  116   - This option has no effect when the `inventory_path` option is defined.
  117 
  118 - `host_vars` (hash) - Set of inventory host variables to be included in the [auto-generated inventory file](https://docs.ansible.com/ansible/intro_inventory.html#host-variables).
  119 
  120   Example:
  121 
  122   ```ruby
  123   ansible.host_vars = {
  124     "host1" => {"http_port" => 80,
  125                 "maxRequestsPerChild" => 808,
  126                 "comments" => "text with spaces"},
  127     "host2" => {"http_port" => 303,
  128                 "maxRequestsPerChild" => 909}
  129   }
  130   ```
  131 
  132   Note: This option has no effect when the `inventory_path` option is defined.
  133 
  134 - `inventory_path` (string) - The path to an Ansible inventory resource (e.g. a [static inventory file](https://docs.ansible.com/intro_inventory.html), a [dynamic inventory script](https://docs.ansible.com/intro_dynamic_inventory.html) or even [multiple inventories stored in the same directory](https://docs.ansible.com/intro_dynamic_inventory.html#using-multiple-inventory-sources)).
  135 
  136   By default, this option is disabled and Vagrant generates an inventory based on the `Vagrantfile` information.
  137 
  138 - `limit` (string or array of strings) - Set of machines or groups from the inventory file to further control which hosts [are affected](https://docs.ansible.com/glossary.html#limit-groups).
  139 
  140   The default value is set to the machine name (taken from `Vagrantfile`) to ensure that `vagrant provision` command only affect the expected machine.
  141 
  142   Setting `limit = "all"` can be used to make Ansible connect to all machines from the inventory file.
  143 
  144 - `playbook_command` (string) - The command used to run playbooks.
  145 
  146   The default value is `ansible-playbook`
  147 
  148 - `raw_arguments` (array of strings) - a list of additional `ansible-playbook` arguments.
  149 
  150   It is an _unsafe wildcard_ that can be used to apply Ansible options that are not (yet) supported by this Vagrant provisioner. As of Vagrant 1.7, `raw_arguments` has the highest priority and its values can potentially override or break other Vagrant settings.
  151 
  152   Examples:
  153 
  154   - `['--check', '-M', '/my/modules']`
  155   - `["--connection=paramiko", "--forks=10"]`
  156 
  157     ~> **Attention:** The `ansible` provisioner does not support whitespace characters in `raw_arguments`
  158     elements. Therefore **don't write** something like `["-c paramiko"]`, which
  159     will result with an invalid `" paramiko"` parameter value.
  160 
  161 - `skip_tags` (string or array of strings) - Only plays, roles and tasks that [_do not match_ these values will be executed](https://docs.ansible.com/playbooks_tags.html).
  162 
  163 - `start_at_task` (string) - The task name where the [playbook execution will start](https://docs.ansible.com/playbooks_startnstep.html#start-at-task).
  164 
  165 - `sudo` (boolean) - Backwards compatible alias for the [`become`](#become) option.
  166 
  167   ~> **Deprecation:**
  168   The `sudo` option is deprecated and will be removed in a future release. Please use the [**`become`**](#become) option instead.
  169 
  170 * `sudo_user` (string) - Backwards compatible alias for the [`become_user`](#become_user) option.
  171 
  172   ~> **Deprecation:**
  173   The `sudo_user` option is deprecated and will be removed in a future release. Please use the [**`become_user`**](#become_user) option instead.
  174 
  175 - `tags` (string or array of strings) - Only plays, roles and tasks [tagged with these values will be executed](https://docs.ansible.com/playbooks_tags.html) .
  176 
  177 - `vault_password_file` (string) - The path of a file containing the password used by [Ansible Vault](https://docs.ansible.com/playbooks_vault.html#vault).
  178 
  179 - `verbose` (boolean or string) - Set Ansible's verbosity to obtain detailed logging
  180 
  181   Default value is `false` (minimal verbosity).
  182 
  183   Examples: `true` (equivalent to `v`), `-vvv` (equivalent to `vvv`), `vvvv`.
  184 
  185   Note that when the `verbose` option is enabled, the `ansible-playbook` command used by Vagrant will be displayed.
  186 
  187 - `version` (string) - The expected Ansible version.
  188 
  189   This option is disabled by default.
  190 
  191   When an Ansible version is defined (e.g. `"2.1.6.0"`), the Ansible provisioner will be executed only if Ansible is installed at the requested version.
  192 
  193   When this option is set to `"latest"`, no version check is applied.
  194 
  195   -> **Tip:** With the `ansible_local` provisioner, it is currently possible to use this option
  196   to specify which version of Ansible must be automatically installed, but **only** in combination with the [**`install_mode`**](/docs/provisioning/ansible_local#install_mode) set to **`:pip`**.