@@ -597,6 +597,24 @@ func (ctrl *instancesController) Create(ctx context.Context, group driver.Docume
597
597
if err = ctrl .ansPs .Publish ("hooks" , services_registry .Topic ("ansible_hooks" ), & c ); err != nil {
598
598
log .Error ("Failed to publish ansible hook" , zap .Error (err ))
599
599
}
600
+ for _ , a := range i .GetAddons () {
601
+ addon , err := ctrl .addons .Get (ctx , a )
602
+ if err != nil {
603
+ log .Error ("Failed to get instance addon" , zap .Error (err ), zap .String ("addon" , a ))
604
+ continue
605
+ }
606
+ if addon .Action != nil && addon .Action .GetPlaybook () != "" {
607
+ c := pb.Context {
608
+ Instance : i .GetUuid (),
609
+ Sp : sp ,
610
+ Event : "START" ,
611
+ Addon : & a ,
612
+ }
613
+ if err = ctrl .ansPs .Publish ("hooks" , services_registry .Topic ("ansible_hooks" ), & c ); err != nil {
614
+ log .Error ("Failed to publish ansible hook addon event" , zap .Error (err ))
615
+ }
616
+ }
617
+ }
600
618
}
601
619
e := epb.Event {
602
620
Uuid : i .GetUuid (),
@@ -785,6 +803,24 @@ func (ctrl *instancesController) Update(ctx context.Context, _ string, inst, old
785
803
if err = ctrl .ansPs .Publish ("hooks" , services_registry .Topic ("ansible_hooks" ), & c ); err != nil {
786
804
log .Error ("Failed to publish ansible hook" , zap .Error (err ))
787
805
}
806
+ for _ , a := range inst .GetAddons () {
807
+ addon , err := ctrl .addons .Get (ctx , a )
808
+ if err != nil {
809
+ log .Error ("Failed to get instance addon" , zap .Error (err ), zap .String ("addon" , a ))
810
+ continue
811
+ }
812
+ if addon .Action != nil && addon .Action .GetPlaybook () != "" {
813
+ c := pb.Context {
814
+ Instance : inst .GetUuid (),
815
+ Sp : sp ,
816
+ Event : "START" ,
817
+ Addon : & a ,
818
+ }
819
+ if err = ctrl .ansPs .Publish ("hooks" , services_registry .Topic ("ansible_hooks" ), & c ); err != nil {
820
+ log .Error ("Failed to publish ansible hook addon event" , zap .Error (err ))
821
+ }
822
+ }
823
+ }
788
824
}
789
825
c := pb.Context {
790
826
Instance : uuid ,
0 commit comments