Is there a way to make my var less ugly?

61 views
Skip to first unread message

J Hawkesworth

unread,
Oct 3, 2014, 7:03:05 PM10/3/14
to ansible...@googlegroups.com
So I created some tasks in one of my roles today that queries Jenkins to find the latest build of a project and then uses that build number to go get a zip file onto one of my managed servers.

The relevant part of my tasks/main.yml looks like this:

  delegate_to: localhost
  register: jenkins_response
  tags: latest

- debug: var=jenkins_response.json.lastSuccessfulBuild.number

- name: get specified zip
  win_get_url:
    dest: 'C:\stagingArea\zips\someProject.{{jenkins_response.json.lastSuccessfulBuild.number}}.zip'

It works fine (thank you whoever created uri: module) but I'd like to assign a single variable name, say {{latestBuildNumber}}, rather than the {{jenkins_response.json.lastSuccessfulBuild.number}} which is a bit of a mouthful.

Maybe I'm thinking in programming mode and this is just the way it has to be, but I have the feeling I've been at the screen too long and I'm missing something obvious.

Jenkins can return a bunch of useful information about builds actually, so it would be nice to grab > 1 thing and assign it a more meaningful name that doesn't directly reference the structure of the json response.

Many thanks,

Jon

Michael Peters

unread,
Oct 3, 2014, 8:35:18 PM10/3/14
to ansible...@googlegroups.com

You can use the set_fact module for that.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b61d49d3-f188-4153-8bbe-306742e5e11a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

J Hawkesworth

unread,
Oct 5, 2014, 5:07:36 PM10/5/14
to ansible...@googlegroups.com
Thanks, just what I needed.
Reply all
Reply to author
Forward
0 new messages