diff --git a/build.gradle b/build.gradle index ba4e716..7e99295 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ apply plugin: 'kotlinx-serialization' group = 'org.domaindrivenarchitecture.provs' -version = '0.8.37-SNAPSHOT' +version = '0.9.0-SNAPSHOT' repositories { mavenCentral() @@ -99,10 +99,10 @@ task fatJarLatest(type: Jar) { manifest { attributes 'Implementation-Title': 'Fatjar of provs', 'Implementation-Version': project.version, - 'Main-Class': 'org.domaindrivenarchitecture.provs.workplace.application.CliWorkplaceKt' + 'Main-Class': 'org.domaindrivenarchitecture.provs.desktop.application.CliWorkplaceKt' } with jar - archiveFileName = 'provs.jar' + archiveFileName = 'provs-desktop.jar' } task fatJarK3s(type: Jar) { @@ -116,13 +116,13 @@ task fatJarK3s(type: Jar) { manifest { attributes 'Implementation-Title': 'Fatjar of provs k3s', 'Implementation-Version': project.version, - 'Main-Class': 'org.domaindrivenarchitecture.provs.extensions.server_software.k3s.application.CliKt' + 'Main-Class': 'org.domaindrivenarchitecture.provs.server.application.ApplicationKt' } with jar archiveFileName = 'provs-server.jar' } -task uberjarWorkplace(type: Jar) { +task uberjarDesktop(type: Jar) { from sourceSets.main.output @@ -137,9 +137,29 @@ task uberjarWorkplace(type: Jar) { manifest { attributes 'Implementation-Title': 'Uberjar of provs', 'Implementation-Version': project.version, - 'Main-Class': 'org.domaindrivenarchitecture.provs.workplace.application.CliKt' + 'Main-Class': 'org.domaindrivenarchitecture.provs.desktop.application.CliKt' } - archiveFileName = 'provs-workplace.jar' + archiveFileName = 'provs-desktop.jar' +} + +task uberjarServer(type: Jar) { + + from sourceSets.main.output + + dependsOn configurations.runtimeClasspath + from { + configurations.runtimeClasspath.findAll { it.name.endsWith('jar') }.collect { zipTree(it) } + } { + duplicatesStrategy(DuplicatesStrategy.EXCLUDE) + exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA' + } + + manifest { + attributes 'Implementation-Title': 'Uberjar of provs', + 'Implementation-Version': project.version, + 'Main-Class': 'org.domaindrivenarchitecture.provs.server.application.ApplicationKt' + } + archiveFileName = 'provs-server.jar' } task uberjarEntry(type: Jar) { diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/entry/Entry.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/entry/Entry.kt index 083ee8f..3c44450 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/entry/Entry.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/entry/Entry.kt @@ -10,6 +10,7 @@ package org.domaindrivenarchitecture.provs.framework.core.entry * @param args[1] (optional) static method of the class with a vararg parameter of type String; if not specified, the "main" method is used * @param args[2...] (optional) String parameters that are passed to the method; can be only used if method name (args[1]) is provided */ +// TODO: jem - 2022.01.21 - do we need this way or can this be removed? fun main(vararg args: String) { if (args.isNotEmpty()) { diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/server/apple/Apple.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/apple/Apple.kt index 0b1125a..55ac20f 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/server/apple/Apple.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/apple/Apple.kt @@ -4,8 +4,6 @@ import org.domaindrivenarchitecture.provs.framework.core.Prov import org.domaindrivenarchitecture.provs.framework.core.ProvResult import org.domaindrivenarchitecture.provs.framework.core.remote import org.domaindrivenarchitecture.provs.framework.core.repeatTaskUntilSuccess -import org.domaindrivenarchitecture.provs.server.domain.applyK3sConfig -import org.domaindrivenarchitecture.provs.server.domain.installK3sServer /** @@ -80,8 +78,8 @@ fun main() { val host = "123.34.56.78" remote(host, "root").task { - installK3sServer(tlsHost = host) - applyK3sConfig(appleConfig()) + //installK3sServer(tlsHost = host) + //applyK3sConfig(appleConfig()) // optional check checkAppleService(host) diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/ApplicationService.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/ServerService.kt similarity index 100% rename from src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/ApplicationService.kt rename to src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/ServerService.kt diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/k3s/K3sService.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/k3s/K3sService.kt index 3120e0d..60a0c49 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/k3s/K3sService.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/domain/k3s/K3sService.kt @@ -5,6 +5,7 @@ import org.domaindrivenarchitecture.provs.framework.core.ProvResult import org.domaindrivenarchitecture.provs.framework.core.echoCommandForText import org.domaindrivenarchitecture.provs.framework.ubuntu.install.base.aptInstall import org.domaindrivenarchitecture.provs.server.infrastructure.provisionK3sInfra +import org.domaindrivenarchitecture.provs.server.infrastructure.provisionNetwork /** @@ -13,5 +14,6 @@ import org.domaindrivenarchitecture.provs.server.infrastructure.provisionK3sInfr * If tlsHost is specified, then tls (if configured) also applies to the specified host. */ fun Prov.provisionK3s() = task { + provisionNetwork() provisionK3sInfra() } diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/network.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/network.kt new file mode 100644 index 0000000..5e6a32b --- /dev/null +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/network.kt @@ -0,0 +1,28 @@ +package org.domaindrivenarchitecture.provs.server.infrastructure + +import org.domaindrivenarchitecture.provs.framework.core.Prov +import org.domaindrivenarchitecture.provs.framework.core.ProvResult +import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.createFileFromResource +import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.fileExists + +val loopbackFile = "/etc/netplan/99-loopback.yaml" +val resourcePath = "org/domaindrivenarchitecture/provs/infrastructure/network/" + +fun Prov.testNetworkExists(): Boolean { + return fileExists(loopbackFile) +} + +fun Prov.provisionNetwork() = task { + if(!testNetworkExists()) { + createFileFromResource( + loopbackFile, + "99-loopback.yaml.template", + resourcePath, + "644", + sudo = true + ) + cmd("netplan apply", sudo = true) + } else { + ProvResult(true) + } +} \ No newline at end of file diff --git a/src/main/resources/org/domaindrivenarchitecture/provs/infrastructure/network/99-loopback.yaml.template b/src/main/resources/org/domaindrivenarchitecture/provs/infrastructure/network/99-loopback.yaml.template new file mode 100644 index 0000000..a349685 --- /dev/null +++ b/src/main/resources/org/domaindrivenarchitecture/provs/infrastructure/network/99-loopback.yaml.template @@ -0,0 +1,9 @@ +network: + version: 2 + ethernets: + lo: + renderer: networkd + match: + name: lo + addresses: + - 192.168.5.1/32