add ability to enable verbose logging
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -5,3 +5,5 @@
|
|||||||
*k8s-admin*
|
*k8s-admin*
|
||||||
vault-keys.json
|
vault-keys.json
|
||||||
config.yaml
|
config.yaml
|
||||||
|
temp
|
||||||
|
*id_rsa*
|
||||||
25
README.md
25
README.md
@@ -1,4 +1,4 @@
|
|||||||
## Устнановка
|
## Установка
|
||||||
|
|
||||||
### Docker-образ
|
### Docker-образ
|
||||||
|
|
||||||
@@ -8,6 +8,25 @@
|
|||||||
|
|
||||||
```shell
|
```shell
|
||||||
docker run -v $(pwd)/config.yaml:/application/config.yaml \
|
docker run -v $(pwd)/config.yaml:/application/config.yaml \
|
||||||
-v $(pwd)/id_rsa:/root/.ssh/id_rsa \
|
-v $(pwd)/id_rsa_bastion_ift:/root/.ssh/id_rsa \
|
||||||
-v $(pwd)/config:/root/.ssh/config harbor.kvazaric.ru/kube-forge/kube-forge:1.0-5dcd4a83 apply
|
-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")
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
1.0
|
1.1
|
||||||
@@ -9,19 +9,18 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
func parseArgs() (string, string, string) {
|
func main() {
|
||||||
var password, configPath, workDir string
|
var password, configPath, workDir string
|
||||||
|
var verbose bool
|
||||||
|
|
||||||
flag.StringVar(&password, "p", "", "Password to access hosts")
|
flag.StringVar(&password, "p", "", "Password to access hosts")
|
||||||
flag.StringVar(&configPath, "c", "/etc/kube-forge/config.yaml", "Path to config file")
|
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.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()
|
flag.Parse()
|
||||||
return password, configPath, workDir
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
password, configPath, workDir := parseArgs()
|
|
||||||
config := config.CreateConfig(configPath, workDir, password)
|
config := config.CreateConfig(configPath, workDir, password)
|
||||||
|
config.Verbose = verbose
|
||||||
repositories, releases := templates.GetHelmAppsConfigData()
|
repositories, releases := templates.GetHelmAppsConfigData()
|
||||||
config.Repositories = repositories
|
config.Repositories = repositories
|
||||||
config.Releases = releases
|
config.Releases = releases
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ type Host struct {
|
|||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
WorkDir string
|
WorkDir string
|
||||||
|
Verbose bool
|
||||||
Credentials struct {
|
Credentials struct {
|
||||||
User string `yaml:"user"`
|
User string `yaml:"user"`
|
||||||
Password string `yaml:"password"`
|
Password string `yaml:"password"`
|
||||||
|
|||||||
@@ -56,19 +56,26 @@ func CopyK8SAdminConfig(pathInDataDir string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runPlaybook(playbookPath string, tags string) {
|
func runPlaybook(playbookPath string, tags string) {
|
||||||
|
config := config.GetConfig()
|
||||||
|
var callbackExecute execute.Executor
|
||||||
|
|
||||||
playbookOptions := getPlaybookParameters(tags)
|
playbookOptions := getPlaybookParameters(tags)
|
||||||
playbookCmd := playbook.NewAnsiblePlaybookCmd(
|
playbookCmd := playbook.NewAnsiblePlaybookCmd(
|
||||||
playbook.WithPlaybooks(playbookPath),
|
playbook.WithPlaybooks(playbookPath),
|
||||||
playbook.WithPlaybookOptions(&playbookOptions),
|
playbook.WithPlaybookOptions(&playbookOptions),
|
||||||
)
|
)
|
||||||
exec := stdoutcallback.NewDebugStdoutCallbackExecute(
|
execute := execute.NewDefaultExecute(
|
||||||
execute.NewDefaultExecute(
|
execute.WithCmd(playbookCmd),
|
||||||
execute.WithCmd(playbookCmd),
|
execute.WithErrorEnrich(playbook.NewAnsiblePlaybookErrorEnrich()),
|
||||||
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 {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4413,7 +4413,7 @@ releases:
|
|||||||
server.insecure: true
|
server.insecure: true
|
||||||
|
|
||||||
secret:
|
secret:
|
||||||
argocdServerAdminPassword: $2a$10$fjTEgJLT1tC82Z8rxrnJBegIoLFXBvpbdbbCvqSONU34yD2w6H.wS
|
argocdServerAdminPassword: $2a$10$N3yN5AWSH6e7MfcQUt7/NOJpXacdWK1vPRiZPbzsUsMWNqCy9G8l6
|
||||||
|
|
||||||
repositories:
|
repositories:
|
||||||
# add default helm-repository from harbor
|
# add default helm-repository from harbor
|
||||||
|
|||||||
Reference in New Issue
Block a user