summaryrefslogtreecommitdiff
path: root/devdocs/vagrant/provisioning%2Fansible_common.html
blob: 70d86df89b29835c4d53d34d59afe2551820d3ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<h1 id="shared-ansible-options">  Shared Ansible Options </h1> <p>The following options are available to both Vagrant Ansible provisioners:</p> <ul> <li>
<a href="ansible"><code>ansible</code></a> </li> <li>
<a href="ansible_local"><code>ansible_local</code></a> </li> </ul> <p>These options get passed to the <code>ansible-playbook</code> command that ships with Ansible, either via command line arguments or environment variables, depending on Ansible own capabilities.</p> <p>Some of these options are for advanced usage only and should not be used unless you understand their purpose.</p> <ul> <li>
<p><a href="#become"><code>become</code></a> (boolean) - Perform all the Ansible playbook tasks <a href="http://docs.ansible.com/ansible/become.html">as another user</a>, different from the user used to log into the guest system.</p> <p>The default value is <code>false</code>.</p> </li> <li>
<p><a href="#become_user"><code>become_user</code></a> (string) - Set the default username to be used by the Ansible <code>become</code> <a href="http://docs.ansible.com/ansible/become.html">privilege escalation</a> mechanism.</p> <p>By default this option is not set, and the Ansible default value (<code>root</code>) will be used.</p> </li> <li>
<p><a href="#compatibility_mode"><code>compatibility_mode</code></a> (string) - Set the <strong>minimal</strong> version of Ansible to be supported. Vagrant will only use parameters that are compatible with the given version.</p> <p>Possible values:</p> <ul> <li>
<a href="#quot-auto-quot-"><code>"auto"</code></a> <em>(Vagrant will automatically select the optimal compatibility mode by checking the Ansible version currently available)</em> </li> <li>
<a href="#quot-1-8-quot-"><code>"1.8"</code></a> <em>(Ansible versions prior to 1.8 should mostly work well, but some options might not be supported)</em> </li> <li>
<a href="#quot-2-0-quot-"><code>"2.0"</code></a> <em>(The generated Ansible inventory will be incompatible with Ansible 1.x)</em> </li> </ul> <p>By default this option is set to <code>"auto"</code>. If Vagrant is not able to detect any supported Ansible version, it will fall back on the compatibility mode <code>"1.8"</code> with a warning.</p> <p>Vagrant will error if the specified compatibility mode is incompatible with the current Ansible version.</p> <blockquote class="alert alert-warning"> <p><strong>Attention:</strong> Vagrant doesn't perform any validation between the <code>compatibility_mode</code> value and the value of the <a href="#version"><code>version</code></a> option.</p> </blockquote>
<blockquote class="alert alert-info"> <p><strong>Compatibility Note:</strong> This option was introduced in Vagrant 2.0. The behavior of previous Vagrant versions can be simulated by setting the <code>compatibility_mode</code> to <code>"1.8"</code>.</p> </blockquote>
</li> <li>
<p><a href="#config_file"><code>config_file</code></a> (string) - The path to an <a href="https://docs.ansible.com/intro_configuration.html">Ansible Configuration file</a>.</p> <p>By default, this option is not set, and Ansible will <a href="ansible_intro#ANSIBLE_CONFIG">search for a possible configuration file in some default locations</a>.</p> </li> <li>
<p><a href="#extra_vars"><code>extra_vars</code></a> (string or hash) - Pass additional variables (with highest priority) to the playbook.</p> <p>This parameter can be a path to a JSON or YAML file, or a hash.</p> <p>Example:</p> <div class="highlight"><pre class="highlight ruby" data-language="ruby">ansible.extra_vars = {
  ntp_server: "pool.ntp.org",
  nginx: {
    port: 8008,
    workers: 4
  }
}
</pre></div>
<p>These variables take the highest precedence over any other variables.</p> </li> <li>
<p><a href="#galaxy_command"><code>galaxy_command</code></a> (template string) - The command pattern used to install Galaxy roles when <code>galaxy_role_file</code> is set.</p> <p>The following (optional) placeholders can be used in this command pattern:</p> <ul> <li>
<a href="#role_file-"><code>%{role_file}</code></a> is replaced by the absolute path to the <code>galaxy_role_file</code> option </li> <li>
<a href="#roles_path-"><code>%{roles_path}</code></a> is <ul> <li>replaced by the absolute path to the <code>galaxy_roles_path</code> option when such option is defined, or </li> <li>replaced by the absolute path to a <code>roles</code> subdirectory sitting in the <code>playbook</code> parent directory. </li> </ul> </li> </ul> <p>By default, this option is set to</p> <p><code>ansible-galaxy install --role-file=%{role_file} --roles-path=%{roles_path} --force</code></p> </li> <li>
<p><a href="#galaxy_role_file"><code>galaxy_role_file</code></a> (string) - The path to the Ansible Galaxy role file.</p> <p>By default, this option is set to <code>nil</code> and Galaxy support is then disabled.</p> <p>Note: if an absolute path is given, the <code>ansible_local</code> provisioner will assume that it corresponds to the exact location on the guest system.</p> <div class="highlight"><pre class="highlight ruby" data-language="ruby">ansible.galaxy_role_file = "requirements.yml"
</pre></div>
</li> <li>
<p><a href="#galaxy_roles_path"><code>galaxy_roles_path</code></a> (string) - The path to the directory where Ansible Galaxy roles must be installed</p> <p>By default, this option is set to <code>nil</code>, which means that the Galaxy roles will be installed in a <code>roles</code> subdirectory located in the parent directory of the <code>playbook</code> file.</p> </li> <li>
<p><a href="#groups"><code>groups</code></a> (hash) - Set of inventory groups to be included in the <a href="ansible_intro">auto-generated inventory file</a>.</p> <p>Example:</p> <div class="highlight"><pre class="highlight ruby" data-language="ruby">ansible.groups = {
  "web" =&gt; ["vm1", "vm2"],
  "db"  =&gt; ["vm3"]
}
</pre></div>
<p>Example with <a href="https://docs.ansible.com/ansible/intro_inventory.html#group-variables">group variables</a>:</p> <div class="highlight"><pre class="highlight ruby" data-language="ruby">ansible.groups = {
  "atlanta" =&gt; ["host1", "host2"],
  "atlanta:vars" =&gt; {"ntp_server" =&gt; "ntp.atlanta.example.com",
                     "proxy" =&gt; "proxy.atlanta.example.com"}
}
</pre></div>
<p>Notes:</p> <ul> <li>Alphanumeric patterns are not supported (e.g. <code>db-[a:f]</code>, <code>vm[01:10]</code>). </li> <li>This option has no effect when the <code>inventory_path</code> option is defined. </li> </ul> </li> <li>
<p><a href="#host_vars"><code>host_vars</code></a> (hash) - Set of inventory host variables to be included in the <a href="https://docs.ansible.com/ansible/intro_inventory.html#host-variables">auto-generated inventory file</a>.</p> <p>Example:</p> <div class="highlight"><pre class="highlight ruby" data-language="ruby">ansible.host_vars = {
  "host1" =&gt; {"http_port" =&gt; 80,
              "maxRequestsPerChild" =&gt; 808},
              "comments" =&gt; "text with spaces",
  "host2" =&gt; {"http_port" =&gt; 303,
              "maxRequestsPerChild" =&gt; 909}
}
</pre></div>
<p>Note: This option has no effect when the <code>inventory_path</code> option is defined.</p> </li> <li>
<p><a href="#inventory_path"><code>inventory_path</code></a> (string) - The path to an Ansible inventory resource (e.g. a <a href="https://docs.ansible.com/intro_inventory.html">static inventory file</a>, a <a href="https://docs.ansible.com/intro_dynamic_inventory.html">dynamic inventory script</a> or even <a href="https://docs.ansible.com/intro_dynamic_inventory.html#using-multiple-inventory-sources">multiple inventories stored in the same directory</a>).</p> <p>By default, this option is disabled and Vagrant generates an inventory based on the <code>Vagrantfile</code> information.</p> </li> <li>
<p><a href="#limit"><code>limit</code></a> (string or array of strings) - Set of machines or groups from the inventory file to further control which hosts <a href="https://docs.ansible.com/glossary.html#limit-groups">are affected</a>.</p> <p>The default value is set to the machine name (taken from <code>Vagrantfile</code>) to ensure that <code>vagrant provision</code> command only affect the expected machine.</p> <p>Setting <code>limit = "all"</code> can be used to make Ansible connect to all machines from the inventory file.</p> </li> <li>
<p><a href="#playbook_command"><code>playbook_command</code></a> (string) - The command used to run playbooks.</p> <p>The default value is <code>ansible-playbook</code></p> </li> <li>
<p><a href="#raw_arguments"><code>raw_arguments</code></a> (array of strings) - a list of additional <code>ansible-playbook</code> arguments.</p> <p>It is an <em>unsafe wildcard</em> that can be used to apply Ansible options that are not (yet) supported by this Vagrant provisioner. As of Vagrant 1.7, <code>raw_arguments</code> has the highest priority and its values can potentially override or break other Vagrant settings.</p> <p>Examples:</p> <ul> <li>
<a href="#39-check-39-39-m-39-39-my-modules-39-"><code>['--check', '-M', '/my/modules']</code></a> </li> <li>
<a href="#quot-connection-paramiko-quot-quot-forks-10-quot-"><code>["--connection=paramiko", "--forks=10"]</code></a> </li> </ul> <blockquote class="alert alert-warn"> <p><strong>Attention:</strong> The <code>ansible</code> provisioner does not support whitespace characters in <code>raw_arguments</code> elements. Therefore <strong>don't write</strong> something like <code>["-c paramiko"]</code>, which will result with an invalid <code>" paramiko"</code> parameter value.</p> </blockquote>
</li> <li>
<p><a href="#skip_tags"><code>skip_tags</code></a> (string or array of strings) - Only plays, roles and tasks that <a href="https://docs.ansible.com/playbooks_tags.html"><em>do not match</em> these values will be executed</a>.</p> </li> <li>
<p><a href="#start_at_task"><code>start_at_task</code></a> (string) - The task name where the <a href="https://docs.ansible.com/playbooks_startnstep.html#start-at-task">playbook execution will start</a>.</p> </li> <li>
<p><a href="#sudo"><code>sudo</code></a> (boolean) - Backwards compatible alias for the <a href="#become"><code>become</code></a> option.</p> <blockquote class="alert alert-warning"> <p><strong>Deprecation:</strong> The <code>sudo</code> option is deprecated and will be removed in a future release. Please use the <a href="#become"><strong><code>become</code></strong></a> option instead.</p> </blockquote>
</li> <li>
<p><a href="#sudo_user"><code>sudo_user</code></a> (string) - Backwards compatible alias for the <a href="#become_user"><code>become_user</code></a> option.</p> <blockquote class="alert alert-warning"> <p><strong>Deprecation:</strong> The <code>sudo_user</code> option is deprecated and will be removed in a future release. Please use the <a href="#become_user"><strong><code>become_user</code></strong></a> option instead.</p> </blockquote>
</li> <li>
<p><a href="#tags"><code>tags</code></a> (string or array of strings) - Only plays, roles and tasks <a href="https://docs.ansible.com/playbooks_tags.html">tagged with these values will be executed</a> .</p> </li> <li>
<p><a href="#vault_password_file"><code>vault_password_file</code></a> (string) - The path of a file containing the password used by <a href="https://docs.ansible.com/playbooks_vault.html#vault">Ansible Vault</a>.</p> </li> <li>
<p><a href="#verbose"><code>verbose</code></a> (boolean or string) - Set Ansible's verbosity to obtain detailed logging</p> <p>Default value is <code>false</code> (minimal verbosity).</p> <p>Examples: <code>true</code> (equivalent to <code>v</code>), <code>-vvv</code> (equivalent to <code>vvv</code>), <code>vvvv</code>.</p> <p>Note that when the <code>verbose</code> option is enabled, the <code>ansible-playbook</code> command used by Vagrant will be displayed.</p> </li> <li>
<p><a href="#version"><code>version</code></a> (string) - The expected Ansible version.</p> <p>This option is disabled by default.</p> <p>When an Ansible version is defined (e.g. <code>"2.1.6.0"</code>), the Ansible provisioner will be executed only if Ansible is installed at the requested version.</p> <p>When this option is set to <code>"latest"</code>, no version check is applied.</p> <blockquote class="alert alert-info"> <p><strong>Tip:</strong> With the <code>ansible_local</code> provisioner, it is currently possible to use this option to specify which version of Ansible must be automatically installed, but <strong>only</strong> in combination with the <a href="ansible_local#install_mode"><strong><code>install_mode</code></strong></a> set to <strong><code>:pip</code></strong>.</p> </blockquote>
</li> </ul><div class="_attribution">
  <p class="_attribution-p">
    &copy; 2010&ndash;2018 Mitchell Hashimoto<br>Licensed under the MPL 2.0 License.<br>
    <a href="https://www.vagrantup.com/docs/provisioning/ansible_common.html" class="_attribution-link">https://www.vagrantup.com/docs/provisioning/ansible_common.html</a>
  </p>
</div>