defaults = {
    'apt': {
        'packages': {
            'openjdk-11-jre': {},
            'openhab': {
                'needs': {
                    'pkg_apt:openjdk-11-jre',
                },
            },
            'openhab-addons': {
                'needs': {
                    'pkg_apt:openhab',
                },
            },
        },
        'repos': {
            'openhab': {
                'items': {
                    'deb https://openhab.jfrog.io/artifactory/openhab-linuxpkg stable main',
                },
            },
        },
    },
    'backups': {
        'paths': {
            '/usr/share/openhab/addons', # not included in openhab backup
            '/var/lib/openhab',
        },
    },
}


@metadata_reactor.provides(
    'nginx/vhosts/openhab',
)
def nginx(metadata):
    if not node.has_bundle('nginx'):
        raise DoNotRunAgain

    return {
        'nginx': {
            'vhosts': {
                'openhab': {
                    'domain': metadata.get('openhab/domain'),
                    'locations': {
                        '/': {
                            'target': 'http://localhost:22090/',
                        },
                    },
                    'website_check_path': '/',
                    'website_check_string': 'openHAB',
                },
            },
        },
    }
