Ansible Plugin: extra_vars from secret

Any thoughts on if it is possible to pass secrets to the extra_vars parameter?
(I’d prefer to use repo secrets if possible)

http://plugins.drone.io/drone-plugins/drone-ansible/

extra_vars
set additional variables as key=value: ‘key1=value1,[key2=value2]’
3 Likes

Same here - wondering how we do that?

Hey guys. I was looking for a solution for the same thing and couldn’t find anything. So I came up with a workaround which works for my needs, although it’s probably not optimal.

The idea is to define all extra vars as a single secret. So I have an ANSIBLE_EXTRA_VARS secret which looks like this (note that variables are space separated):

foo=bar ansible_become_pass=baz etc=foo

Then in .drone.yml I simply use this secret and pass it to the step config:

kind: pipeline
name: demo
steps:
- name: apply playbooks
  image: plugins/ansible:1
  settings:
    playbook: foo.yml
    extra_vars: 
      from_secret: ANSIBLE_EXTRA_VARS