def run_facter(self, key=None):
args = [self.facter_path]<EOL>args.append("<STR_LIT>")<EOL>if self.external_dir is not None:<EOL><INDENT>args.append('<STR_LIT>')<EOL>args.append(self.external_dir)<EOL><DEDENT>if self.uses_yaml:<EOL><INDENT>args.append("<STR_LIT>")<EOL><DEDENT>if key is not None:<EOL><INDENT>args.append(key)<EOL><DEDENT>proc = subprocess.Popen(args, stdout=subprocess.PIPE)<EOL>results = proc.stdout.read()<EOL>if self.uses_yaml:<EOL><INDENT>parsed_results = yaml.load(results)<EOL>if key is not None:<EOL><INDENT>return parsed_results[key]<EOL><DEDENT>else:<EOL><INDENT>return parsed_results<EOL><DEDENT><DEDENT>results = results.decode()<EOL>if key is not None:<EOL><INDENT>return results.strip()<EOL><DEDENT>else:<EOL><INDENT>return dict(_parse_cli_facter_results(results))<EOL><DEDENT>
Run the facter executable with an optional specfic
        fact. Output is parsed to yaml if available and
        selected. Puppet facts are always selected. Returns a
        dictionary if no key is given, and the value if a key is
        passed.