Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. Want to reacht this vars:
  2. ok: [localhost] => (item=app) => {
  3. "app": [
  4. {
  5. "name": "bla",
  6. "version": 1
  7. }
  8. ],
  9. "item": "app"
  10. }
  11. ok: [localhost] => (item=app_bla) => {
  12. "app_bla": [
  13. {
  14. "name": "blub",
  15. "version": 1
  16. }
  17. ],
  18. "item": "app_bla"
  19. }
  20.  
  21. They are in a vars file:
  22. [root@websrv01 ansible]# cat version
  23. app:
  24. - name: bla
  25. version: 1
  26.  
  27. app_bla:
  28. - name: blub
  29. version: 1
  30.  
  31. now i got this inventory file:
  32. [root@websrv01 ansible]# cat hosts
  33.  
  34. [app]
  35. localhost
  36.  
  37. [app_bla]
  38. localhost
  39.  
  40.  
  41. and trying to install packages on all hosts that are member of the group with this play:
  42.  
  43. - debug: msg="going to install {{item.0.name}}-{{item}} on {{inventory_hostname}}"
  44. with_items: group_names
  45.  
  46. Output:
  47.  
  48. TASK [debug] *******************************************************************
  49. [DEPRECATION WARNING]: Using bare variables is deprecated. Update your playbooks so that the environment value uses the full variable syntax ('{{group_names}}').
  50. This feature will be
  51. removed in a future release. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
  52. fatal: [localhost]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'unicode object' has no attribute 'name'\n\nThe error appears to have been in '/etc/ansible/play.yml': line 8, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n with_items: group_names\n - debug: msg=\"going to install {{item.name}}-{{item.version}} on {{inventory_hostname}}\"\n ^ here\nWe could be wrong, but this one looks like it might be an issue with\nmissing quotes. Always quote template expression brackets when they\nstart a value. For instance:\n\n with_items:\n - {{ foo }}\n\nShould be written as:\n\n with_items:\n - \"{{ foo }}\"\n"}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement