I'm trying to dynamically pass an Ansible inventory limit within Groovy. I 
can do this in a Freestyle project but am struggling to figure out how to 
pass that environment var.

I have a String Parameter defined, CLUSTER. In the Freestyle project, I 
have "Host subset" == $CLUSTER and it works. Console output shows something 
like:

# ansible-playbook -i ec2.py -l cluster1 tasks/ping2.yml



How do I reference that in Groovy? I've tried several ways to encant this 
but am failing. Trying to pull it from env.CLUSTER returns null.

def playbookCluster = env.CLUSTER
echo "cluster is $playbookCluster"


And I don't know the right syntax to pass to ansiblePlaybook:

ansiblePlaybook colorized: true, credentialsId: 
'7090458f-4fd0-44eb-9159-d16d6024d58b', installation: 'ansible 2.1.1.0', 
inventory: 'ec2.py', limit: '${CLUSTER}', playbook: 
'tasks/jenkins-ping.yml', sudoUser: null


Incidentally, I pass a couple other environment variables and pull them 
into the Playbook and that works. 

  vars:
   - hostgroup: "{{ lookup('env','HOSTGROUP') }}"
   - mirror: "{{ lookup('env','MIRROR') }}"

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/85db9620-d056-4eb0-bde6-09c8530a2bd6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to