New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for JSON format on the Ansible provisioner #2131

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
5 participants
@ndemoor
Copy link

ndemoor commented Sep 5, 2013

No description provided.

Added support for --extra-vars JSON format on the Ansible provisioner…
…, with version check and fallback to original format in older versions #2128
@mitchellh

This comment has been minimized.

Copy link
Member

mitchellh commented Sep 5, 2013

Why?

@mitchellh

This comment has been minimized.

Copy link
Member

mitchellh commented Sep 5, 2013

Ah, just read your other issue. I see. :)

@ndemoor

This comment has been minimized.

Copy link

ndemoor commented Sep 12, 2013

I don't know if any more background is needed, but it would be great if this could be merged and later on end up in official releases.

Right now we have to rewrite our playbooks, getting array or hash as input, to a prefabricated string notation and split the real values and keys out.

@mjackson

This comment has been minimized.

Copy link

mjackson commented Sep 25, 2013

👍 The code that converts the extra_vars hash to a string needs to be fixed. Seems much easier to just rely on JSON for the encoding/decoding and require ansible >= 1.2.

@eggsby

This comment has been minimized.

Copy link
Contributor

eggsby commented Oct 2, 2013

A probably simpler method is to just loop -e key=value over to ansible. Otherwise, getting the quotes balanced can be tricky.

For example:
ansible-playbook -e env=dev -e extra=yes -e foo=bar ...

however: json allows complex vars to be passed to ansible. (i.e. arbitrary data structures)

@ndemoor

This comment has been minimized.

Copy link

ndemoor commented Oct 2, 2013

however: json allows complex vars to be passed to ansible. (i.e. arbitrary data structures)

This was the reason for this feature to be implemented.
eg. If you want to push a list of extra packages to be installed by apt/yum there is no way now, than to have a comma-separated string and strip it in the playbook, instead of just passing them as an array.

@gildegoma

This comment has been minimized.

Copy link
Collaborator

gildegoma commented Oct 11, 2013

Hey guys! I recently created #2366 (before finding this similar PR actually). This other PR also addresses extra_vars improvements. Could you please have a look there and comment?

Related notes:

  • unlike here, I did not implement an Ansible version compatibility check (which is quite fair, but maybe not necessary in Vagrant and Ansible community where frequent upates are usual, no?).
  • About -e env=dev -e extra=yes -e ..., I also thought about it. We could have an Array of extra_vars that combine both Hash and external files (but it may sounds over-engineered...):
    ansible.extra_vars = [
       '@vagrant-globals.yml',
       {
          ntp_server: "pool.ntp.org",
          nginx: {
            port: '8008',
            workers: 4
          }
       },
       '@vagrant-myapp.json'
    ]

@ndemoor My intention is surely not to hijack your PR, but just to find the best fix together 😃

@mitchellh

This comment has been minimized.

Copy link
Member

mitchellh commented Nov 25, 2013

Closed in favor of #2366. Thanks!

@mitchellh mitchellh closed this Nov 25, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment