Use Credential Id with Ansible Tower Service

Hi everyone,

I’d like to launch a job ( some Openstack provisionning ) in my Ansible Tower with some extra vars and credential.
Both are configured as “Prompt on launch” on the Tower side.

I’ve modified the modify_job_options in the preprovision to add some extra options :

              # You can also override job options through service
              def modify_job_options(service)
                # Example how to programmatically modify job options:
                job_options = service.job_options
                # job_options[:limit] = 'someHost'
                # job_options[:extra_vars]['flavor'] = 'm1.small'

                # Credential if in state_var 
                options_hash = $evm.get_state_var(:options_hash)
                job_options[:cloud_credential_id] = options_hash['credential_id'].to_i

                job_options[:extra_vars]['service_id'] =

                # Important: set stack_options
                service.job_options = job_options
                @handle.log("info", "job options = #{service.job_options.inspect}")

For the extra vars, it’s work well. But the credential seems to be completely ignored.

I’ve tried with credential_id and cloud_credential_id.

Did I miss something ? How do you pass credential informations to the Tower job ?

Thanks a lot !

Hi all,

It seems that I used a deprecated key ( ).

I use now something like :

job_options[:credentials] = [ cred_id ]

And it works like a charm ! I’ll keep you in touch if I encounts others issues about this subject. Next step : multi credentials !

Thanks a lot !

1 Like