0

I'm calling AWX template from ManageIQ. I'm passing 9 variables to the playbook (with prompt on launch active). The playbook is successfully called, and all of the vars come through. However two of the vars are supposed to be arrays. Instead they come through to AWX as strings: e.g., '["chefclient"]' instead of ["chefclient"].

I have confirmed that these vars are indeed of type array in ManageIQ before I pass them to the AWX template.

Any clue why this is happening? Do all vars get irresistibly converted to strings? How do I fix this?

Thank you!

mike_butak
  • 703
  • 2
  • 10
  • 27

3 Answers3

1

According to the RedHat developers on Gitter.im, this is a shortcoming in the launch_ansible_method in ManageIQ. I.e., it always converts arrays to strings. We have opened an issue on GitHub to address this.

mike_butak
  • 703
  • 2
  • 10
  • 27
0

I have basically had a variable in ansible tower/awx that takes input as Text with server names as array/List. example: ["node1","node2","node3"] and once job is launched I can see the variable in the extra variables as '["node1","node2","node3"]'. I'm not sure about reason why it does that but it doesn't effect your subsequent ansible operations on that variable. Not all variables gets single quotations only when you use array/List.

altair66
  • 131
  • 4
  • Thanks @altair66! I've shared that with my unix admin who is responsible for the playbook to see if he can use that info. He says the playbook is unable to use the stringified arrays, which differs from your experience. Perhaps he needs to switch the data type for these from array to string. – mike_butak Feb 06 '21 at 00:41
  • Hi @mike_butak can you share any additional info on what operations are performed using that variable – altair66 Feb 06 '21 at 00:52
  • Thanks @altair66, One array is a list of software packages to install (postgres, etc.), the other is a list of server groups or roles to configure for RBAC. – mike_butak Feb 08 '21 at 14:35
  • hello @altair66, after chatting with the devs at RedHat on https://gitter.im/ManageIQ/manageiq/automate I learned that this is a limitation of the launch_ansible_job method. It always converts arrays to strings. – mike_butak Feb 09 '21 at 21:13
  • Hi @mike_butak. I even had the same issue and wanted to know if you are using these variables in ansible module or these variables passed to for example shell or other scripts. In that case you need to remove those single quotes.and convert or make some changes. – altair66 Feb 09 '21 at 21:17
  • I am calling AWX from a Ruby script in ManageIQ. The owners of the MangeIQ codebase are looking into this issue. – mike_butak Feb 09 '21 at 22:52
0

I have tried to replicate this on my end with AWX installed locally. I have passed v_packages variables data as ["apache2","nginx"]. I don't see that issue now. output

job output

altair66
  • 131
  • 4
  • Thanks @altair66. It appears that the problem is how a specific method in ManageIQ is written. It apparently stringifies arrays. The solution is either to modify the ManageIQ method or find a way to parse it in AWX. Thanks for your input! – mike_butak Feb 09 '21 at 23:07
  • hi @mike_butak. Yes I think those are the only ways to fix this issue atleast for now. – altair66 Feb 09 '21 at 23:12