You can pass the environment variable to variable c --extra-vars, but this is only part of the solution, you need to get the value of the string in a data format that can be understood.
- Python ( ) script, JSON JSON vars --extra-vars "@customers.json" ( JSON ansible 1.3), . Ansible Variable.
import sys
import os
import json
DEFAULT_VAR="CUSTOMERS"
def var_to_json(var_name, list_sep = ','):
var_dict = {var_name: os.environ[var_name].split(list_sep)}
return json.dumps(var_dict)
var_name=DEFAULT_VAR
if len(sys.argv) > 1:
var_name = sys.argv[1]
print var_to_json(var_name)
script ( ). , .
, , , . , , ( --extra-vars).