main.yml 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ---
  2. # Include variables and define needed variables.
  3. - name: Include OS-specific variables.
  4. include_vars: "{{ ansible_os_family }}.yml"
  5. - name: Ensure unzip is installed (RedHat).
  6. yum: pkg=unzip state=installed
  7. when: ansible_os_family == 'RedHat'
  8. - name: Ensure unzip is installed (Debian).
  9. apt: pkg=unzip state=installed
  10. when: ansible_os_family == 'Debian'
  11. - name: Create user for Gogs.
  12. user:
  13. name: "{{ gogs_user }}"
  14. comment: Gogs
  15. home: "{{ gogs_user_home }}"
  16. - name: Download Gogs.
  17. get_url:
  18. url: "{{ gogs_binary_url }}"
  19. dest: "{{ gogs_user_home }}/gogs.zip"
  20. owner: "{{ gogs_user }}"
  21. group: "{{ gogs_user }}"
  22. - name: Expand Gogs.
  23. shell: >
  24. su -c "unzip {{ gogs_user_home }}/gogs.zip -d {{ gogs_user_home }}" -s /bin/bash {{ gogs_user }}
  25. chdir={{ gogs_user_home }}
  26. creates={{ gogs_user_home }}/gogs/gogs
  27. - include: init-setup.yml
  28. - include: gogs-mysql.yml
  29. - name: Create Gogs log folder.
  30. file:
  31. path: "{{ gogs_user_home }}/gogs/log"
  32. state: directory
  33. owner: "{{ gogs_user }}"
  34. group: "{{ gogs_user }}"
  35. mode: 0755
  36. - name: Ensure Gogs is running.
  37. service: name=gogs state=started enabled=yes