Search in sources :

Example 1 with Repository

use of org.platformlayer.images.model.Repository in project platformlayer by platformlayer.

the class DiskImageRecipeBuilder method removeDetails.

protected void removeDetails() {
    DiskImageRecipe recipe = getRecipe();
    final Set<String> whitelistPackages = Sets.newHashSet();
    final Set<String> whitelistRepos = Sets.newHashSet();
    final Set<String> whitelistRepositoryKeys = Sets.newHashSet();
    // whitelistPackages.add("openjdk-7-jre");
    Iterables.removeIf(recipe.getAddPackage(), new Predicate<String>() {

        @Override
        public boolean apply(String input) {
            return !whitelistPackages.contains(input);
        }
    });
    Iterables.removeIf(recipe.getRepositoryKey(), new Predicate<RepositoryKey>() {

        @Override
        public boolean apply(RepositoryKey input) {
            return !whitelistRepositoryKeys.contains(input.getUrl());
        }
    });
    Iterables.removeIf(recipe.getRepository(), new Predicate<Repository>() {

        @Override
        public boolean apply(Repository input) {
            return !whitelistRepos.contains(input.getKey());
        }
    });
    Iterables.removeIf(recipe.getConfigurePackage(), new Predicate<ConfigurePackage>() {

        @Override
        public boolean apply(ConfigurePackage input) {
            return !whitelistPackages.contains(input.getPackageName());
        }
    });
}
Also used : ConfigurePackage(org.platformlayer.images.model.ConfigurePackage) Repository(org.platformlayer.images.model.Repository) DiskImageRecipe(org.platformlayer.images.model.DiskImageRecipe) RepositoryKey(org.platformlayer.images.model.RepositoryKey)

Example 2 with Repository

use of org.platformlayer.images.model.Repository in project platformlayer by platformlayer.

the class DiskImageRecipeHelper method applyRecipe.

public void applyRecipe(OpsTarget target, DiskImageRecipe recipe) throws OpsException {
    for (RepositoryKey repositoryKey : recipe.repositoryKey) {
        apt.addRepositoryKeyUrl(target, repositoryKey.url);
    }
    for (Repository repository : recipe.repository) {
        apt.addRepository(target, repository.key, repository.source);
    }
    if (recipe.configurePackage != null) {
        apt.preconfigurePackages(target, recipe.configurePackage);
    }
    // We definitely want to update if we added a repository etc above
    apt.update(target, true);
    apt.upgrade(target);
    for (String packageName : recipe.addPackage) {
        apt.install(target, packageName);
    }
}
Also used : Repository(org.platformlayer.images.model.Repository) RepositoryKey(org.platformlayer.images.model.RepositoryKey)

Example 3 with Repository

use of org.platformlayer.images.model.Repository in project platformlayer by platformlayer.

the class JenkinsServiceController method addChildren.

@Override
protected void addChildren() throws OpsException {
    JenkinsService model = OpsContext.get().getInstance(JenkinsService.class);
    InstanceBuilder vm;
    {
        vm = InstanceBuilder.build(model.dnsName, this, model.getTags());
        vm.publicPorts.add(PORT);
        vm.hostPolicy.allowRunInContainer = true;
        vm.minimumMemoryMb = 2048;
        addChild(vm);
    }
    // If we're building Java projects, we'll want a JDK
    vm.addChild(JavaVirtualMachine.buildJdk7());
    {
        PackageDependency jenkinsPackage = PackageDependency.build("jenkins");
        jenkinsPackage.repositoryKey = new RepositoryKey();
        jenkinsPackage.repositoryKey.setUrl("http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key");
        jenkinsPackage.repository = new Repository();
        jenkinsPackage.repository.setKey("jenkins");
        jenkinsPackage.repository.getSource().add("deb http://pkg.jenkins-ci.org/debian binary/");
        vm.addChild(jenkinsPackage);
    }
    // We use curl for backups
    vm.addChild(PackageDependency.build("curl"));
    // Jenkins git usually relies on git being installed
    // git-core is valid on both Debian & Ubuntu
    vm.addChild(PackageDependency.build("git-core"));
    vm.addChild(SimpleFile.build(getClass(), new File("/etc/default/jenkins")));
    vm.addChild(EnsureJenkinsSshKey.class);
    {
        // Adding a known-host entry for github.com doesn't reduce security (?)
        EnsureKnownHost knownHost = vm.addChild(EnsureKnownHost.class);
        knownHost.user = "jenkins";
        knownHost.homeDir = new File("/var/lib/jenkins");
        knownHost.host = "github.com";
        knownHost.algorithm = "ssh-rsa";
        knownHost.key = "AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==";
    }
    // Collectd not in wheezy??
    // instance.addChild(CollectdCollector.build());
    // TODO: If we're going to support SSH git....
    // TODO: We need to ssh-keygen for jenkins
    // TODO: Someone has to add the jenkins ssh key to the git repo
    // TODO: We need to set the git user variables (name & email)
    // TODO: We need to add the ssh key(s) of any git repos we're going to be using over ssh
    // su -c "ssh-keygen -q -f /var/lib/jenkins/.ssh/id_rsa -N ''" jenkins
    // scp root@[2001:470:8157:2::f]:/var/lib/jenkins/.ssh/id_rsa.pub .
    // cat id_rsa.pub | ssh -p29418 <gerritip> gerrit create-account --ssh-key - --full-name Jenkins jenkins
    {
        PublicEndpoint endpoint = injected(PublicEndpoint.class);
        // endpoint.network = null;
        endpoint.publicPort = PORT;
        endpoint.backendPort = PORT;
        endpoint.dnsName = model.dnsName;
        endpoint.tagItem = model.getKey();
        endpoint.parentItem = model.getKey();
        endpoint.transport = Transport.Ipv6;
        vm.addChild(endpoint);
    }
    {
        BackupDirectory backup = injected(BackupDirectory.class);
        backup.itemKey = model.getKey();
        File jenkinsRoot = new File("/var/lib/jenkins");
        backup.backupRoot = jenkinsRoot;
        String[] excludes = { "jobs/*/workspace", "jobs/*/modules", "jobs/*/builds/*/workspace.tar.gz", ".m2/repository" };
        for (String exclude : excludes) {
            backup.excludes.add(new File(jenkinsRoot, exclude));
        }
        vm.addChild(backup);
    }
}
Also used : Repository(org.platformlayer.images.model.Repository) PackageDependency(org.platformlayer.ops.packages.PackageDependency) BackupDirectory(org.platformlayer.ops.backups.BackupDirectory) JenkinsService(org.platformlayer.service.jenkins.model.JenkinsService) PublicEndpoint(org.platformlayer.ops.networks.PublicEndpoint) RepositoryKey(org.platformlayer.images.model.RepositoryKey) File(java.io.File) SimpleFile(org.platformlayer.ops.filesystem.SimpleFile) InstanceBuilder(org.platformlayer.ops.instances.InstanceBuilder)

