2013-11-01 00:24:35 +01:00
|
|
|
# -*- mode: python -*-
|
|
|
|
|
|
|
|
# Ansible is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
DOCUMENTATION = '''
|
|
|
|
---
|
2015-06-15 21:53:30 +02:00
|
|
|
author: "Benno Joy (@bennojoy)"
|
2013-11-01 00:24:35 +01:00
|
|
|
module: include_vars
|
|
|
|
short_description: Load variables from files, dynamically within a task.
|
|
|
|
description:
|
2015-10-15 21:06:32 +02:00
|
|
|
- Loads variables from a YAML/JSON file dynamically during task runtime. It can work with conditionals, or use host specific variables to determine the path name to load from.
|
2013-11-01 00:24:35 +01:00
|
|
|
options:
|
2016-07-25 03:32:04 +02:00
|
|
|
file:
|
|
|
|
version_added: "2.2"
|
|
|
|
description:
|
|
|
|
- The file name from which variables should be loaded.
|
|
|
|
- If the path is relative, it will look for the file in vars/ subdirectory of a role or relative to playbook.
|
|
|
|
name:
|
|
|
|
version_added: "2.2"
|
|
|
|
description:
|
|
|
|
- The name of a variable into which assign the included vars, if omitted (null) they will be made top level vars.
|
|
|
|
default: null
|
2013-11-01 00:24:35 +01:00
|
|
|
free-form:
|
|
|
|
description:
|
2016-07-25 03:32:04 +02:00
|
|
|
- This module allows you to specify the 'file' option directly w/o any other options.
|
|
|
|
notes:
|
|
|
|
- The file is always required either as the explicit option or using the free-form.
|
2013-11-01 00:24:35 +01:00
|
|
|
version_added: "1.4"
|
|
|
|
'''
|
|
|
|
|
|
|
|
EXAMPLES = """
|
2016-07-25 03:32:04 +02:00
|
|
|
# Include vars of stuff.yml into the 'stuff' variable (2.2).
|
|
|
|
- include_vars:
|
|
|
|
file: stuff.yml
|
|
|
|
name: stuff
|
|
|
|
|
|
|
|
# Conditionally decide to load in variables into 'plans' when x is 0, otherwise do not. (2.2)
|
|
|
|
- include_vars: file=contingency_plan.yml name=plans
|
2013-11-01 00:24:35 +01:00
|
|
|
when: x == 0
|
|
|
|
|
|
|
|
# Load a variable file based on the OS type, or a default if not found.
|
|
|
|
- include_vars: "{{ item }}"
|
|
|
|
with_first_found:
|
2014-05-30 04:44:33 +02:00
|
|
|
- "{{ ansible_distribution }}.yml"
|
|
|
|
- "{{ ansible_os_family }}.yml"
|
2013-11-01 00:24:35 +01:00
|
|
|
- "default.yml"
|
2014-05-30 04:44:33 +02:00
|
|
|
|
2016-07-25 03:32:04 +02:00
|
|
|
# bare include (free-form)
|
|
|
|
- include_vars: myvars.yml
|
|
|
|
|
2013-11-01 00:24:35 +01:00
|
|
|
"""
|