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.

90 lines
2.1 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:
  14. length: 20
  15. register: new_password
  16. - block:
  17. - name: create mattermost DB
  18. postgresql_db:
  19. name: mattermost
  20. - name: create mattermost DB user
  21. postgresql_user:
  22. name: mmuser
  23. password: "{{ new_password.passwd }}"
  24. db: mattermost
  25. priv: ALL
  26. become: true
  27. become_method: su
  28. become_user: postgres
  29. - name: download latest mattermost
  30. get_url:
  31. url: "https://releases.mattermost.com/{{ mattermost_version }}/mattermost-team-{{ mattermost_version }}-linux-amd64.tar.gz"
  32. dest: "/opt/mattermost.tar.gz"
  33. register: new_download
  34. - name: unpack mattermost
  35. unarchive:
  36. src: /opt/mattermost.tar.gz
  37. dest: /opt
  38. copy: no
  39. when: new_download.changed
  40. - name: create mattermost data directory
  41. file:
  42. path: /opt/mattermost/data
  43. state: directory
  44. - name: create mattermost group
  45. group:
  46. name: mattermost
  47. system: true
  48. - name: create mattermost user and group
  49. user:
  50. name: mattermost
  51. group: mattermost
  52. system: true
  53. - name: set mattermost directory permissions
  54. file:
  55. path: /opt/mattermost
  56. owner: mattermost
  57. group: mattermost
  58. mode: g+w
  59. recurse: true
  60. - name: configure mattermost (driver name)
  61. json_file:
  62. path: /opt/mattermost/config/config.json
  63. key: "SqlSettings.DriverName"
  64. value: "postgres"
  65. - name: configure mattermost (data source)
  66. json_file:
  67. path: /opt/mattermost/config/config.json
  68. key: "SqlSettings.DataSource"
  69. value: "postgres://mmuser:{{ new_password.passwd }}@127.0.0.1:5432/mattermost?sslmode=disable&connect_timeout=10"
  70. - name: install mattermost systemd unit
  71. template:
  72. src: mattermost.service.j2
  73. dest: /etc/systemd/system/mattermost.service
  74. - name: enable mattermost service
  75. service:
  76. name: mattermost
  77. enabled: yes
  78. state: started