Playbooks to a new Lilik
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.

63 lines
2.0 KiB

  1. - name: install postgresql
  2. apt:
  3. name: "{{ item }}"
  4. state: present
  5. update_cache: yes
  6. cache_valid_time: 3600
  7. with_items:
  8. - postgresql
  9. - postgresql-contrib
  10. - python-psycopg2
  11. - ca-certificates
  12. - name: generate mattermost DB password
  13. gen_passwd: length=20
  14. register: new_password
  15. - block:
  16. - name: create mattermost DB
  17. postgresql_db: name=mattermost
  18. - name: create mattermost DB user
  19. postgresql_user:
  20. name: mmuser
  21. password: "{{ new_password.passwd }}"
  22. db: mattermost
  23. priv: ALL
  24. become: true
  25. become_method: su
  26. become_user: postgres
  27. - name: download latest mattermost
  28. get_url:
  29. url: "https://releases.mattermost.com/{{ mattermost_version }}/mattermost-team-{{ mattermost_version }}-linux-amd64.tar.gz"
  30. dest: "/opt/mattermost.tar.gz"
  31. register: new_download
  32. - name: unpack mattermost
  33. unarchive: src=/opt/mattermost.tar.gz dest=/opt copy=no
  34. when: new_download.changed
  35. - name: create mattermost data directory
  36. file: path=/opt/mattermost/data state=directory
  37. - name: create mattermost group
  38. group: name=mattermost system=true
  39. - name: create mattermost user and group
  40. user: name=mattermost group=mattermost system=true
  41. - name: set mattermost directory permissions
  42. file:
  43. path: /opt/mattermost
  44. owner: mattermost
  45. group: mattermost
  46. mode: g+w
  47. recurse: true
  48. - name: configure mattermost (driver name)
  49. json_file:
  50. path: /opt/mattermost/config/config.json
  51. key: "SqlSettings.DriverName"
  52. value: "postgres"
  53. - name: configure mattermost (data source)
  54. json_file:
  55. path: /opt/mattermost/config/config.json
  56. key: "SqlSettings.DataSource"
  57. value: "postgres://mmuser:{{ new_password.passwd }}@127.0.0.1:5432/mattermost?sslmode=disable&connect_timeout=10"
  58. - name: install mattermost systemd unit
  59. template:
  60. src: mattermost.service.j2
  61. dest: /etc/systemd/system/mattermost.service
  62. - name: enable mattermost service
  63. service: name=mattermost enabled=yes state=started