ansible-playbook-example.yml 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. - hosts: some-host
  2. gather_facts: no
  3. become: yes
  4. tasks:
  5. - name: create volume for telegram token & wikimap export
  6. docker_volume:
  7. name: location_guessing_game_telegram_bot_data
  8. register: data_volume
  9. - name: store telegram token
  10. copy:
  11. dest: '{{ data_volume.volume.Mountpoint }}/telegram-token'
  12. # https://telegram.me/botfather
  13. content: !vault |
  14. # ...
  15. mode: a=r
  16. no_log: true
  17. register: telegram_token
  18. - name: download wikimap dataset
  19. get_url:
  20. url: https://wikimap.toolforge.org/api.php?cat=Vienna&lang=de
  21. # filename "wget --restrict-file-names=windows" encoded
  22. dest: '{{ data_volume.volume.Mountpoint }}/api.php@cat=Vienna&lang=de'
  23. mode: a=r
  24. register: wikimap_dataset
  25. - name: bot container
  26. docker_container:
  27. name: location_guessing_game_telegram_bot
  28. # object e24e72aea596e9cfc69bd531d690d11389eb9e2d
  29. # tag docker/0.1.1-amd64
  30. image: docker.io/fphammerle/location-guessing-game-telegram-bot@sha256:0ee33594a044f844b8942a6b01e2df29a29ccd093917534bf5e760cf0bed2708
  31. env:
  32. TELEGRAM_TOKEN_PATH: '/data/{{ telegram_token.dest | relpath(data_volume.volume.Mountpoint) }}'
  33. WIKIMAP_EXPORT_PATH: '/data/{{ wikimap_dataset.dest | relpath(data_volume.volume.Mountpoint) }}'
  34. read_only: yes
  35. mounts:
  36. - type: volume
  37. source: '{{ data_volume.volume.Name }}'
  38. target: /data
  39. read_only: yes
  40. cap_drop: [ALL]
  41. security_opts: [no-new-privileges]
  42. cpu_quota: 4000
  43. cpu_period: 10000
  44. memory: 128M
  45. restart_policy: unless-stopped
  46. state: started
  47. restart: '{{ telegram_token.changed or wikimap_dataset.changed }}'