[CLUST-285] ansible server and client automatically setup - #147
[CLUST-285] ansible server and client automatically setup#147howardyu60211 wants to merge 51 commits into
Conversation
|
I just noticed that we should test this function inside the container. We might need to install an SSH client in the container where our backend lives. |
|
|
||
| if err = s.generateInventory(traceCtx); err != nil { | ||
| _, _ = s.queries.UpdateStatus(traceCtx, UpdateStatusParams{ID: id, Status: "failed"}) | ||
| return Server{}, fmt.Errorf("產生 inventory 失敗: %w", err) |
|
|
||
| logger.Info("deploying all nodes...") | ||
| if err := exec.Execute(traceCtx); err != nil { | ||
| logger.Error("全叢集 Ansible 執行失敗", zap.Error(err)) |
…host provided, and merge database migration
| type AnsibleInventory struct { | ||
| All AnsibleGroup `yaml:"all"` | ||
| } | ||
| type AnsibleGroup struct { | ||
| Vars map[string]interface{} `yaml:"vars,omitempty"` | ||
| Children map[string]AnsibleChild `yaml:"children,omitempty"` | ||
| } | ||
| type AnsibleChild struct { | ||
| Hosts map[string]HostVars `yaml:"hosts,omitempty"` | ||
| } |
There was a problem hiding this comment.
There shouldn't be an Ansible prefix, which is the type in the Ansible package.
| InventoryFile = "hosts.yaml" | ||
| MainPlaybook = "playbooks/nodes.yaml" | ||
| LogFilePath = "ansible-deploy.log" | ||
| AnsibleDir = "internal/ansible/ansible" |
There was a problem hiding this comment.
Variable names typically don't start with the package name.
| } | ||
|
|
||
| go s.runAnsibleInBackground(bgCtx, server) | ||
| bgCtx := context.WithoutCancel(ctx) |
There was a problem hiding this comment.
It is better to use traceCtx here because of the span ID and logging.
|
|
||
| bgCtx := trace.ContextWithSpanContext(context.Background(), span.SpanContext()) | ||
| go s.runAnsibleInBackground(bgCtx, server) | ||
| bgCtx := context.WithoutCancel(ctx) |
There was a problem hiding this comment.
It is better to use traceCtx here because of the span ID and logging.
|
|
||
| bgCtx := trace.ContextWithSpanContext(context.Background(), span.SpanContext()) | ||
| go s.runAnsibleInBackground(bgCtx, server) | ||
| bgCtx := context.WithoutCancel(ctx) |
There was a problem hiding this comment.
It is better to use traceCtx here because of the span ID and logging.
| "ANSIBLE_CALLBACKS_ENABLED": "profile_tasks", | ||
| }), | ||
| ) | ||
| bgCtx := context.WithoutCancel(ctx) |
There was a problem hiding this comment.
It is better to use traceCtx here because of the span ID and logging.
| bgCtx := trace.ContextWithSpanContext(context.Background(), span.SpanContext()) | ||
| go s.applySSSDConfig(bgCtx) | ||
| if server.AnsibleRole == computeNodeRole { | ||
| bgCtx := context.WithoutCancel(ctx) |
There was a problem hiding this comment.
It is better to use traceCtx here because of the span ID and logging.
Type of changes
Purpose
Additional Information