With this new option defined, the `ansible-galaxy` and
`ansible-playbook` commands generated by the Ansible provisioners will
be executed with the ANSIBLE_CONFIG environment variable set
accordingly.
Resolve GH-7195
This commit also fix the following open issues:
- Implement the pending RSpec examples about path existence checks
performed by the ansible (remote) provisioner.
- In verbose mode, the ansible remote provisioner now correctly displays
the Ansible Galaxy parameters ("role_file" and "roles_path") with
single quotes (which is safer for potential copy-paste usage).
Additional Notes:
- Test coverage for `ansible_local` provisioner is still not
implemented. See GH-6633.
- Test coverage for galaxy from host is not implemented yet (due to
general issue with mocking both command executions, see
https://github.com/mitchellh/vagrant/pull/6529#r45278451
6.8 KiB
| layout | page_title | sidebar_current | description |
|---|---|---|---|
| docs | Common Ansible Options - Provisioning | provisioning-ansible-common | This page details the common options to the Vagrant Ansible provisioners. |
Shared Ansible Options
The following options are available to both Vagrant Ansible provisioners:
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.
Some of these options are for advanced usage only and should not be used unless you understand their purpose.
-
config_file(string) - The path to an Ansible Configuration file.By default, this option is not set, and Ansible will search for a possible configuration file in some default locations.
-
extra_vars(string or hash) - Pass additional variables (with highest priority) to the playbook.This parameter can be a path to a JSON or YAML file, or a hash.
Example:
ansible.extra_vars = { ntp_server: "pool.ntp.org", nginx: { port: 8008, workers: 4 } }These variables take the highest precedence over any other variables.
-
galaxy_command(template string) - The command pattern used to install Galaxy roles whengalaxy_role_fileis set.The following (optional) placeholders can be used in this command pattern:
%{role_file}is replaced by the absolute path to thegalaxy_role_fileoption%{roles_path}is- replaced by the absolute path to the
galaxy_roles_pathoption when such option is defined, or - replaced by the absolute path to a
rolessubdirectory sitting in theplaybookparent directory.
- replaced by the absolute path to the
By default, this option is set to
ansible-galaxy install --role-file=%{role_file} --roles-path=%{roles_path} --force -
galaxy_role_file(string) - The path to the Ansible Galaxy role file.By default, this option is set to
niland Galaxy support is then disabled.Note: if an absolute path is given, the
ansible_localprovisioner will assume that it corresponds to the exact location on the guest system. -
galaxy_roles_path(string) - The path to the directory where Ansible Galaxy roles must be installedBy default, this option is set to
nil, which means that the Galaxy roles will be installed in arolessubdirectory located in the parent directory of theplaybookfile. -
groups(hash) - Set of inventory groups to be included in the auto-generated inventory file.Example:
ansible.groups = { "web" => ["vm1", "vm2"], "db" => ["vm3"] }Example with group variables:
ansible.groups = { "atlanta" => ["host1", "host2"], "atlanta:vars" => {"ntp_server" => "ntp.atlanta.example.com", "proxy" => "proxy.atlanta.example.com"} }Notes:
- Alphanumeric patterns are not supported (e.g.
db-[a:f],vm[01:10]). - This option has no effect when the
inventory_pathoption is defined.
- Alphanumeric patterns are not supported (e.g.
-
host_vars(hash) - Set of inventory host variables to be included in the auto-generated inventory file.Example:
ansible.host_vars = { "host1" => {"http_port" => 80, "maxRequestsPerChild" => 808}, "host2" => {"http_port" => 303, "maxRequestsPerChild" => 909} }Note: This option has no effect when the
inventory_pathoption is defined. -
inventory_path(string) - The path to an Ansible inventory resource (e.g. a static inventory file, a dynamic inventory script or even multiple inventories stored in the same directory).By default, this option is disabled and Vagrant generates an inventory based on the
Vagrantfileinformation. -
limit(string or array of strings) - Set of machines or groups from the inventory file to further control which hosts are affected.The default value is set to the machine name (taken from
Vagrantfile) to ensure thatvagrant provisioncommand only affect the expected machine.Setting
limit = "all"can be used to make Ansible connect to all machines from the inventory file. -
playbook_command(string) - The command used to run playbooks.The default value is
ansible-playbook -
raw_arguments(array of strings) - a list of additionalansible-playbookarguments.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_argumentshas the highest priority and its values can potentially override or break other Vagrant settings.Examples:
['--check', '-M', '/my/modules']["--connection=paramiko", "--forks=10"]
Caveat: The
ansibleprovisioner does not support whitespace characters inraw_argumentselements. Therefore don't write something like["-c paramiko"], which will result with an invalid" parmiko"parameter value. -
skip_tags(string or array of strings) - Only plays, roles and tasks that do not match these values will be executed. -
start_at_task(string) - The task name where the playbook execution will start. -
sudo(boolean) - Cause Ansible to perform all the playbook tasks using sudo.The default value is
false. -
sudo_user(string) - set the default username who should be used by the sudo command. -
tags(string or array of strings) - Only plays, roles and tasks tagged with these values will be executed . -
vault_password_file(string) - The path of a file containing the password used by Ansible Vault. -
verbose(boolean or string) - Set Ansible's verbosity to obtain detailed loggingDefault value is
false(minimal verbosity).Examples:
true(equivalent tov),-vvv(equivalent tovvv),vvvv.Note that when the
verboseoption is enabled, theansible-playbookcommand used by Vagrant will be displayed.