Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CopySpec ¶
type CopySpec struct {
Src string `yaml:"src"`
Dest string `yaml:"dest"`
// Mode 文件权限,如 "0644",为空则保持源文件权限
Mode string `yaml:"mode,omitempty"`
}
CopySpec 定义文件传输或模板渲染规格
type Duration ¶
Duration 是 time.Duration 的 YAML 友好包装,支持 "30s", "5m", "1h" 等格式
func (Duration) MarshalYAML ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine 是 Playbook 的执行引擎
type EnsureSpec ¶
type EnsureSpec struct {
// Check 检查命令,退出码 0 表示已满足期望状态
Check string `yaml:"check"`
// Action 当 Check 未通过时执行的修复命令
Action string `yaml:"action"`
}
EnsureSpec 定义幂等性检查规格(状态收敛核心)
type HostReport ¶
type HostReport struct {
NodeID string
Host string
Steps []StepResult
Status HostStatus
Duration time.Duration
}
HostReport 是单台主机的完整执行报告
func (*HostReport) Summary ¶
func (h *HostReport) Summary() (ok, changed, skipped, failed int)
Summary 返回该主机各状态的计数摘要
type HostStatus ¶
type HostStatus string
HostStatus 表示单台主机的整体执行状态
const ( HostStatusSuccess HostStatus = "success" HostStatusFailed HostStatus = "failed" HostStatusAborted HostStatus = "aborted" )
type Playbook ¶
type Playbook struct {
Name string `yaml:"name"`
Description string `yaml:"description,omitempty"`
Targets Targets `yaml:"targets"`
Settings Settings `yaml:"settings,omitempty"`
Vars map[string]string `yaml:"vars,omitempty"`
Steps []Step `yaml:"steps"`
}
Playbook 是编排文件的顶层结构
type Settings ¶
type Settings struct {
// Concurrency 控制最大并发主机数,0 表示使用默认值 1
Concurrency uint `yaml:"concurrency,omitempty"`
Sudo bool `yaml:"sudo,omitempty"`
OnError OnError `yaml:"on_error,omitempty"`
Timeout Duration `yaml:"timeout,omitempty"`
}
Settings 定义全局执行配置
type Step ¶
type Step struct {
Name string `yaml:"name"`
Shell string `yaml:"shell,omitempty"`
Script string `yaml:"script,omitempty"`
Copy *CopySpec `yaml:"copy,omitempty"`
Ensure *EnsureSpec `yaml:"ensure,omitempty"`
Template *CopySpec `yaml:"template,omitempty"`
// Sudo 步骤级别的提权覆盖;nil 表示继承全局 Settings.Sudo
Sudo *bool `yaml:"sudo,omitempty"`
// Retries 失败重试次数,默认 0(不重试)
Retries int `yaml:"retries,omitempty"`
// RetryDelay 重试间隔,默认 1s
RetryDelay Duration `yaml:"retry_delay,omitempty"`
// IgnoreError 即使步骤失败也继续,优先级高于 Settings.OnError
IgnoreError bool `yaml:"ignore_error,omitempty"`
}
Step 定义单个执行步骤 每个 Step 必须恰好指定 shell/script/copy/ensure/template 之一
type StepResult ¶
type StepResult struct {
StepName string
Status StepStatus
Output string
Err error
Duration time.Duration
}
StepResult 表示单个步骤在单台主机上的执行结果
type StepStatus ¶
type StepStatus string
StepStatus 表示单个步骤的执行状态
const ( // StatusOK 步骤成功且无变更(ensure: check 通过直接返回) StatusOK StepStatus = "ok" // StatusChanged 步骤成功并产生了实际变更 StatusChanged StepStatus = "changed" // StatusSkipped ensure 步骤中 check 通过,跳过 action StatusSkipped StepStatus = "skipped" // StatusFailed 步骤执行失败 StatusFailed StepStatus = "failed" )
Click to show internal directories.
Click to hide internal directories.