Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. /tmp/app/targets/file1.txt
  2.  
  3. Some text.
  4.  
  5. /tmp/app/targets/file2.cfg
  6.  
  7. cluster=0
  8. cluster_id=app_pool_00
  9.  
  10. /tmp/app/targets/file3.sh
  11.  
  12. #!/bin/sh
  13.  
  14. printf "Hello worldn"
  15.  
  16. exit 0
  17.  
  18. ---
  19.  
  20. - name: check file integrity
  21.  
  22. hosts: localhost
  23. become: no
  24.  
  25. vars:
  26. TARGET: /tmp/app/targets
  27. LOG: /tmp/app/archive/scan_results.log
  28.  
  29. tasks:
  30.  
  31. - name: discover target files
  32.  
  33. find:
  34. paths: "{{ TARGET }}"
  35. recurse: yes
  36. file_type: file
  37.  
  38. register: TARGET_FILES
  39.  
  40. - name: scan target
  41.  
  42. stat:
  43. path: "{{ item.path }}"
  44. get_checksum: yes
  45.  
  46. loop: "{{ TARGET_FILES.files }}"
  47. register: TARGET_RESULTS
  48.  
  49. - name: DEBUG
  50.  
  51. debug:
  52. var: "{{ TARGET_RESULTS }}"
  53.  
  54. - name: write findings to log
  55.  
  56. copy:
  57. content: "{{ TARGET_RESULTS.stat.path }},{{ TARGET_RESULTS.stat.checksum }}"
  58. dest: "{{ LOG }}"
  59.  
  60. ...
  61.  
  62. ---
  63. - name: check file integrity
  64.  
  65. hosts: localhost
  66. become: no
  67.  
  68. vars:
  69. TARGET: /tmp/app/targets/file1.txt
  70. LOG: /tmp/app/archive/scan_results.log
  71.  
  72. tasks:
  73.  
  74. - name: scan target
  75.  
  76. stat:
  77. path: '{{ TARGET }}'
  78. checksum_algorithm: sha1
  79. follow: no
  80. get_attributes: yes
  81. get_checksum: yes
  82. get_md5: no
  83. get_mime: yes
  84.  
  85. register: result
  86.  
  87. - name: write findings to log
  88. copy:
  89. content: "{{ result.stat.path }},{{ result.stat.checksum }}"
  90. dest: "{{ LOG }}"
  91.  
  92. ...
  93.  
  94. /tmp/app/archive/scan_results.log
  95. /tmp/app/targets/file1.txt,8d06cea05d408d70c59b1dbc5df3bda374d869a4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement