You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

cameras.yaml 2.1KB

3 vuotta sitten
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. ---
  2. - hosts: servers[0]
  3. remote_user: root
  4. handlers:
  5. - name: reload systemd daemon
  6. command: systemctl daemon-reload
  7. - name: restart camera-download service
  8. systemd:
  9. name: camera-download@{{item}}.service
  10. state: restarted
  11. with_items: "{{groups.cameras}}"
  12. tasks:
  13. - name: install debian packages
  14. apt:
  15. pkg:
  16. - gphoto2
  17. - fping
  18. - name: camera-download script
  19. copy:
  20. content: |
  21. #!/usr/bin/fish
  22. source /etc/camera-download/$argv[1].fish
  23. cd $dir
  24. while sleep 1
  25. echo waiting for PING reply from $ip
  26. if fping -4 -r60 -B1 -p5000 -q $ip
  27. echo got PING reply from $ip - starting camera download
  28. gphoto2 --port ptpip:$ip --get-all-files --skip-existing --force-overwrite --recurse --delete-all-files
  29. end
  30. end
  31. dest: /usr/local/bin/camera-download
  32. mode: 0755
  33. notify: restart camera-download service
  34. - name: camera-download config directory
  35. file:
  36. path: /etc/camera-download
  37. state: directory
  38. - name: camera-download config
  39. copy:
  40. content: |
  41. set ip {{hostvars[item].ip}}
  42. set dir {{hostvars[item].camera_download_directory}}
  43. dest: /etc/camera-download/{{item}}.fish
  44. with_items: "{{groups.cameras}}"
  45. notify: restart camera-download service
  46. - name: camera-download systemd service
  47. copy:
  48. content: |
  49. [Unit]
  50. Description=run camera-download
  51. [Service]
  52. User={{camera_download_user}}
  53. Group={{camera_download_group}}
  54. Type=simple
  55. ExecStart=/usr/local/bin/camera-download %i
  56. [Install]
  57. WantedBy=multi-user.target
  58. dest: /etc/systemd/system/camera-download@.service
  59. notify:
  60. - reload systemd daemon
  61. - restart camera-download service
  62. - name: enable and start camera-download service
  63. systemd:
  64. name: camera-download@{{item}}.service
  65. state: started
  66. enabled: yes
  67. with_items: "{{groups.cameras}}"