executable_web-docker-pull 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env -S ansible-playbook --forks 4 --ask-become-pass
  2. ---
  3. - hosts: web
  4. strategy: host_pinned
  5. become: yes
  6. vars:
  7. slack_token: "{{ lookup('passwordstore', 'majordomo/private/mjru.slack.com/tokens/ansible')}}"
  8. tasks:
  9. - copy:
  10. dest: /root/docker-pull.sh
  11. content: |
  12. {% raw %}#!/usr/bin/env bash
  13. set -e -x
  14. for repo in $(docker images --format '{{ .Repository }}' | grep -v sysdig); do
  15. docker pull $repo:master
  16. done
  17. {% endraw %}
  18. - file:
  19. path: /root/docker-pull.sh
  20. state: file
  21. mode: 0750
  22. - slack:
  23. token: "{{ slack_token }}"
  24. msg: "Pull new Docker images on {{ ansible_hostname }}"
  25. channel: "#git"
  26. delegate_to: localhost
  27. - name: docker pull
  28. command: /root/docker-pull.sh
  29. tags:
  30. - run
  31. - name: stop taskexecutor
  32. command: stop taskexecutor
  33. - name: start taskexecutor
  34. command: start taskexecutor
  35. - slack:
  36. token: "{{ slack_token }}"
  37. msg: "Restart taskexecutor on {{ ansible_hostname }}"
  38. channel: "#git"
  39. delegate_to: localhost