add ability to enable verbose logging

This commit is contained in:
2024-05-17 00:20:33 +03:00
parent 5ac4607f79
commit 36d886d94a
7 changed files with 47 additions and 19 deletions

2
.gitignore vendored
View File

@@ -5,3 +5,5 @@
*k8s-admin*
vault-keys.json
config.yaml
temp
*id_rsa*

View File

@@ -1,4 +1,4 @@
## Устнановка
## Установка
### Docker-образ
@@ -8,6 +8,25 @@
```shell
docker run -v $(pwd)/config.yaml:/application/config.yaml \
-v $(pwd)/id_rsa:/root/.ssh/id_rsa \
-v $(pwd)/config:/root/.ssh/config harbor.kvazaric.ru/kube-forge/kube-forge:1.0-5dcd4a83 apply
-v $(pwd)/id_rsa_bastion_ift:/root/.ssh/id_rsa \
-v $(pwd)/config:/root/.ssh/config \
-v $(pwd)/k8s-admin.conf:/application/k8s-admin.conf \
harbor.kvazaric.ru/kube-forge/kube-forge:1.0-71bd08d2 apply
```
## С помощью исполняемого файла
Необходимо также на машине оператора иметь утилиты:
- sshpass
```shell
./kube-forge -c config.yaml -d . apply
```
## Параметры:
- "-с" путь до конфигурационного файла
- "-d" путь до рабочей директории (там же должна быть директория kubespray)
- "-p" пароль для авторизации через SSH
- "-v" включить расширенное логирование ("-v=true")

View File

@@ -1 +1 @@
1.0
1.1

View File

@@ -9,19 +9,18 @@ import (
"os"
)
func parseArgs() (string, string, string) {
func main() {
var password, configPath, workDir string
var verbose bool
flag.StringVar(&password, "p", "", "Password to access hosts")
flag.StringVar(&configPath, "c", "/etc/kube-forge/config.yaml", "Path to config file")
flag.StringVar(&workDir, "d", "/var/lib/kube-forge", "Path to kube-forge work dir")
flag.BoolVar(&verbose, "v", false, "Enable verbose logging")
fmt.Println(verbose)
flag.Parse()
return password, configPath, workDir
}
func main() {
password, configPath, workDir := parseArgs()
config := config.CreateConfig(configPath, workDir, password)
config.Verbose = verbose
repositories, releases := templates.GetHelmAppsConfigData()
config.Repositories = repositories
config.Releases = releases

View File

@@ -16,6 +16,7 @@ type Host struct {
type Config struct {
WorkDir string
Verbose bool
Credentials struct {
User string `yaml:"user"`
Password string `yaml:"password"`

View File

@@ -56,19 +56,26 @@ func CopyK8SAdminConfig(pathInDataDir string) {
}
func runPlaybook(playbookPath string, tags string) {
config := config.GetConfig()
var callbackExecute execute.Executor
playbookOptions := getPlaybookParameters(tags)
playbookCmd := playbook.NewAnsiblePlaybookCmd(
playbook.WithPlaybooks(playbookPath),
playbook.WithPlaybookOptions(&playbookOptions),
)
exec := stdoutcallback.NewDebugStdoutCallbackExecute(
execute.NewDefaultExecute(
execute.WithCmd(playbookCmd),
execute.WithErrorEnrich(playbook.NewAnsiblePlaybookErrorEnrich()),
),
execute := execute.NewDefaultExecute(
execute.WithCmd(playbookCmd),
execute.WithErrorEnrich(playbook.NewAnsiblePlaybookErrorEnrich()),
)
err := exec.Execute(context.Background())
if config.Verbose {
callbackExecute = stdoutcallback.NewDebugStdoutCallbackExecute(execute)
} else {
callbackExecute = stdoutcallback.NewDenseStdoutCallbackExecute(execute)
}
err := callbackExecute.Execute(context.Background())
if err != nil {
panic(err)
}

View File

@@ -4413,7 +4413,7 @@ releases:
server.insecure: true
secret:
argocdServerAdminPassword: $2a$10$fjTEgJLT1tC82Z8rxrnJBegIoLFXBvpbdbbCvqSONU34yD2w6H.wS
argocdServerAdminPassword: $2a$10$N3yN5AWSH6e7MfcQUt7/NOJpXacdWK1vPRiZPbzsUsMWNqCy9G8l6
repositories:
# add default helm-repository from harbor