@@ -43,17 +43,6 @@ func (p AnsibleResultStageParser) IsEnd(currentStage *db.TaskStage, output db.Ta
43
43
return strings .TrimSpace (output .Output ) == ""
44
44
}
45
45
46
- //type AnsibleResultHost struct {
47
- // Host string `json:"host"`
48
- // Ok int `json:"ok"`
49
- // Changed int `json:"changed"`
50
- // Unreachable int `json:"unreachable"`
51
- // Failed int `json:"failed"`
52
- // Skipped int `json:"skipped"`
53
- // Rescued int `json:"rescued"`
54
- // Ignored int `json:"ignored"`
55
- //}
56
-
57
46
var ansibleResultHostRE = regexp .MustCompile (
58
47
`^([^\s]+)\s*:\s*` +
59
48
`ok=(\d+)\s+` +
@@ -72,7 +61,7 @@ func toInt(s string) int {
72
61
}
73
62
74
63
type AnsibleResultStageParserState struct {
75
- // Hosts []AnsibleResultHost
64
+ Hosts []db. AnsibleTaskHost `json:"hosts"`
76
65
}
77
66
78
67
func (p AnsibleResultStageParser ) Parse (currentStage * db.TaskStage , output db.TaskOutput , store db.Store , projectID int ) (ok bool , err error ) {
@@ -105,18 +94,7 @@ func (p AnsibleResultStageParser) Parse(currentStage *db.TaskStage, output db.Ta
105
94
return
106
95
}
107
96
108
- //p.state.Hosts = append(p.state.Hosts, AnsibleResultHost{
109
- // Host: m[1],
110
- // Ok: toInt(m[2]),
111
- // Changed: toInt(m[3]),
112
- // Unreachable: toInt(m[4]),
113
- // Failed: toInt(m[5]),
114
- // Skipped: toInt(m[6]),
115
- // Rescued: toInt(m[7]),
116
- // Ignored: toInt(m[8]),
117
- //})
118
-
119
- err = store .CreateAnsibleTaskHost (db.AnsibleTaskHost {
97
+ host := db.AnsibleTaskHost {
120
98
TaskID : currentStage .TaskID ,
121
99
ProjectID : projectID ,
122
100
Host : m [1 ],
@@ -127,13 +105,18 @@ func (p AnsibleResultStageParser) Parse(currentStage *db.TaskStage, output db.Ta
127
105
Skipped : toInt (m [6 ]),
128
106
Rescued : toInt (m [7 ]),
129
107
Ignored : toInt (m [8 ]),
130
- })
108
+ }
109
+
110
+ p .state .Hosts = append (p .state .Hosts , host )
111
+
112
+ err = store .CreateAnsibleTaskHost (host )
131
113
132
114
return
133
115
}
134
116
135
117
func (p AnsibleResultStageParser ) Result () (res map [string ]any ) {
136
118
res = make (map [string ]any )
119
+ p .state .Hosts = make ([]db.AnsibleTaskHost , 0 )
137
120
//res["hosts"] = p.state.Hosts
138
121
return
139
122
}
0 commit comments