ansible-remote provisioner not recognizing packer_build_name variable

47 views
Skip to first unread message

Andrew Doyle

unread,
Jul 10, 2017, 4:07:34 PM7/10/17
to Packer
Hello,

I'm a little confused as to how the packer_build_name extra variable is supposed to be used for Ansible Remote.  According to the documentation, "the provisioner automatically defines certain commonly useful Ansible variables", one of them being "packer_build_name".

The way that reads, it makes me think that the variable should be available for Ansible, but I am getting this error 
"'packer_build_name' is undefined" during the Ansible run.

How are these automatic extra variables supposed to be utilized?

The Ansible play:

- name: Set build stage variable
  set_fact
: "build_stage={{ item }}"
  with_items
: "{{ packer_build_name.split('-')[-1] }}"


In Packer:

{
  "type": "ansible",
  "user": "ubuntu",
  "playbook_file": "ansible/site.yml",
  "extra_arguments" : [
      "-vvv"
  ]
}

and...

"builders": [
    {
      "name": "py-cicd-test",
      "type": "amazon-ebs",
      .....

Where I'm trying to split the "test" portion off so I can dynamically include different vars files.

Can anyone point me towards what I'm doing wrong?

Thanks, Andrew


Rickard von Essen

unread,
Jul 10, 2017, 4:24:42 PM7/10/17
to packe...@googlegroups.com
Which version of Packer? 

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/54a6a058-638c-4476-8993-349f43bb1433%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrew Doyle

unread,
Jul 10, 2017, 4:54:06 PM7/10/17
to Packer
Ugh, didn't have the most recent. Amateur hour over here. Thanks for the quick reply!
Which version of Packer? 

To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages