Verified Commit 0e91586e authored by Philipp Michael Breuch's avatar Philipp Michael Breuch
Browse files

inventory: Add !vault yaml tag

Otherwise the inventory script will stacktrace while parsing !vault tags
parent 48714dfe
......@@ -8,6 +8,30 @@ import json
import argparse
import collections as coll
class VaultTag(yaml.YAMLObject):
yaml_tag = u'!vault'
def __init__(self, env_var):
self.env_var = env_var
def __repr__(self):
v = os.environ.get(self.env_var) or ''
return 'VaultTag({}, contains={})'.format(self.env_var, v)
def from_yaml(cls, loader, node):
return VaultTag(node.value)
def to_yaml(cls, dumper, data):
return dumper.represent_scalar(cls.yaml_tag, data.env_var)
# Required for safe_load
yaml.SafeLoader.add_constructor('!vault', VaultTag.from_yaml)
inventory_defaults = {
'ansible_ssh_port': 22022,
'ansible_ssh_user': 'root'
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment