defaults = {
    'apt': {
        'repos': {
            'jenkins': {
                'items': {
                    'deb https://pkg.jenkins.io/{os}-stable binary/',
                },
            },
        },
        'packages': {
            'openjdk-17-jre': {},
            'jenkins': {
                'needs': {
                    'pkg_apt:openjdk-17-jre',
                },
            },
        },
    },
    'backups': {
        'paths': {
            '/var/lib/jenkins',
        },
    },
    'jenkins-ci': {
        'writeable_paths': {
            '/var/lib/jenkins',
        },
    },
    'zfs': {
        'datasets': {
            'tank/jenkins': {
                'mountpoint': '/var/lib/jenkins',
                'needed_by': {
                    'pkg_apt:jenkins',
                },
            },
        },
    },
}


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

    return {
        'nginx': {
            'vhosts': {
                'jenkins-ci': {
                    'domain': metadata.get('jenkins-ci/domain'),
                    'locations': {
                        '/': {
                            'target': 'http://localhost:22010/',
                        },
                    },
                    'website_check_path': '/login',
                    'website_check_string': 'Welcome to Jenkins',
                },
            },
        },
    }
