/test/integration/roles/test_filters/files/foo.txt

https://github.com/ajanthanm/ansible · Plain Text · 72 lines · 45 code · 27 blank · 0 comment · 0 complexity · 2930891ed379ea056aa76427d24f41e0 MD5 · raw file

  1. This is a test of various filter plugins found in Ansible (ex: core.py), and
  2. not so much a test of the core filters in Jinja2.
  3. Dumping a nested structure to JSON
  4. [
  5. "this is a list element",
  6. {
  7. "this": "is a hash element in a list",
  8. "warp": 9,
  9. "where": "endor"
  10. }
  11. ]
  12. Dumping the same structure to YAML
  13. - this is a list element
  14. - this: is a hash element in a list
  15. warp: 9
  16. where: endor
  17. Dumping the same structure to JSON, but don't pretty print
  18. ["this is a list element", {"this": "is a hash element in a list", "where": "endor", "warp": 9}]
  19. Dumping the same structure to YAML, but don't pretty print
  20. - this is a list element
  21. - {this: is a hash element in a list, warp: 9, where: endor}
  22. From a recorded task, the changed, failed, success, and skipped
  23. filters are shortcuts to ask if those tasks produced changes, failed,
  24. succeeded, or skipped (as one might guess).
  25. Changed = True
  26. Failed = False
  27. Success = True
  28. Skipped = False
  29. The mandatory filter fails if a variable is not defined and returns the value.
  30. To avoid breaking this test, this variable is already defined.
  31. a = 1
  32. There are various casts available
  33. int = 1
  34. bool = True
  35. String quoting
  36. quoted = quoted
  37. The fileglob module returns the list of things matching a pattern.
  38. fileglob = []
  39. There are also various string operations that work on paths. These do not require
  40. files to exist and are passthrus to the python os.path functions
  41. /etc/motd with basename = motd
  42. /etc/motd with dirname = /etc
  43. TODO: realpath follows symlinks. There isn't a test for this just now.
  44. TODO: add tests for set theory operations like union
  45. TODO: add tests for regex, match, and search