Guest User

Untitled

a guest
Jun 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. {
  2. "hosts": {
  3. "a_hostname" : {
  4. "ips" : [
  5. 1,
  6. 2,
  7. 3
  8. ]
  9. },
  10. {...}
  11. }
  12. }
  13.  
  14. jq -n {hosts:{}} |
  15. for host in $( ansible -i hosts all --list-hosts ) ;
  16. do jq ".hosts += {$host:{}}" |
  17. jq ".hosts.$host += {ips:[1,2,3]}" ;
  18. done ;
  19.  
  20. {
  21. "hosts": {
  22. "host_1": {
  23. "ips": [
  24. 1,
  25. 2,
  26. 3
  27. ]
  28. }
  29. }
  30. }
Add Comment
Please, Sign In to add comment