#!/usr/bin/env python3
import argparse
from subprocess import check_output
import sys


MASTER_FQDN = '{{ pillar.hosts.master }}'


def need_fqdn():
    return check_output('dig +short %s' % MASTER_FQDN, shell=True).strip()


def my_fqdn():
    return check_output('hostname').strip()


def main():
    if my_fqdn() not in need_fqdn():
        sys.exit(1)
    else:
        sys.exit(0)


main()
