kitchen-ansible 0.49.0 → 0.49.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,268 +1,269 @@
1
- # Ansible Install Options
2
-
3
- Kitchen-ansible is very flexible in how it installs ansible:
4
-
5
- It installs it in the following order:
6
-
7
- * if require_ansible_omnibus is set to true
8
-
9
- Installs using the omnibus_ansible script specified in the ansible_omnibus_url parameter and passes the ansible_version if specied as -v option.
10
-
11
- * If require_ansible_source is set to true
12
-
13
- Install require packages and download the ansible source from github from master or from a branch specified in the parameter install_source_rev.
14
-
15
- * if require_pip is set to true
16
-
17
- Install require packages and then installs ansible using the python pip command and ansible version must be specified. This allows a specific version of ansible to be installed.
18
-
19
- * if require_ansible_repo is set to true (the default)
20
-
21
- Installs from the operation system repository only with the ansible version that is in the particular repository and will use the ansible_version in the package name where appropriate.
22
-
23
- NOTE: Set to ansible_package_name to 'ansible' when installing from the CentOS/Redhat extras repo, instead of the EPEL.
24
-
25
- # Provisioner Options
26
-
27
- kitchen-ansible runs the ansible playbook command http://linux.die.net/man/1/ansible-playbook with options from parameters in the kitchen.yml file:
28
-
29
- key | default value | Notes
30
- ----|---------------|--------
31
- additional_copy_path | | Arbitrary array of files and directories to copy into test environment e.g. vars or included playbooks. See below section Copying Additional Files
32
- additional_copy_role_path | | Arbitrary array of files and directories to copy into test environment and are appended to the ANSIBLE_ROLES_PATH env var when running ansible. See below section Copying Additional Files
33
- additional_ssh_private_keys | | List of additional ssh private key files to be added to ~/.ssh
34
- ansible_apt_repo | ppa:ansible/ansible | `apt` repo; see `https://launchpad.net` `/~ansible/+archive/ubuntu/ansible` or `rquillo/ansible`
35
- ansible_binary_path | NULL | If specified this will override the location where `kitchen` tries to run `ansible-playbook` from, i.e. `ansible_binary_path: /usr/local/bin`
36
- ansible_check | false | Sets the `--check` flag when running Ansible
37
- ansible_connection | local | use `ssh` if the host is not `localhost` (Linux) or `winrm` (Windows) or `none` if defined in inventory
38
- ansible_cfg_path | ansible.cfg | location of custom ansible.cfg to get copied into test environment
39
- ansible_diff | false | Sets the `--diff` flag when running Ansible
40
- ansible_extra_flags | | Additional options to pass to ansible-playbook, e.g. `'--skip-tags=redis'`
41
- ansible_host_key_checking | true | Strict host key checking in ssh
42
- ansible_inventory | | Static or dynamic inventory file or directory or 'none' if defined in `ansible.cfg`
43
- ansible_limit | | Further limits the selected host/group patterns
44
- ansible_omnibus_remote_path | /opt/ansible | Server installation location of an Omnibus Ansible install
45
- ansible_omnibus_url | `https://raw.githubusercontent.com` `/neillturner/omnibus-ansible` `/master/ansible_install.sh` | Omnibus Ansible install location
46
- ansible_package_name | | Set to ansible when installing from the CentOS/Redhat extras repo, instead of the EPEL.
47
- ansible_platform | Naively tries to determine | OS platform of server
48
- ansible_playbook_command | | Override the Ansible playbook command
49
- ansible_sles_repo | `http://download.opensuse.org/repositories` `/systemsmanagement/SLE_12` `/systemsmanagement.repo` | Zypper SuSE Ansible repo
50
- ansible_source_url | `git://github.com/ansible/ansible.git` | Git URL of Ansible source
51
- ansible_source_rev | | Branch or tag to install Ansible source
52
- ansible_sudo | true | Determines whether `ansible-playbook` is executed as root or as the current authenticated user
53
- ansible_vault_password_file | | Path to Ansible Vault password file. Can also be an array of files.
54
- ansible_verbose | false | Extra information logging
55
- ansible_verbosity | 1 | Sets the verbosity flag appropriately, e.g.: `1 => '-v', 2 => '-vv', 3 => '-vvv' ...`. Valid values are: `1, 2, 3, 4` or `:info, :warn, :debug, :trace`
56
- ansible_version | latest | Desired version, only affects `apt-get` installs
57
- ansible_yum_repo | nil | `yum` repo for EL platforms
58
- ansiblefile_path | | Path to Ansiblefile
59
- callback_plugins_path | callback_plugins | Ansible repo `callback_plugins` directory
60
- chef_bootstrap_url | `https://www.chef.io/chef/install.sh` | The Chef install
61
- custom_pre_install_command | nil | Custom shell command to be used at beginning of install stage. Can be multiline.
62
- custom_pre_play_command | nil | Custom shell command to be used before the ansible play stage. Can be multiline. See examples below.
63
- custom_post_install_command | nil | Custom shell command to be used at after the install stage. Can be multiline.
64
- custom_post_play_command | nil | Custom shell command to be used after the ansible play stage. Can be multiline. See examples below.
65
- enable_yum_epel | false | Enable the `yum` EPEL repo
66
- env_vars | Hash.new | Hash to set environment variable to use with `ansible-playbook` command
67
- extra_vars | Hash.new | Hash to set the `extra_vars` passed to `ansible-playbook` command
68
- extra_vars_file | nil | file containing environment variables e.g. `private_vars/production.yml site.yml` Don't prefix with a @ sign.
69
- filter_plugins_path | filter_plugins | Ansible repo `filter_plugins` directory
70
- galaxy_ignore_certs | false | Ignore certificate errors when installing roles with ansible-galaxy.
71
- group_vars_path | group_vars | Ansible repo group_vars directory
72
- host_vars_path | host_vars | Ansible repo hosts directory
73
- hosts | | Create Ansible hosts file for localhost with this server group or list of groups
74
- http_proxy | nil | Use HTTP proxy when installing Ansible, packages and running Ansible
75
- https_proxy | nil | Use HTTPS proxy when installing Ansible, packages and running Ansible
76
- idempotency_test | false | Enable to test Ansible playbook idempotency
77
- idempotency_tags | [] | Adds a `--tags` parameter with the specified tags to the second invocation of `ansible-playbook` when `idempotency_test` is set to `true`
78
- idempotency_skip_tags | [] | Adds a `--skip-tags` parameter with the specified tags to the second invocation of `ansible-playbook` when `idempotency_test` is set to `true`
79
- ignore_extensions_from_root | ['.pyc'] | allow extensions to be ignored when copying from roles using additional_copy_role_path or doing recursive_additional_copy_path
80
- ignore_paths_from_root | [] | allow extra paths to be ignored when copying from roles using additional_copy_role_path or using recursive_additional_copy_path
81
- kerberos_conf_file | | Path of krb5.conf file using in Windows support
82
- keep_playbook_path | false | Keep directory structure of `playbook`, e.g. when including vars with relativ paths from playbook
83
- library_plugins_path | library | Ansible repo library plugins directory
84
- lookup_plugins_path | lookup_plugins | Ansible repo `lookup_plugins` directory
85
- max_retries | 1 | maximum number of retry attempts of converge command
86
- modules_path | | Ansible repo manifests directory
87
- no_proxy | nil | List of URLs or IPs that should be excluded from proxying
88
- playbook | default.yml | Playbook for `ansible-playbook` to run
89
- private_key | | ssh private key file for ssh connection
90
- python_sles_repo | `http://download.opensuse.org/repositories` `/devel:/languages:/python/SLE_12` `/devel:languages:python.repo` | Zypper SuSE python repo
91
- recursive_additional_copy_path | | Arbitrary array of files and directories to copy into test environment. See below section Copying Additional Files
92
- require_ansible_omnibus | false | Set to `true` if using Omnibus Ansible `pip` install
93
- require_ansible_repo | true | Set if installing Ansible from a `yum` or `apt` repo
94
- require_ansible_source | false | Install Ansible from source using method described [here](http://docs.ansible.com/intro_installation.html#running-from-source). Only works on Debian/Ubuntu at present
95
- require_chef_for_busser | true | Install Chef to run Busser for tests. NOTE: kitchen 1.4 only requires Ruby to run Busser so this is not required.
96
- require_pip | false | Set to `true` if Ansible is to be installed through `pip`).
97
- require_ruby_for_busser | false | Install Ruby to run Busser for tests
98
- require_windows_support | false | Install [Windows support](http://docs.ansible.com/ansible/intro_windows.html)
99
- requirements_path | | Path to Ansible Galaxy requirements
100
- retry_on_exit_code | [] | Array of exit codes to retry converge command against
101
- role_name | | use when the repo name does not match the name the role is published as.
102
- roles_path | roles | Ansible repo roles directory
103
- shell_command | 'sh' | Shell command to use, usually an alias for bash. may need to set to bash.
104
- show_command_output | false | Show output of commands that are run to provision system.
105
- ssh_known_hosts | | List of hosts that should be added to ~/.ssh/known_hosts
106
- sudo_command | sudo -E | `sudo` command; change to `sudo -E -H` to be consistent with Ansible
107
- update_package_repos | true | Update OS repository metadata
108
- wait_for_retry | 30 | number of seconds to wait before retrying converge command
109
- ignore_ansible_cfg | false | If true, values from ansible.cfg file will not be loaded.
110
-
111
- ## Ansible Inventory
112
-
113
- Ansible has the concept of an [inventory](http://docs.ansible.com/ansible/latest/intro_inventory.html).
114
-
115
- Ansible then connects to these servers and processes the playbook against the server.
116
-
117
- See also [Host inventories](https://ansible-tips-and-tricks.readthedocs.io/en/latest/ansible/inventory/).
118
-
119
-
120
- ### ansible Inventory parameter
121
-
122
- if you have an ansible inventory file you can specify it in the ansible_inventory parameter in the .kitchen.yml file.
123
- ```yaml
124
- ansible_inventory: myinventoryfile.txt
125
- ```
126
- or if you have an ansible.cfg file specify
127
- ```yaml
128
- ansible_inventory: none
129
- ```
130
- it will look for the file in the root of your repository.
131
-
132
- or it can be a directory from the root of your repository and contain scripts to implement [dynamic inventory](http://docs.ansible.com/ansible/latest/intro_dynamic_inventory.html)
133
-
134
- ### hosts parameter
135
-
136
- if you don't specify an inventory file then you must specify the hosts parameter in the .kitchen.yml file.
137
-
138
- kitchen ansible uses this information to create a hosts file that is used by ansible with the ansible command is run.
139
-
140
- it can either be a name of a single server
141
-
142
- ```yaml
143
- hosts: myhost
144
- ```
145
-
146
- or any array of hosts:
147
-
148
- ```yaml
149
- hosts:
150
- - myhost1
151
- - myhost2
152
- ```
153
-
154
- the hosts file that is generated always contains in the first line
155
-
156
- ```yaml
157
- localhost ansible_connection=local
158
- ```
159
- so that it will process against the locahost.
160
-
161
- and it will create a hosts file that includes the hosts you specify
162
-
163
- ```yaml
164
- localhost ansible_connection=local
165
- myhost1
166
- myhost2
167
- localhost
168
- ```
169
-
170
-
171
- ## Copying Additional Files
172
-
173
- Several parameters have been developed rather organically to support the requirement to copy additional files beyond the ones in the standard ansible locations.
174
- * These could be used for the verification phase later
175
- * additional files required by the application
176
- * or these could be ansible roles
177
-
178
- ### additional_copy_path - Arbitrary array of files and directories to copy into test environment
179
- * If you specify a directory it will copy all the files to /tmp/kitchen with the directory structure
180
- * if you specify the full file name they are copied to the top of the /tmp/kitchen folder in the server and the path is ignored.
181
- i.e. if we have a directory data/ containing file xyz.txt
182
- ```
183
- additional_copy_path:
184
- - data/xyz.txt
185
- ```
186
- it will copy data/xyz.txt to /tmp/kitchen/xyz.txt
187
- * if you specify the directory without the filename it will preserve the path when copying to /tmp/kitchen.
188
- ```
189
- additional_copy_path:
190
- - data
191
- ```
192
- it will copy data/xyz.txt to /tmp/kitchen/data/xyz.txt
193
- NOTE: additional_copy_path does copy files that are links but if you specify the full file path only the file name is copied to /tmp/kitchen
194
-
195
- ### recursive_additional_copy_path
196
- This copies the directories in a resursive fashion which can work better for some directory structures
197
- * It does not support specifying files with paths. i.e. you can only specify files at the top level of the repository
198
- ```
199
- recursive_additional_copy_path:
200
- - xyz.txt
201
- ```
202
- * It does support copying directories in a similar fashion to additional_copy_path but uses recursion to discover the files in the directory structure which can be
203
- problematic with files with links.
204
- ```
205
- recursive_additional_copy_path:
206
- - data
207
- ```
208
- ### additional_copy_role_path
209
- This is the same as additional_copy_path but adds the extra paths to the ANSIBLE_ROLES_PATH ansible command parameter.
210
-
211
- ### ignore_paths_from_root and ignore_extensions_from_root
212
- During recursive_additional_copy_path or additional_copy_role_path there are 2 additional parameters.
213
- (NOTE: These don't apply with additional_copy_path)
214
- * ignore_paths_from_root defaults to empty array []. This causes these paths to be ignored.
215
- * ignore_extensions_from_root defaults to an array containg ['.pyc']. This causes files with these extensions to be ignored.
216
- as these are implemented with the 'Find.prune' command they can be problematic with file links.
217
-
218
-
219
- ## Configuring Provisioner Options
220
-
221
- The provisioner can be configured globally or per suite, global settings act as defaults for all suites, you can then customise per suite, for example:
222
-
223
- ```yaml
224
- ---
225
- driver:
226
- name: vagrant
227
-
228
- provisioner:
229
- name: ansible_playbook
230
- roles_path: roles
231
- hosts: tomcat-servers
232
- require_ansible_repo: true
233
- ansible_verbose: true
234
- ansible_verbosity: 2
235
- ansible_diff: true
236
-
237
- platforms:
238
- - name: nocm_ubuntu-12.04
239
- driver_plugin: vagrant
240
- driver_config:
241
- box: nocm_ubuntu-12.04
242
- box_url: http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box
243
-
244
- suites:
245
- - name: default
246
- ```
247
-
248
- ### Per-suite Structure
249
-
250
- It can be beneficial to keep different Ansible layouts for different suites. Rather than having to specify the roles, modules, etc for each suite, you can create the following directory structure and they will automatically be found:
251
-
252
- ```
253
- $kitchen_root/ansible/$suite_name/roles
254
- $kitchen_root/ansible/$suite_name/modules
255
- $kitchen_root/ansible/$suite_name/Ansiblefile
256
- ```
257
-
258
- Multiple Line Structure
259
- ```yaml
260
- provisioner::
261
- command: |
262
- sudo -s <<SERVERSPEC
263
- cd /opt/gdc/serverspec-core
264
- export SERVERSPEC_ENV=$EC2DATA_ENVIRONMENT
265
- export SERVERSPEC_BACKEND=exec
266
- serverspec junit=true tag=~skip_in_kitchen check:role:$EC2DATA_TYPE
267
- SERVERSPEC
268
- ```
1
+ # Ansible Install Options
2
+
3
+ Kitchen-ansible is very flexible in how it installs ansible:
4
+
5
+ It installs it in the following order:
6
+
7
+ * if require_ansible_omnibus is set to true
8
+
9
+ Installs using the omnibus_ansible script specified in the ansible_omnibus_url parameter and passes the ansible_version if specied as -v option.
10
+
11
+ * If require_ansible_source is set to true
12
+
13
+ Install require packages and download the ansible source from github from master or from a branch specified in the parameter install_source_rev.
14
+
15
+ * if require_pip is set to true
16
+
17
+ Install require packages and then installs ansible using the python pip command and ansible version must be specified. This allows a specific version of ansible to be installed.
18
+
19
+ * if require_ansible_repo is set to true (the default)
20
+
21
+ Installs from the operation system repository only with the ansible version that is in the particular repository and will use the ansible_version in the package name where appropriate.
22
+
23
+ NOTE: Set to ansible_package_name to 'ansible' when installing from the CentOS/Redhat extras repo, instead of the EPEL.
24
+
25
+ # Provisioner Options
26
+
27
+ kitchen-ansible runs the ansible playbook command http://linux.die.net/man/1/ansible-playbook with options from parameters in the kitchen.yml file:
28
+
29
+ key | default value | Notes
30
+ ----|---------------|--------
31
+ additional_copy_path | | Arbitrary array of files and directories to copy into test environment e.g. vars or included playbooks. See below section Copying Additional Files
32
+ additional_copy_role_path | | Arbitrary array of files and directories to copy into test environment and are appended to the ANSIBLE_ROLES_PATH env var when running ansible. See below section Copying Additional Files
33
+ additional_ssh_private_keys | | List of additional ssh private key files to be added to ~/.ssh
34
+ ansible_apt_repo | ppa:ansible/ansible | `apt` repo; see `https://launchpad.net` `/~ansible/+archive/ubuntu/ansible` or `rquillo/ansible`
35
+ ansible_binary_path | NULL | If specified this will override the location where `kitchen` tries to run `ansible-playbook` from, i.e. `ansible_binary_path: /usr/local/bin`
36
+ ansible_check | false | Sets the `--check` flag when running Ansible
37
+ ansible_connection | local | use `ssh` if the host is not `localhost` (Linux) or `winrm` (Windows) or `none` if defined in inventory
38
+ ansible_cfg_path | ansible.cfg | location of custom ansible.cfg to get copied into test environment
39
+ ansible_cfg_overwrite | true | whether the ansible.cfg in the test environment should be overwritten or not.
40
+ ansible_diff | false | Sets the `--diff` flag when running Ansible
41
+ ansible_extra_flags | | Additional options to pass to ansible-playbook, e.g. `'--skip-tags=redis'`
42
+ ansible_host_key_checking | true | Strict host key checking in ssh
43
+ ansible_inventory | | Static or dynamic inventory file or directory or 'none' if defined in `ansible.cfg`
44
+ ansible_limit | | Further limits the selected host/group patterns
45
+ ansible_omnibus_remote_path | /opt/ansible | Server installation location of an Omnibus Ansible install
46
+ ansible_omnibus_url | `https://raw.githubusercontent.com` `/neillturner/omnibus-ansible` `/master/ansible_install.sh` | Omnibus Ansible install location
47
+ ansible_package_name | | Set to ansible when installing from the CentOS/Redhat extras repo, instead of the EPEL.
48
+ ansible_platform | Naively tries to determine | OS platform of server
49
+ ansible_playbook_command | | Override the Ansible playbook command
50
+ ansible_sles_repo | `http://download.opensuse.org/repositories` `/systemsmanagement/SLE_12` `/systemsmanagement.repo` | Zypper SuSE Ansible repo
51
+ ansible_source_url | `git://github.com/ansible/ansible.git` | Git URL of Ansible source
52
+ ansible_source_rev | | Branch or tag to install Ansible source
53
+ ansible_sudo | true | Determines whether `ansible-playbook` is executed as root or as the current authenticated user
54
+ ansible_vault_password_file | | Path to Ansible Vault password file. Can also be an array of files.
55
+ ansible_verbose | false | Extra information logging
56
+ ansible_verbosity | 1 | Sets the verbosity flag appropriately, e.g.: `1 => '-v', 2 => '-vv', 3 => '-vvv' ...`. Valid values are: `1, 2, 3, 4` or `:info, :warn, :debug, :trace`
57
+ ansible_version | latest | Desired version, only affects `apt-get` installs
58
+ ansible_yum_repo | nil | `yum` repo for EL platforms
59
+ ansiblefile_path | | Path to Ansiblefile
60
+ callback_plugins_path | callback_plugins | Ansible repo `callback_plugins` directory
61
+ chef_bootstrap_url | `https://www.chef.io/chef/install.sh` | The Chef install
62
+ custom_pre_install_command | nil | Custom shell command to be used at beginning of install stage. Can be multiline.
63
+ custom_pre_play_command | nil | Custom shell command to be used before the ansible play stage. Can be multiline. See examples below.
64
+ custom_post_install_command | nil | Custom shell command to be used at after the install stage. Can be multiline.
65
+ custom_post_play_command | nil | Custom shell command to be used after the ansible play stage. Can be multiline. See examples below.
66
+ enable_yum_epel | false | Enable the `yum` EPEL repo
67
+ env_vars | Hash.new | Hash to set environment variable to use with `ansible-playbook` command
68
+ extra_vars | Hash.new | Hash to set the `extra_vars` passed to `ansible-playbook` command
69
+ extra_vars_file | nil | file containing environment variables e.g. `private_vars/production.yml site.yml` Don't prefix with a @ sign.
70
+ filter_plugins_path | filter_plugins | Ansible repo `filter_plugins` directory
71
+ galaxy_ignore_certs | false | Ignore certificate errors when installing roles with ansible-galaxy.
72
+ group_vars_path | group_vars | Ansible repo group_vars directory
73
+ host_vars_path | host_vars | Ansible repo hosts directory
74
+ hosts | | Create Ansible hosts file for localhost with this server group or list of groups
75
+ http_proxy | nil | Use HTTP proxy when installing Ansible, packages and running Ansible
76
+ https_proxy | nil | Use HTTPS proxy when installing Ansible, packages and running Ansible
77
+ idempotency_test | false | Enable to test Ansible playbook idempotency
78
+ idempotency_tags | [] | Adds a `--tags` parameter with the specified tags to the second invocation of `ansible-playbook` when `idempotency_test` is set to `true`
79
+ idempotency_skip_tags | [] | Adds a `--skip-tags` parameter with the specified tags to the second invocation of `ansible-playbook` when `idempotency_test` is set to `true`
80
+ ignore_extensions_from_root | ['.pyc'] | allow extensions to be ignored when copying from roles using additional_copy_role_path or doing recursive_additional_copy_path
81
+ ignore_paths_from_root | [] | allow extra paths to be ignored when copying from roles using additional_copy_role_path or using recursive_additional_copy_path
82
+ kerberos_conf_file | | Path of krb5.conf file using in Windows support
83
+ keep_playbook_path | false | Keep directory structure of `playbook`, e.g. when including vars with relativ paths from playbook
84
+ library_plugins_path | library | Ansible repo library plugins directory
85
+ lookup_plugins_path | lookup_plugins | Ansible repo `lookup_plugins` directory
86
+ max_retries | 1 | maximum number of retry attempts of converge command
87
+ modules_path | | Ansible repo manifests directory
88
+ no_proxy | nil | List of URLs or IPs that should be excluded from proxying
89
+ playbook | default.yml | Playbook for `ansible-playbook` to run
90
+ private_key | | ssh private key file for ssh connection
91
+ python_sles_repo | `http://download.opensuse.org/repositories` `/devel:/languages:/python/SLE_12` `/devel:languages:python.repo` | Zypper SuSE python repo
92
+ recursive_additional_copy_path | | Arbitrary array of files and directories to copy into test environment. See below section Copying Additional Files
93
+ require_ansible_omnibus | false | Set to `true` if using Omnibus Ansible `pip` install
94
+ require_ansible_repo | true | Set if installing Ansible from a `yum` or `apt` repo
95
+ require_ansible_source | false | Install Ansible from source using method described [here](http://docs.ansible.com/intro_installation.html#running-from-source). Only works on Debian/Ubuntu at present
96
+ require_chef_for_busser | true | Install Chef to run Busser for tests. NOTE: kitchen 1.4 only requires Ruby to run Busser so this is not required.
97
+ require_pip | false | Set to `true` if Ansible is to be installed through `pip`).
98
+ require_ruby_for_busser | false | Install Ruby to run Busser for tests
99
+ require_windows_support | false | Install [Windows support](http://docs.ansible.com/ansible/intro_windows.html)
100
+ requirements_path | | Path to Ansible Galaxy requirements
101
+ retry_on_exit_code | [] | Array of exit codes to retry converge command against
102
+ role_name | | use when the repo name does not match the name the role is published as.
103
+ roles_path | roles | Ansible repo roles directory
104
+ shell_command | 'sh' | Shell command to use, usually an alias for bash. may need to set to bash.
105
+ show_command_output | false | Show output of commands that are run to provision system.
106
+ ssh_known_hosts | | List of hosts that should be added to ~/.ssh/known_hosts
107
+ sudo_command | sudo -E | `sudo` command; change to `sudo -E -H` to be consistent with Ansible
108
+ update_package_repos | true | Update OS repository metadata
109
+ wait_for_retry | 30 | number of seconds to wait before retrying converge command
110
+ ignore_ansible_cfg | false | If true, values from ansible.cfg file will not be loaded.
111
+
112
+ ## Ansible Inventory
113
+
114
+ Ansible has the concept of an [inventory](http://docs.ansible.com/ansible/latest/intro_inventory.html).
115
+
116
+ Ansible then connects to these servers and processes the playbook against the server.
117
+
118
+ See also [Host inventories](https://ansible-tips-and-tricks.readthedocs.io/en/latest/ansible/inventory/).
119
+
120
+
121
+ ### ansible Inventory parameter
122
+
123
+ if you have an ansible inventory file you can specify it in the ansible_inventory parameter in the .kitchen.yml file.
124
+ ```yaml
125
+ ansible_inventory: myinventoryfile.txt
126
+ ```
127
+ or if you have an ansible.cfg file specify
128
+ ```yaml
129
+ ansible_inventory: none
130
+ ```
131
+ it will look for the file in the root of your repository.
132
+
133
+ or it can be a directory from the root of your repository and contain scripts to implement [dynamic inventory](http://docs.ansible.com/ansible/latest/intro_dynamic_inventory.html)
134
+
135
+ ### hosts parameter
136
+
137
+ if you don't specify an inventory file then you must specify the hosts parameter in the .kitchen.yml file.
138
+
139
+ kitchen ansible uses this information to create a hosts file that is used by ansible with the ansible command is run.
140
+
141
+ it can either be a name of a single server
142
+
143
+ ```yaml
144
+ hosts: myhost
145
+ ```
146
+
147
+ or any array of hosts:
148
+
149
+ ```yaml
150
+ hosts:
151
+ - myhost1
152
+ - myhost2
153
+ ```
154
+
155
+ the hosts file that is generated always contains in the first line
156
+
157
+ ```yaml
158
+ localhost ansible_connection=local
159
+ ```
160
+ so that it will process against the locahost.
161
+
162
+ and it will create a hosts file that includes the hosts you specify
163
+
164
+ ```yaml
165
+ localhost ansible_connection=local
166
+ myhost1
167
+ myhost2
168
+ localhost
169
+ ```
170
+
171
+
172
+ ## Copying Additional Files
173
+
174
+ Several parameters have been developed rather organically to support the requirement to copy additional files beyond the ones in the standard ansible locations.
175
+ * These could be used for the verification phase later
176
+ * additional files required by the application
177
+ * or these could be ansible roles
178
+
179
+ ### additional_copy_path - Arbitrary array of files and directories to copy into test environment
180
+ * If you specify a directory it will copy all the files to /tmp/kitchen with the directory structure
181
+ * if you specify the full file name they are copied to the top of the /tmp/kitchen folder in the server and the path is ignored.
182
+ i.e. if we have a directory data/ containing file xyz.txt
183
+ ```
184
+ additional_copy_path:
185
+ - data/xyz.txt
186
+ ```
187
+ it will copy data/xyz.txt to /tmp/kitchen/xyz.txt
188
+ * if you specify the directory without the filename it will preserve the path when copying to /tmp/kitchen.
189
+ ```
190
+ additional_copy_path:
191
+ - data
192
+ ```
193
+ it will copy data/xyz.txt to /tmp/kitchen/data/xyz.txt
194
+ NOTE: additional_copy_path does copy files that are links but if you specify the full file path only the file name is copied to /tmp/kitchen
195
+
196
+ ### recursive_additional_copy_path
197
+ This copies the directories in a resursive fashion which can work better for some directory structures
198
+ * It does not support specifying files with paths. i.e. you can only specify files at the top level of the repository
199
+ ```
200
+ recursive_additional_copy_path:
201
+ - xyz.txt
202
+ ```
203
+ * It does support copying directories in a similar fashion to additional_copy_path but uses recursion to discover the files in the directory structure which can be
204
+ problematic with files with links.
205
+ ```
206
+ recursive_additional_copy_path:
207
+ - data
208
+ ```
209
+ ### additional_copy_role_path
210
+ This is the same as additional_copy_path but adds the extra paths to the ANSIBLE_ROLES_PATH ansible command parameter.
211
+
212
+ ### ignore_paths_from_root and ignore_extensions_from_root
213
+ During recursive_additional_copy_path or additional_copy_role_path there are 2 additional parameters.
214
+ (NOTE: These don't apply with additional_copy_path)
215
+ * ignore_paths_from_root defaults to empty array []. This causes these paths to be ignored.
216
+ * ignore_extensions_from_root defaults to an array containg ['.pyc']. This causes files with these extensions to be ignored.
217
+ as these are implemented with the 'Find.prune' command they can be problematic with file links.
218
+
219
+
220
+ ## Configuring Provisioner Options
221
+
222
+ The provisioner can be configured globally or per suite, global settings act as defaults for all suites, you can then customise per suite, for example:
223
+
224
+ ```yaml
225
+ ---
226
+ driver:
227
+ name: vagrant
228
+
229
+ provisioner:
230
+ name: ansible_playbook
231
+ roles_path: roles
232
+ hosts: tomcat-servers
233
+ require_ansible_repo: true
234
+ ansible_verbose: true
235
+ ansible_verbosity: 2
236
+ ansible_diff: true
237
+
238
+ platforms:
239
+ - name: nocm_ubuntu-12.04
240
+ driver_plugin: vagrant
241
+ driver_config:
242
+ box: nocm_ubuntu-12.04
243
+ box_url: http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box
244
+
245
+ suites:
246
+ - name: default
247
+ ```
248
+
249
+ ### Per-suite Structure
250
+
251
+ It can be beneficial to keep different Ansible layouts for different suites. Rather than having to specify the roles, modules, etc for each suite, you can create the following directory structure and they will automatically be found:
252
+
253
+ ```
254
+ $kitchen_root/ansible/$suite_name/roles
255
+ $kitchen_root/ansible/$suite_name/modules
256
+ $kitchen_root/ansible/$suite_name/Ansiblefile
257
+ ```
258
+
259
+ Multiple Line Structure
260
+ ```yaml
261
+ provisioner::
262
+ command: |
263
+ sudo -s <<SERVERSPEC
264
+ cd /opt/gdc/serverspec-core
265
+ export SERVERSPEC_ENV=$EC2DATA_ENVIRONMENT
266
+ export SERVERSPEC_BACKEND=exec
267
+ serverspec junit=true tag=~skip_in_kitchen check:role:$EC2DATA_TYPE
268
+ SERVERSPEC
269
+ ```