add python, bashrc.d & devops install
refactor gopass
This commit is contained in:
parent
b8ebbbdcfb
commit
862f40432c
4 changed files with 140 additions and 1 deletions
|
@ -0,0 +1,35 @@
|
|||
package org.domaindrivenarchitecture.provs.workplace.infrastructure
|
||||
|
||||
import org.domaindrivenarchitecture.provs.core.Prov
|
||||
import org.domaindrivenarchitecture.provs.core.ProvResult
|
||||
import org.domaindrivenarchitecture.provs.ubuntu.filesystem.base.*
|
||||
import org.domaindrivenarchitecture.provs.ubuntu.install.base.aptInstall
|
||||
import java.io.File
|
||||
|
||||
|
||||
fun Prov.installBash() = def {
|
||||
installBashForUser()
|
||||
}
|
||||
|
||||
fun Prov.installBashForUser(): ProvResult = def {
|
||||
var dirname = "~/.bashrd.d"
|
||||
if(!dirExists(dirname)) {
|
||||
createDir(dirname)
|
||||
cmd("chmod 755 " + dirname)
|
||||
aptInstall("bash-completion screen")
|
||||
|
||||
var enhance = """
|
||||
# source .bashrc.d files
|
||||
if [ -d ~/.bashrc.d ]; then
|
||||
for i in ~/.bashrc.d/*.sh; do
|
||||
if [ -r \$\{i} ]; then
|
||||
. \\\$\{i}
|
||||
fi
|
||||
done
|
||||
unset i
|
||||
fi """.trimIndent()
|
||||
addTextToFile(text = enhance, file = File("~/.bashrc"))
|
||||
} else {
|
||||
ProvResult(true)
|
||||
}
|
||||
}
|
|
@ -5,11 +5,74 @@ import org.domaindrivenarchitecture.provs.core.ProvResult
|
|||
import org.domaindrivenarchitecture.provs.ubuntu.filesystem.base.createDirs
|
||||
import org.domaindrivenarchitecture.provs.ubuntu.filesystem.base.createFile
|
||||
import org.domaindrivenarchitecture.provs.ubuntu.filesystem.base.dirExists
|
||||
import org.domaindrivenarchitecture.provs.ubuntu.filesystem.base.fileExists
|
||||
import org.domaindrivenarchitecture.provs.ubuntu.install.base.aptInstall
|
||||
import org.domaindrivenarchitecture.provs.ubuntu.web.base.downloadFromURL
|
||||
|
||||
|
||||
fun Prov.installDevOps() = def {
|
||||
installTerraform()
|
||||
installAwsCredentials("", "") // TODO: get credentials from gopass
|
||||
//installAwsCredentials("", "") // TODO: get credentials from gopass
|
||||
installKubectl()
|
||||
installYq()
|
||||
}
|
||||
|
||||
fun Prov.installYq(
|
||||
version: String = "4.13.2",
|
||||
sha256sum: String = "d7c89543d1437bf80fee6237eadc608d1b121c21a7cbbe79057d5086d74f8d79"
|
||||
): ProvResult = def {
|
||||
var path = "/usr/bin/"
|
||||
var filename = "yq"
|
||||
if(!fileExists(path + filename)) {
|
||||
val result = downloadFromURL(
|
||||
"https://github.com/mikefarah/yq/releases/download/v$version/yq_linux_amd64",
|
||||
filename,
|
||||
path,
|
||||
sha256sum = sha256sum,
|
||||
sudo = true
|
||||
)
|
||||
cmd("chmod +x " + path + filename, sudo = true)
|
||||
} else {
|
||||
ProvResult(true)
|
||||
}
|
||||
}
|
||||
|
||||
fun Prov.installKubectl(): ProvResult = def {
|
||||
var kubeConfigFile = "~/.bashrc.d/kubectl.sh"
|
||||
if(!fileExists(kubeConfigFile)) {
|
||||
var kubeConfig = """
|
||||
# Set the default kube context if present
|
||||
DEFAULT_KUBE_CONTEXTS="\$\{HOME}/.kube/config"
|
||||
if test -f "\$\{DEFAULT_KUBE_CONTEXTS}"
|
||||
then
|
||||
export KUBECONFIG="\$\{DEFAULT_KUBE_CONTEXTS}"
|
||||
fi
|
||||
|
||||
# Additional contexts should be in ~/.kube/custom-contexts/
|
||||
CUSTOM_KUBE_CONTEXTS="\$\{HOME}/.kube/custom-contexts"
|
||||
mkdir -p "\$\{CUSTOM_KUBE_CONTEXTS}"
|
||||
|
||||
OIFS="\$\{IFS}"
|
||||
IFS=$'\n'
|
||||
for contextFile in `find "\$\{CUSTOM_KUBE_CONTEXTS}" -type f -name "*.yml"`
|
||||
do
|
||||
export KUBECONFIG="\$\{contextFile}:\$\{KUBECONFIG}"
|
||||
done
|
||||
IFS="\$\{OIFS}"
|
||||
""".trimIndent()
|
||||
createFile(kubeConfigFile, kubeConfig, "640")
|
||||
|
||||
var tunnelAlias = """
|
||||
alias sshu='ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
|
||||
alias ssht='ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -L 8002:localhost:8002 -L 6443:192.168.5.1:6443'
|
||||
""".trimIndent()
|
||||
createFile("~/.bashrc.d/ssh_alias.sh", tunnelAlias, "640")
|
||||
|
||||
aptInstall("kubectl")
|
||||
cmd("kubectl completion bash >> /etc/bash_completion.d/kubernetes", sudo = true)
|
||||
} else {
|
||||
ProvResult(true)
|
||||
}
|
||||
}
|
||||
|
||||
fun Prov.installTerraform(): ProvResult = def {
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
package org.domaindrivenarchitecture.provs.workplace.infrastructure
|
||||
|
||||
import org.domaindrivenarchitecture.provs.core.Prov
|
||||
import org.domaindrivenarchitecture.provs.core.ProvResult
|
||||
import org.domaindrivenarchitecture.provs.ubuntu.filesystem.base.createDirs
|
||||
import org.domaindrivenarchitecture.provs.ubuntu.filesystem.base.dirExists
|
||||
import org.domaindrivenarchitecture.provs.ubuntu.install.base.aptInstall
|
||||
|
||||
fun Prov.installPython() = def {
|
||||
installPython3()
|
||||
installVenv()
|
||||
installPybuilder()
|
||||
installRestClient()
|
||||
installJupyterlab()
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun Prov.installPython3(): ProvResult = def {
|
||||
aptInstall("python3.8-venv")
|
||||
}
|
||||
|
||||
fun Prov.installVenv(): ProvResult = def {
|
||||
var venvHome = "~/.python/meissa"
|
||||
cmd("python3 -m venv " + venvHome)
|
||||
cmd("source " + venvHome + "/bin/activate")
|
||||
cmd("pip install pip --upgrade")
|
||||
}
|
||||
|
||||
fun Prov.installPybuilder(): ProvResult = def {
|
||||
cmd("pip install pybuilder ddadevops pypandoc mockito coverage unittest-xml-reporting deprecation python_terraform " +
|
||||
"boto3")
|
||||
}
|
||||
|
||||
fun Prov.installRestClient(): ProvResult = def {
|
||||
cmd("pip install requests")
|
||||
}
|
||||
|
||||
fun Prov.installJupyterlab(): ProvResult = def {
|
||||
cmd("pip install jupyterlab pandas matplotlib")
|
||||
}
|
Loading…
Reference in a new issue