#!{{ ansible_python['executable'] }}
# -*- coding: utf-8 -*-

# Copyright (C) 2020 Maciej Delmanowski <drybjed@gmail.com>
# Copyright (C) 2020 DebOps <https://debops.org/>
# SPDX-License-Identifier: GPL-3.0-only

# {{ ansible_managed }}

from __future__ import print_function
from json import loads, dumps
import os


def cmd_exists(cmd):
    return any(
        os.access(os.path.join(path, cmd), os.X_OK)
        for path in os.environ["PATH"].split(os.pathsep)
    )


output = {'installed': cmd_exists('filebeat'),
          'inputs': '/etc/filebeat/inputs.d',
          'modules': '/etc/filebeat/modules.d'}

print(dumps(output, sort_keys=True, indent=4))
