From f9c26369e18f4e01016253f16ea6e1a9193fb1c0 Mon Sep 17 00:00:00 2001 From: Arash Shams Date: Thu, 28 Dec 2017 10:23:40 +0330 Subject: [PATCH] Adding one task to install debian and ubuntu (#571) depends on: https://github.com/RackHD/on-taskgraph/pull/346 Install Debian - Ubuntu with only one task: Task.Os.Install.Debian osName is a new required variable with default value debian. we use this variable in following files : - on-tasksgraph/data/template/install-debian/debian-preseed - on-tasksgraph/data/template/install-debian/debian-sources to install ubuntu you have to create a payload file with following details : ``` "osName": "Ubuntu", "version": "xenial", "baseUrl": "dists/xenial/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64", "repo": "http://172.31.128.1:8080/ubuntu", ``` current default values are : ``` "osName": "debian", "version": "stretch", "baseUrl": "dists/stretch/main/installer-amd64/current/images/netboot/debian-installer/amd64", "repo": "http://172.31.128.1:8080/debian", ``` Successfully tested with Debian Jessie, Debian stretch, ubuntu xenial on HP Proliant servers. --- ...nstall-ubuntu.json => install-debian.json} | 13 ++++++++-- lib/task-data/schemas/types-installos.json | 14 +++++++++++ .../{install-ubuntu.js => install-debian.js} | 25 ++++++++++--------- ...-ubuntu-spec.js => install-debian-spec.js} | 7 +++--- .../schemas/install-os-schema-ut-helper.js | 2 +- ...-ubuntu-spec.js => install-debian-spec.js} | 7 +++--- 6 files changed, 47 insertions(+), 21 deletions(-) rename lib/task-data/schemas/{install-ubuntu.json => install-debian.json} (85%) rename lib/task-data/tasks/{install-ubuntu.js => install-debian.js} (70%) rename spec/lib/task-data/schemas/{install-ubuntu-spec.js => install-debian-spec.js} (83%) rename spec/lib/task-data/tasks/{install-ubuntu-spec.js => install-debian-spec.js} (83%) diff --git a/lib/task-data/schemas/install-ubuntu.json b/lib/task-data/schemas/install-debian.json similarity index 85% rename from lib/task-data/schemas/install-ubuntu.json rename to lib/task-data/schemas/install-debian.json index ed2c9800..fb843c9d 100644 --- a/lib/task-data/schemas/install-ubuntu.json +++ b/lib/task-data/schemas/install-debian.json @@ -1,5 +1,5 @@ { - "copyright": "Copyright 2016, EMC, Inc.", + "copyright": "Copyright 2017, Dell EMC, Inc.", "definitions": { "BaseUrl": { "type": "string", @@ -15,6 +15,9 @@ "$ref": "types-installos.json#/definitions/OsType", "readonly": true }, + "osName": { + "$ref": "types-installos.json#/definitions/OsName" + }, "version": { "$ref": "types-installos.json#/definitions/Version" }, @@ -68,8 +71,14 @@ }, "progressMilestones": { "$ref": "types-installos.json#/definitions/ProgressMilestones" + }, + "timezone": { + "$ref": "types-installos.json#/definitions/Timezone" + }, + "ntp": { + "$ref": "types-installos.json#/definitions/Ntp" } }, - "required": ["osType", "version", "repo", "profile", "installScript", + "required": ["osType", "osName", "version", "repo", "profile", "installScript", "installScriptUri", "comport", "rootPassword", "hostname", "baseUrl"] } diff --git a/lib/task-data/schemas/types-installos.json b/lib/task-data/schemas/types-installos.json index 7aa028cc..65f8223c 100644 --- a/lib/task-data/schemas/types-installos.json +++ b/lib/task-data/schemas/types-installos.json @@ -5,6 +5,10 @@ "description": "The type of OS which is used by code internally", "enum": [ "esx", "linux", "windows" ] }, + "OsName": { + "description": "The name of Linux OS based on LSB Distributor ID (debian, ubuntu)", + "enum": [ "debian", "ubuntu" ] + }, "UserName": { "description": "The user account name", "type": "string", @@ -367,6 +371,16 @@ "description": "Extra (persistent) kernel boot parameters", "minLength": 1 }, + "Timezone": { + "description": "The Timezone based on $TZ (https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)", + "type": "string", + "minLength": 1 + }, + "Ntp": { + "description": "The NTP server address", + "type": "string", + "minLength": 1 + }, "PackagesArray": { "description": "specify additional packages to install", "type": "array", diff --git a/lib/task-data/tasks/install-ubuntu.js b/lib/task-data/tasks/install-debian.js similarity index 70% rename from lib/task-data/tasks/install-ubuntu.js rename to lib/task-data/tasks/install-debian.js index 7d37b02a..ac984efe 100644 --- a/lib/task-data/tasks/install-ubuntu.js +++ b/lib/task-data/tasks/install-debian.js @@ -1,23 +1,24 @@ -// Copyright 2015, EMC, Inc. +// Copyright 2017, Dell EMC, Inc. 'use strict'; module.exports = { - friendlyName: 'Install Ubuntu', - injectableName: 'Task.Os.Install.Ubuntu', + friendlyName: 'Install Debian/Ubuntu', + injectableName: 'Task.Os.Install.Debian', implementsTask: 'Task.Base.Os.Install', - optionsSchema: 'install-ubuntu.json', + optionsSchema: 'install-debian.json', options: { osType: 'linux', //readonly options, should avoid change it - profile: 'install-ubuntu.ipxe', - installScript: 'ubuntu-preseed', + osName: 'debian', //use "ubuntu" if you want to install ubuntu. + profile: 'install-debian.ipxe', + installScript: 'debian-preseed', installScriptUri: '{{ api.templates }}/{{ options.installScript }}?nodeId={{ task.nodeId }}', //jshint ignore: line - rackhdCallbackScript: 'ubuntu.rackhdcallback', + rackhdCallbackScript: 'debian.rackhdcallback', hostname: 'localhost', comport: 'ttyS0', - version: 'trusty', - repo: '{{file.server}}/ubuntu', - baseUrl: 'dists/{{ options.version }}/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64', + version: 'stretch', + repo: '{{file.server}}/{{options.osName}}', + baseUrl: 'dists/{{ options.version }}/main/installer-amd64/current/images/netboot/{{options.osName}}-installer/amd64', rootPassword: "RackHDRocks!", interface: "auto", installDisk: "/dev/sda", @@ -26,7 +27,7 @@ module.exports = { //Some milestones are injected where can add custom commands. //Refer to below link for those injectable points: - //https://help.ubuntu.com/lts/installation-guide/armhf/apbs05.html + //https://www.debian.org/releases/stable/amd64/apbs05.html.en progressMilestones: { //jshint ignore: start requestProfile: { value: 1, description: 'Enter ipxe and request OS installation profile' }, @@ -42,7 +43,7 @@ module.exports = { properties: { os: { linux: { - distribution: 'ubuntu' + distribution: 'debian' } } } diff --git a/spec/lib/task-data/schemas/install-ubuntu-spec.js b/spec/lib/task-data/schemas/install-debian-spec.js similarity index 83% rename from spec/lib/task-data/schemas/install-ubuntu-spec.js rename to spec/lib/task-data/schemas/install-debian-spec.js index b7298e71..4771cef1 100644 --- a/spec/lib/task-data/schemas/install-ubuntu-spec.js +++ b/spec/lib/task-data/schemas/install-debian-spec.js @@ -1,13 +1,14 @@ -// Copyright 2016, EMC, Inc. +// Copyright 2017, Dell EMC, Inc. /* jshint node: true */ 'use strict'; describe(require('path').basename(__filename), function() { - var schemaFileName = 'install-ubuntu.json'; + var schemaFileName = 'install-debian.json'; var partialCanonical = { - "baseUrl": "ubuntu.baseUrl", + "baseUrl": "debian.baseUrl", + "osName": "debian" }; var positiveSetParam = { diff --git a/spec/lib/task-data/schemas/install-os-schema-ut-helper.js b/spec/lib/task-data/schemas/install-os-schema-ut-helper.js index c453a224..7b2c0ba6 100644 --- a/spec/lib/task-data/schemas/install-os-schema-ut-helper.js +++ b/spec/lib/task-data/schemas/install-os-schema-ut-helper.js @@ -67,7 +67,7 @@ var canonical = { }; var positiveSetParam = { - version: ["trusty", "6", "6.5", "6_8", "LATEST", "0.*"], + version: ["stretch", "6", "6.5", "6_8", "LATEST", "0.*"], installDisk: ["sda", "naa.123", "/dev/sdb", 0, 1, null], "networkDevices[0].ipv4.vlanIds[0]": [0, 1009, 4095] }; diff --git a/spec/lib/task-data/tasks/install-ubuntu-spec.js b/spec/lib/task-data/tasks/install-debian-spec.js similarity index 83% rename from spec/lib/task-data/tasks/install-ubuntu-spec.js rename to spec/lib/task-data/tasks/install-debian-spec.js index b560bad6..b03dae39 100644 --- a/spec/lib/task-data/tasks/install-ubuntu-spec.js +++ b/spec/lib/task-data/tasks/install-debian-spec.js @@ -1,4 +1,4 @@ -// Copyright 2015, EMC, Inc. +// Copyright 2017, Dell EMC, Inc. /* jshint node:true */ 'use strict'; @@ -7,11 +7,12 @@ describe(require('path').basename(__filename), function () { var base = require('./base-tasks-spec'); base.before(function (context) { - context.taskdefinition = helper.require('/lib/task-data/tasks/install-ubuntu.js'); + context.taskdefinition = helper.require('/lib/task-data/tasks/install-debian.js'); }); describe('task-data', function () { base.examples(); }); -}); \ No newline at end of file +}); +