@@ -94,27 +94,49 @@ Hosts can be seleted by using the `glob` and `compound matchers
94
94
ansible
95
95
~~~~~~~
96
96
97
- The ansible backend is able to parse ansible inventories to get host connection details.
98
- For local, ssh, paramiko or docker connections(based on `ansible_connection ` value)
99
- it will use the equivalent testinfra connection backend, unless `force_ansible=True `
100
- (or ``--force-ansible ``) is set.
97
+ Ansible inventories may be used to describe what hosts Testinfra should use
98
+ and how to connect them, using Testinfra's Ansible backend.
101
99
102
- For other connections types or when `force_ansible=True `, testinfra will run
103
- all commands through ansible, which is substantially slower than using native
104
- connections backends.
105
-
106
- If ssh identity file is not provided via `--ssh-identity-file ` flag, testinfra will try
107
- to use `ansible_ssh_private_key_file `, `ansible_private_key_file ` and, finally,
108
- `ansible_user ` with `ansible_ssh_pass ` variables, both should be specified.
109
-
110
- Examples::
100
+ To use the Ansible backend, prefix the ``--hosts `` option with ``ansible:// `` e.g::
111
101
112
102
$ py.test --hosts='ansible://all' # tests all inventory hosts
113
103
$ py.test --hosts='ansible://host1,ansible://host2'
114
104
$ py.test --hosts='ansible://web*'
105
+
106
+ An inventory may be specified with the ``--ansible-inventory `` option, otherwise
107
+ the default (``/etc/ansible/hosts ``) is used.
108
+
109
+ The ``ansible_connection `` value in your inventory will be used to determine
110
+ which backend to use for individual hosts: ``local ``, ``ssh ``, ``paramiko `` and ``docker ``
111
+ are supported values. Other connections (or if you are using the ``--force-ansible ``
112
+ option) will result in testinfra running all commands via Ansible itself,
113
+ which is substantially slower than the other backends::
114
+
115
115
$ py.test --force-ansible --hosts='ansible://all'
116
116
$ py.test --hosts='ansible://host?force_ansible=True'
117
117
118
+ By default, the Ansible connection backend will first try to use
119
+ ``ansible_ssh_private_key_file `` and ``ansible_private_key_file `` to authenticate,
120
+ then fall back to the ``ansible_user `` with ``ansible_ssh_pass `` variables (both
121
+ are required), before finally falling back to your own host's SSH config.
122
+
123
+ This behavior may be overwritten by specifying either the ``--ssh-identity-file ``
124
+ option or the ``--ssh-config `` option
125
+
126
+ Finally, these environment variables are supported and will be passed along to
127
+ their corresponding ansible variable (See Ansible documentation):
128
+
129
+ https://docs.ansible.com/ansible/2.3/intro_inventory.html
130
+
131
+ https://docs.ansible.com/ansible/latest/reference_appendices/config.html
132
+
133
+ * ``ANSIBLE_REMOTE_USER ``
134
+ * ``ANSIBLE_SSH_EXTRA_ARGS ``
135
+ * ``ANSIBLE_SSH_COMMON_ARGS ``
136
+ * ``ANSIBLE_REMOTE_PORT ``
137
+ * ``ANSIBLE_BECOME_USER ``
138
+ * ``ANSIBLE_BECOME ``
139
+
118
140
kubectl
119
141
~~~~~~~
120
142
0 commit comments