@@ -22,6 +22,8 @@ type EEJob struct {
2222 PlaybookContents string `json:"playbookContents,omitempty"`
2323 // Playbook is the playbook that ansible will run on this execution, accepts path or FQN from collection
2424 Playbook string `json:"playbook,omitempty"`
25+ // Role is the role that ansible will run on this execution, accepts path or FQN from collection
26+ Role string `json:"role,omitempty"`
2527 // Image is the container image that will execute the ansible command
2628 Image string `json:"image,omitempty"`
2729 // Name is the name of the execution job
@@ -78,12 +80,20 @@ func (a *EEJob) JobForOpenStackAnsibleEE(h *helper.Helper) (*batchv1.Job, error)
7880
7981 args := a .Args
8082
81- playbook := a .Playbook
8283 if len (args ) == 0 {
83- if len (playbook ) == 0 {
84- playbook = CustomPlaybook
84+ artifact := a .Playbook
85+ param := "-p"
86+ if len (artifact ) == 0 {
87+ if len (a .PlaybookContents ) > 0 {
88+ artifact = CustomPlaybook
89+ } else if len (a .Role ) > 0 {
90+ artifact = a .Role
91+ param = "-r"
92+ } else {
93+ return nil , fmt .Errorf ("no playbook, playbookContents or role specified" )
94+ }
8595 }
86- args = []string {"ansible-runner" , "run" , "/runner" , "-p" , playbook }
96+ args = []string {"ansible-runner" , "run" , "/runner" , param , artifact }
8797 }
8898
8999 // ansible runner identifier
@@ -169,12 +179,15 @@ func (a *EEJob) JobForOpenStackAnsibleEE(h *helper.Helper) (*batchv1.Job, error)
169179 }
170180 }
171181
182+ if len (a .Role ) > 0 {
183+ setRunnerEnvVar (h , "RUNNER_ROLE" , a .Role , "role" , job , hashes )
184+ }
172185 if len (a .PlaybookContents ) > 0 {
173186 setRunnerEnvVar (h , "RUNNER_PLAYBOOK" , a .PlaybookContents , "playbookContents" , job , hashes )
174- } else if len (playbook ) > 0 {
187+ } else if len (a . Playbook ) > 0 {
175188 // As we set "playbook.yaml" as default
176189 // we need to ensure that PlaybookContents is empty before adding playbook
177- setRunnerEnvVar (h , "RUNNER_PLAYBOOK" , playbook , "playbooks" , job , hashes )
190+ setRunnerEnvVar (h , "RUNNER_PLAYBOOK" , a . Playbook , "playbooks" , job , hashes )
178191 }
179192
180193 if len (a .CmdLine ) > 0 {
0 commit comments