INNER CODE UNIT · Python

extract_value

timothystewart6/k3s-ansible · .github/scripts/test-default-interface.py:52

def extract_value(content, key):
    # Match a quoted value assigned to the key, e.g. flannel_iface: "...".
    match = re.search(r"^%s:\s*\"(.+)\"\s*$" % re.escape(key), content, re.M)
    if not match:
        fail("could not find %s in the sample inventory" % key)
    return match.group(1)


def resolve(env, expression, facts):
    template = env.from_string(expression)
    return template.render(ansible_facts=facts)


def main():
    root = repo_root()
    content = read_all_yml(root)
    env = Environment(undefined=StrictUndefined)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…