Example 4 with Repository

use of org.platformlayer.images.model.Repository in project platformlayer by platformlayer.

the class JavaVirtualMachine method addTo.

@Override
public void addTo(DiskImageRecipe recipe) {
    if (version.equals("6")) {
        // TODO: What if it's not debian squeeze??
        Repository repository = new Repository();
        repository.setKey("debian-non-free");
        repository.getSource().add("deb http://ftp.us.debian.org/debian squeeze non-free");
        recipe.getRepository().add(repository);
        DiskImageRecipeBuilder.addPreconfigure(recipe, "sun-java6-bin", "shared/accepted-sun-dlj-v1-1", "boolean", "true");
        DiskImageRecipeBuilder.addPreconfigure(recipe, "sun-java6-bin", "shared/accepted-sun-dlj-v1-1", "boolean", "true");
        DiskImageRecipeBuilder.addPreconfigure(recipe, "sun-java6-jdk", "shared/accepted-sun-dlj-v1-1", "boolean", "true");
        DiskImageRecipeBuilder.addPreconfigure(recipe, "sun-java6-jre", "shared/accepted-sun-dlj-v1-1", "boolean", "true");
        DiskImageRecipeBuilder.addPreconfigure(recipe, "sun-java6-jre", "sun-java6-jre/stopthread", "boolean", "true");
        DiskImageRecipeBuilder.addPreconfigure(recipe, "sun-java6-jre", "sun-java6-jre/jcepolicy", "note", "");
        DiskImageRecipeBuilder.addPreconfigure(recipe, "sun-java6-bin", "shared/error-sun-dlj-v1-1", "error", "");
        DiskImageRecipeBuilder.addPreconfigure(recipe, "sun-java6-jdk", "shared/error-sun-dlj-v1-1", "error", "");
        DiskImageRecipeBuilder.addPreconfigure(recipe, "sun-java6-jre", "shared/error-sun-dlj-v1-1", "error", "");
        DiskImageRecipeBuilder.addPreconfigure(recipe, "sun-java6-bin", "shared/present-sun-dlj-v1-1", "note", "");
        DiskImageRecipeBuilder.addPreconfigure(recipe, "sun-java6-jdk", "shared/present-sun-dlj-v1-1", "note", "");
        DiskImageRecipeBuilder.addPreconfigure(recipe, "sun-java6-jre", "shared/present-sun-dlj-v1-1", "note", "");
        recipe.getAddPackage().add("sun-java6-jre");
        if (addJdk) {
            recipe.getAddPackage().add("sun-java6-jdk");
        }
    } else if (version.equals("7")) {
        OperatingSystemRecipe operatingSystem = recipe.getOperatingSystem();
        if (operatingSystem == null) {
            operatingSystem = new OperatingSystemRecipe();
        }
        if (operatingSystem.getDistribution() == null) {
            operatingSystem.setDistribution("debian");
        }
        if (operatingSystem.getVersion() == null) {
            if (operatingSystem.getDistribution().equalsIgnoreCase("debian")) {
                operatingSystem.setVersion("wheezy");
            }
        }
        recipe.setOperatingSystem(operatingSystem);
    } else {
        throw new IllegalArgumentException("Unknown java version: " + version);
    }
}
Also used : Repository(org.platformlayer.images.model.Repository) OperatingSystemRecipe(org.platformlayer.images.model.OperatingSystemRecipe)

Aggregations

Repository (org.platformlayer.images.model.Repository)4 RepositoryKey (org.platformlayer.images.model.RepositoryKey)3 File (java.io.File)1 ConfigurePackage (org.platformlayer.images.model.ConfigurePackage)1 DiskImageRecipe (org.platformlayer.images.model.DiskImageRecipe)1 OperatingSystemRecipe (org.platformlayer.images.model.OperatingSystemRecipe)1 BackupDirectory (org.platformlayer.ops.backups.BackupDirectory)1 SimpleFile (org.platformlayer.ops.filesystem.SimpleFile)1 InstanceBuilder (org.platformlayer.ops.instances.InstanceBuilder)1 PublicEndpoint (org.platformlayer.ops.networks.PublicEndpoint)1 PackageDependency (org.platformlayer.ops.packages.PackageDependency)1 JenkinsService (org.platformlayer.service.jenkins.model.JenkinsService)1