Hi Conor, sounds like you're probably doing this (untested pseudocode):
- shell: "/path/to/script {{ var }}"
vars:
var:
some_key: some_data
Instead, you need to do something like this (untested pseudocode):
- shell: "/path/to/script {% for item in var|dict2items %}{{ item.key }}={{
item.value }}{% endfor %}"
vars:
var:
some_key: some_data
If not, if you can post some example script, that might help...
All the best,
--
Jon "The Nice Guy" Spriggs
@jontheniceguy everywhere...
https://jon.sprig.gs
On Mon, 11 Feb 2019 at 16:24, Conor Proud <[email protected]> wrote:
> Hi,
> This looks like the right place for posting questions- but please point me
> in the right direction if not.
> I'm using the "extra variables" box on the awx web front-end to provide
> key-value pairs to a shell script in my playbook. The problem I'm having is
> how I can use those variables in my shell script, as they all appear as
> {u'key': u'value'} when I print them from within my shell script. This
> means that they don't conform to the standard JSON format (which uses
> double-quotes) and also as these are unicode strings I'm having other
> issues trying to pull out the information I want. What I would like is to
> easily put these key-value pairs into an associative array so I can access
> the values when they're required. Is there a good way to do this? At the
> moment I'm having to use sed to substitute out the bits I don't want (the
> single quotes have to be converted to double quotes and I have to remove
> the "u" character and then pass this to a package called jq to read the
> string as a JSON object). This feels like the wrong approach, so I'm look
> for some advice or examples of whether this can be done more elegantly?
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/d04dc999-d042-46b2-af50-c543443d7190%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/d04dc999-d042-46b2-af50-c543443d7190%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAOrCWevLxGJ3-fXycGRnBz%3DGeAwnezmTgm6CChf5Tzjd9hnPxQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.