diff --git a/webapps/mattermost/LISEZMOI.md b/webapps/mattermost/LISEZMOI.md new file mode 100644 index 00000000..f552f536 --- /dev/null +++ b/webapps/mattermost/LISEZMOI.md @@ -0,0 +1,49 @@ +mattermost +===== + +Ce rôle installe un serveur mattermost. + +Notez qu'hormis le présent fichier LISEZMOI.md, tous les fichiers du rôle mattermost sont rédigés en anglais afin de suivre les conventions de la communauté Ansible, favoriser sa réutilisation et son amélioration, etc. Libre à vous cependant de faire appel à ce role dans un playbook rédigé principalement en français ou toute autre langue. + +Requis +------ + +... + +Variables du rôle +----------------- + +Plusieurs des valeurs par défaut dans defaults/main.yml doivent être changées soit directement dans defaults/main.yml ou mieux encore en les supplantant ailleurs, par exemple dans votre playbook (voir l'exemple ci-bas). + +Dépendances +------------ + +Ce rôle Ansible dépend des rôles suivants : + +- nodejs + +Exemple de playbook +------------------- + +``` +- name: "Déployer un serveur mattermost" + hosts: + - all + vars: + # Supplanter ici les variables du rôle + domains: ['votre-vrai-domaine.org'] + service: 'mon-mattermost' + + roles: + - { role: webapps/mattermost , tags: "mattermost" } +``` + +Licence +------- + +GPLv3 + +Infos sur l'auteur +------------------ + +Mathieu Gauthier-Pilote, administrateur de systèmes chez Evolix. diff --git a/webapps/mattermost/README.md b/webapps/mattermost/README.md new file mode 100644 index 00000000..14fe212f --- /dev/null +++ b/webapps/mattermost/README.md @@ -0,0 +1,49 @@ +mattermost +===== + +This role installs or upgrades the server for mattermost. + +FRENCH: Voir le fichier LISEZMOI.md pour le français. + +Requirements +------------ + +... + +Role Variables +-------------- + +Several of the default values in defaults/main.yml must be changed either directly in defaults/main.yml or better even by overwriting them somewhere else, for example in your playbook (see the example below). + +Dependencies +------------ + +This Ansible role depends on the following other roles: + +- nodejs + +Example Playbook +---------------- + +``` +- name: "Deploy a mattermost server" + hosts: + - all + vars: + # Overwrite the role variables here + domains: ['your-real-domain.org'] + service: 'my-mattermost' + + roles: + - { role: webapps/mattermost , tags: "mattermost" } +``` + +License +------- + +GPLv3 + +Author Information +------------------ + +Mathieu Gauthier-Pilote, sys. admin. at Evolix. diff --git a/webapps/mattermost/defaults/main.yml b/webapps/mattermost/defaults/main.yml new file mode 100644 index 00000000..0334ce94 --- /dev/null +++ b/webapps/mattermost/defaults/main.yml @@ -0,0 +1,11 @@ +--- +# defaults file for vars +system_dep: "['git', 'nginx', 'postgresql', 'python3-psycopg2', 'certbot', 'acl']" +version: '7.8.1' +download_url: "https://releases.mattermost.com/{{ version }}/mattermost-team-{{ version }}-linux-amd64.tar.gz" +domains: ['example.domain.org'] +mm_port: '8065' +db_host: '127.0.0.1' +db_name: "{{ service }}" +db_user: "{{ service }}" +db_password: 'UQ6_CHANGE_ME_Gzb' diff --git a/webapps/mattermost/handlers/main.yml b/webapps/mattermost/handlers/main.yml new file mode 100644 index 00000000..214734cf --- /dev/null +++ b/webapps/mattermost/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file diff --git a/webapps/mattermost/meta/main.yml b/webapps/mattermost/meta/main.yml new file mode 100644 index 00000000..b065fb2a --- /dev/null +++ b/webapps/mattermost/meta/main.yml @@ -0,0 +1,52 @@ +galaxy_info: + author: Mathieu Gauthier-Pilote + description: sys. admin. + company: Evolix + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: license GPL-3.0-only + + min_ansible_version: 2.10 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. diff --git a/webapps/mattermost/tasks/main.yml b/webapps/mattermost/tasks/main.yml new file mode 100644 index 00000000..0fcf1c67 --- /dev/null +++ b/webapps/mattermost/tasks/main.yml @@ -0,0 +1,104 @@ +--- +# tasks file for mattermost install + +- name: Install main system dependencies + apt: + name: "{{ system_dep }}" + +- name: Add UNIX account + user: + name: "{{ service }}" + shell: /bin/bash + +- name: Add PostgreSQL user + postgresql_user: + name: "{{ db_user }}" + password: "{{ db_password }}" + no_password_changes: true + become_user: postgres + +- name: Add PostgreSQL database + postgresql_db: + name: "{{ db_name }}" + owner: "{{ db_user }}" + become_user: postgres + +- name: Unarchive mattermost archive + unarchive: + src: "{{ download_url }}" + dest: ~/ + remote_src: yes + become_user: "{{ service }}" + +- name: Create the mattermost data dir if needed + file: + path: ~/mattermost/data + state: directory + mode: '0750' + become_user: "{{ service }}" + +- name: Template mattermost conf file + template: + src: "config.json.j2" + dest: "~/mattermost/config/config.json" + become_user: "{{ service }}" + +- name: Template mattermost systemd unit + template: + src: "mattermost.service.j2" + dest: "/etc/systemd/system/mattermost@.service" + +- name: Start mattermost systemd unit + service: + name: "mattermost@{{ service }}" + state: started + +#~ - name: Check if SSL certificate is present and register result + #~ stat: + #~ path: "/etc/letsencrypt/live/{{ domains |first }}/fullchain.pem" + #~ register: ssl + +#~ - name: Generate certificate only if required (first time) + #~ block: + #~ - name: Template vhost without SSL for successfull LE challengce + #~ template: + #~ src: "vhost.conf.j2" + #~ dest: "/etc/nginx/sites-available/{{ service }}.conf" + #~ - name: Enable temporary nginx vhost for mattermost + #~ file: + #~ src: "/etc/nginx/sites-available/{{ service }}.conf" + #~ dest: "/etc/nginx/sites-enabled/{{ service }}.conf" + #~ state: link + #~ - name: Reload nginx conf + #~ service: + #~ name: nginx + #~ state: reloaded + #~ - name: Make sure /var/lib/letsencrypt exists and has correct permissions + #~ file: + #~ path: /var/lib/letsencrypt + #~ state: directory + #~ mode: '0755' + #~ - name: Generate certificate with certbot + #~ shell: certbot certonly --webroot --webroot-path /var/lib/letsencrypt -d {{ domains |first }} + #~ when: ssl.stat.exists == true + +#~ - name: (Re)check if SSL certificate is present and register result + #~ stat: + #~ path: "/etc/letsencrypt/live/{{ domains |first }}/fullchain.pem" + #~ register: ssl + +- name: (Re)template conf file for nginx vhost with SSL + template: + src: "vhost.conf.j2" + dest: "/etc/nginx/sites-available/{{ service }}.conf" + +- name: Enable nginx vhost for mattermost + file: + src: "/etc/nginx/sites-available/{{ service }}.conf" + dest: "/etc/nginx/sites-enabled/{{ service }}.conf" + state: link + +- name: Reload nginx conf + service: + name: nginx + state: reloaded diff --git a/webapps/mattermost/tasks/upgrade.yml b/webapps/mattermost/tasks/upgrade.yml new file mode 100644 index 00000000..ef3c895f --- /dev/null +++ b/webapps/mattermost/tasks/upgrade.yml @@ -0,0 +1,63 @@ +--- +# tasks file for mattermost upgrade + +- name: Start mattermost systemd unit + service: + name: "mattermost@{{ service }}" + state: stopped + +- name: set current date and time as a fact + set_fact: backup_date="{{ ansible_date_time.iso8601_basic_short }}" + +- name: backup current mattermost files + command: "mv ~/mattermost/ ~/mattermost_{{ backup_date }}" + become_user: "{{ service }}" + +- name: Dump database to a file with compression + postgresql_db: + name: "{{ db_name }}" + state: dump + target: "~/{{ db_name }}.sql.gz" + become_user: postgres + +- name: Unarchive new mattermost archive + unarchive: + src: "{{ download_url }}" + dest: ~/ + remote_src: yes + become_user: "{{ service }}" + +- name: restore dirs from backup + copy: + src: "{{ item }}" + dest: ~/mattermost + remote_src: true + loop: + - "~/mattermost_{{ backup_date }}/config" + - "~/mattermost_{{ backup_date }}/data" + - "~/mattermost_{{ backup_date }}/logs" + - "~/mattermost_{{ backup_date }}/plugins" + - "~/mattermost_{{ backup_date }}/client/plugins" + become_user: "{{ service }}" + +- name: Start mattermost systemd unit + service: + name: "mattermost@{{ service }}" + state: restarted + +- name: Reload nginx conf + service: + name: nginx + state: reloaded + +- name: Define variable to skip next task by default + set_fact: + keep_db_dump: true + +- name: Remove database dump + file: + path: "~/{{ db_name }}.sql.gz" + state: absent + become_user: postgres + when: keep_db_dump is undefined + tags: clean diff --git a/webapps/mattermost/templates/config.json.j2 b/webapps/mattermost/templates/config.json.j2 new file mode 100644 index 00000000..38859b11 --- /dev/null +++ b/webapps/mattermost/templates/config.json.j2 @@ -0,0 +1,605 @@ +{ + "ServiceSettings": { + "SiteURL": "http://{{ domains | first }}", + "WebsocketURL": "", + "LicenseFileLocation": "", + "ListenAddress": "127.0.0.1:{{ mm_port }}", + "ConnectionSecurity": "", + "TLSCertFile": "", + "TLSKeyFile": "", + "TLSMinVer": "1.2", + "TLSStrictTransport": false, + "TLSStrictTransportMaxAge": 63072000, + "TLSOverwriteCiphers": [], + "UseLetsEncrypt": false, + "LetsEncryptCertificateCacheFile": "./config/letsencrypt.cache", + "Forward80To443": false, + "TrustedProxyIPHeader": [], + "ReadTimeout": 300, + "WriteTimeout": 300, + "IdleTimeout": 60, + "MaximumLoginAttempts": 10, + "GoroutineHealthThreshold": -1, + "EnableOAuthServiceProvider": true, + "EnableIncomingWebhooks": true, + "EnableOutgoingWebhooks": true, + "EnableCommands": true, + "EnablePostUsernameOverride": false, + "EnablePostIconOverride": false, + "GoogleDeveloperKey": "", + "EnableLinkPreviews": true, + "EnablePermalinkPreviews": true, + "RestrictLinkPreviews": "", + "EnableTesting": false, + "EnableDeveloper": false, + "DeveloperFlags": "", + "EnableClientPerformanceDebugging": false, + "EnableOpenTracing": false, + "EnableSecurityFixAlert": true, + "EnableInsecureOutgoingConnections": false, + "AllowedUntrustedInternalConnections": "", + "EnableMultifactorAuthentication": false, + "EnforceMultifactorAuthentication": false, + "EnableUserAccessTokens": false, + "AllowCorsFrom": "", + "CorsExposedHeaders": "", + "CorsAllowCredentials": false, + "CorsDebug": false, + "AllowCookiesForSubdomains": false, + "ExtendSessionLengthWithActivity": true, + "SessionLengthWebInDays": 30, + "SessionLengthWebInHours": 720, + "SessionLengthMobileInDays": 30, + "SessionLengthMobileInHours": 720, + "SessionLengthSSOInDays": 30, + "SessionLengthSSOInHours": 720, + "SessionCacheInMinutes": 10, + "SessionIdleTimeoutInMinutes": 43200, + "WebsocketSecurePort": 443, + "WebsocketPort": 80, + "WebserverMode": "gzip", + "EnableGifPicker": true, + "GfycatAPIKey": "2_KtH_W5", + "GfycatAPISecret": "3wLVZPiswc3DnaiaFoLkDvB4X0IV6CpMkj4tf2inJRsBY6-FnkT08zGmppWFgeof", + "EnableCustomEmoji": true, + "EnableEmojiPicker": true, + "PostEditTimeLimit": -1, + "TimeBetweenUserTypingUpdatesMilliseconds": 5000, + "EnablePostSearch": true, + "EnableFileSearch": true, + "MinimumHashtagLength": 3, + "EnableUserTypingMessages": true, + "EnableChannelViewedMessages": true, + "EnableUserStatuses": true, + "ExperimentalEnableAuthenticationTransfer": true, + "ClusterLogTimeoutMilliseconds": 2000, + "EnablePreviewFeatures": true, + "EnableTutorial": true, + "EnableOnboardingFlow": true, + "ExperimentalEnableDefaultChannelLeaveJoinMessages": true, + "ExperimentalGroupUnreadChannels": "disabled", + "EnableAPITeamDeletion": false, + "EnableAPITriggerAdminNotifications": false, + "EnableAPIUserDeletion": false, + "ExperimentalEnableHardenedMode": false, + "ExperimentalStrictCSRFEnforcement": false, + "EnableEmailInvitations": false, + "DisableBotsWhenOwnerIsDeactivated": true, + "EnableBotAccountCreation": false, + "EnableSVGs": false, + "EnableLatex": false, + "EnableInlineLatex": true, + "PostPriority": true, + "EnableAPIChannelDeletion": false, + "EnableLocalMode": false, + "LocalModeSocketLocation": "/var/tmp/mattermost_local.socket", + "EnableAWSMetering": false, + "SplitKey": "", + "FeatureFlagSyncIntervalSeconds": 30, + "DebugSplit": false, + "ThreadAutoFollow": true, + "CollapsedThreads": "always_on", + "ManagedResourcePaths": "", + "EnableCustomGroups": true, + "SelfHostedPurchase": true, + "AllowSyncedDrafts": true + }, + "TeamSettings": { + "SiteName": "Mattermost", + "MaxUsersPerTeam": 50, + "EnableUserCreation": true, + "EnableOpenServer": false, + "EnableUserDeactivation": false, + "RestrictCreationToDomains": "", + "EnableCustomUserStatuses": true, + "EnableCustomBrand": false, + "CustomBrandText": "", + "CustomDescriptionText": "", + "RestrictDirectMessage": "any", + "EnableLastActiveTime": true, + "UserStatusAwayTimeout": 300, + "MaxChannelsPerTeam": 2000, + "MaxNotificationsPerChannel": 1000, + "EnableConfirmNotificationsToChannel": true, + "TeammateNameDisplay": "username", + "ExperimentalViewArchivedChannels": true, + "ExperimentalEnableAutomaticReplies": false, + "LockTeammateNameDisplay": false, + "ExperimentalPrimaryTeam": "", + "ExperimentalDefaultChannels": [] + }, + "ClientRequirements": { + "AndroidLatestVersion": "", + "AndroidMinVersion": "", + "IosLatestVersion": "", + "IosMinVersion": "" + }, + "SqlSettings": { + "DriverName": "postgres", + "DataSource": "postgres://{{ db_user }}:{{ db_password }}@{{ db_host }}:5432/{{ db_name }}?sslmode=disable&connect_timeout=10", + "DataSourceReplicas": [], + "DataSourceSearchReplicas": [], + "MaxIdleConns": 20, + "ConnMaxLifetimeMilliseconds": 3600000, + "ConnMaxIdleTimeMilliseconds": 300000, + "MaxOpenConns": 300, + "Trace": false, + "AtRestEncryptKey": "xcipqdpb6k5hrjpfhsdixyhsscmtsujz", + "QueryTimeout": 30, + "DisableDatabaseSearch": false, + "MigrationsStatementTimeoutSeconds": 100000, + "ReplicaLagSettings": [] + }, + "LogSettings": { + "EnableConsole": true, + "ConsoleLevel": "INFO", + "ConsoleJson": true, + "EnableColor": false, + "EnableFile": true, + "FileLevel": "INFO", + "FileJson": true, + "FileLocation": "", + "EnableWebhookDebugging": true, + "EnableDiagnostics": true, + "VerboseDiagnostics": false, + "EnableSentry": true, + "AdvancedLoggingConfig": "" + }, + "ExperimentalAuditSettings": { + "FileEnabled": false, + "FileName": "", + "FileMaxSizeMB": 100, + "FileMaxAgeDays": 0, + "FileMaxBackups": 0, + "FileCompress": false, + "FileMaxQueueSize": 1000, + "AdvancedLoggingConfig": "" + }, + "NotificationLogSettings": { + "EnableConsole": true, + "ConsoleLevel": "INFO", + "ConsoleJson": true, + "EnableColor": false, + "EnableFile": true, + "FileLevel": "INFO", + "FileJson": true, + "FileLocation": "", + "AdvancedLoggingConfig": "" + }, + "PasswordSettings": { + "MinimumLength": 8, + "Lowercase": false, + "Number": false, + "Uppercase": false, + "Symbol": false + }, + "FileSettings": { + "EnableFileAttachments": true, + "EnableMobileUpload": true, + "EnableMobileDownload": true, + "MaxFileSize": 104857600, + "MaxImageResolution": 33177600, + "MaxImageDecoderConcurrency": -1, + "DriverName": "local", + "Directory": "./data/", + "EnablePublicLink": false, + "ExtractContent": true, + "ArchiveRecursion": false, + "PublicLinkSalt": "yhe99kxqhhwyitn5eo47s61u4m4rmwci", + "InitialFont": "nunito-bold.ttf", + "AmazonS3AccessKeyId": "", + "AmazonS3SecretAccessKey": "", + "AmazonS3Bucket": "", + "AmazonS3PathPrefix": "", + "AmazonS3Region": "", + "AmazonS3Endpoint": "s3.amazonaws.com", + "AmazonS3SSL": true, + "AmazonS3SignV2": false, + "AmazonS3SSE": false, + "AmazonS3Trace": false, + "AmazonS3RequestTimeoutMilliseconds": 30000 + }, + "EmailSettings": { + "EnableSignUpWithEmail": true, + "EnableSignInWithEmail": true, + "EnableSignInWithUsername": true, + "SendEmailNotifications": false, + "UseChannelInEmailNotifications": false, + "RequireEmailVerification": false, + "FeedbackName": "", + "FeedbackEmail": "", + "ReplyToAddress": "", + "FeedbackOrganization": "", + "EnableSMTPAuth": false, + "SMTPUsername": "", + "SMTPPassword": "", + "SMTPServer": "localhost", + "SMTPPort": "10025", + "SMTPServerTimeout": 10, + "ConnectionSecurity": "", + "SendPushNotifications": true, + "PushNotificationServer": "https://push-test.mattermost.com", + "PushNotificationContents": "full", + "PushNotificationBuffer": 1000, + "EnableEmailBatching": false, + "EmailBatchingBufferSize": 256, + "EmailBatchingInterval": 30, + "EnablePreviewModeBanner": true, + "SkipServerCertificateVerification": false, + "EmailNotificationContentsType": "full", + "LoginButtonColor": "#0000", + "LoginButtonBorderColor": "#2389D7", + "LoginButtonTextColor": "#2389D7", + "EnableInactivityEmail": true + }, + "RateLimitSettings": { + "Enable": false, + "PerSec": 10, + "MaxBurst": 100, + "MemoryStoreSize": 10000, + "VaryByRemoteAddr": true, + "VaryByUser": false, + "VaryByHeader": "" + }, + "PrivacySettings": { + "ShowEmailAddress": true, + "ShowFullName": true + }, + "SupportSettings": { + "TermsOfServiceLink": "https://mattermost.com/terms-of-use/", + "PrivacyPolicyLink": "https://mattermost.com/privacy-policy/", + "AboutLink": "https://docs.mattermost.com/about/product.html/", + "HelpLink": "https://mattermost.com/default-help/", + "ReportAProblemLink": "https://mattermost.com/default-report-a-problem/", + "SupportEmail": "", + "CustomTermsOfServiceEnabled": false, + "CustomTermsOfServiceReAcceptancePeriod": 365, + "EnableAskCommunityLink": true + }, + "AnnouncementSettings": { + "EnableBanner": false, + "BannerText": "", + "BannerColor": "#f2a93b", + "BannerTextColor": "#333333", + "AllowBannerDismissal": true, + "AdminNoticesEnabled": true, + "UserNoticesEnabled": true, + "NoticesURL": "https://notices.mattermost.com/", + "NoticesFetchFrequency": 3600, + "NoticesSkipCache": false + }, + "ThemeSettings": { + "EnableThemeSelection": true, + "DefaultTheme": "default", + "AllowCustomThemes": true, + "AllowedThemes": [] + }, + "GitLabSettings": { + "Enable": false, + "Secret": "", + "Id": "", + "Scope": "", + "AuthEndpoint": "", + "TokenEndpoint": "", + "UserAPIEndpoint": "", + "DiscoveryEndpoint": "", + "ButtonText": "", + "ButtonColor": "" + }, + "GoogleSettings": { + "Enable": false, + "Secret": "", + "Id": "", + "Scope": "profile email", + "AuthEndpoint": "https://accounts.google.com/o/oauth2/v2/auth", + "TokenEndpoint": "https://www.googleapis.com/oauth2/v4/token", + "UserAPIEndpoint": "https://people.googleapis.com/v1/people/me?personFields=names,emailAddresses,nicknames,metadata", + "DiscoveryEndpoint": "", + "ButtonText": "", + "ButtonColor": "" + }, + "Office365Settings": { + "Enable": false, + "Secret": "", + "Id": "", + "Scope": "User.Read", + "AuthEndpoint": "https://login.microsoftonline.com/common/oauth2/v2.0/authorize", + "TokenEndpoint": "https://login.microsoftonline.com/common/oauth2/v2.0/token", + "UserAPIEndpoint": "https://graph.microsoft.com/v1.0/me", + "DiscoveryEndpoint": "", + "DirectoryId": "" + }, + "OpenIdSettings": { + "Enable": false, + "Secret": "", + "Id": "", + "Scope": "profile openid email", + "AuthEndpoint": "", + "TokenEndpoint": "", + "UserAPIEndpoint": "", + "DiscoveryEndpoint": "", + "ButtonText": "", + "ButtonColor": "#145DBF" + }, + "LdapSettings": { + "Enable": false, + "EnableSync": false, + "LdapServer": "", + "LdapPort": 389, + "ConnectionSecurity": "", + "BaseDN": "", + "BindUsername": "", + "BindPassword": "", + "UserFilter": "", + "GroupFilter": "", + "GuestFilter": "", + "EnableAdminFilter": false, + "AdminFilter": "", + "GroupDisplayNameAttribute": "", + "GroupIdAttribute": "", + "FirstNameAttribute": "", + "LastNameAttribute": "", + "EmailAttribute": "", + "UsernameAttribute": "", + "NicknameAttribute": "", + "IdAttribute": "", + "PositionAttribute": "", + "LoginIdAttribute": "", + "PictureAttribute": "", + "SyncIntervalMinutes": 60, + "SkipCertificateVerification": false, + "PublicCertificateFile": "", + "PrivateKeyFile": "", + "QueryTimeout": 60, + "MaxPageSize": 0, + "LoginFieldName": "", + "LoginButtonColor": "#0000", + "LoginButtonBorderColor": "#2389D7", + "LoginButtonTextColor": "#2389D7", + "Trace": false + }, + "ComplianceSettings": { + "Enable": false, + "Directory": "./data/", + "EnableDaily": false, + "BatchSize": 30000 + }, + "LocalizationSettings": { + "DefaultServerLocale": "en", + "DefaultClientLocale": "en", + "AvailableLocales": "" + }, + "SamlSettings": { + "Enable": false, + "EnableSyncWithLdap": false, + "EnableSyncWithLdapIncludeAuth": false, + "IgnoreGuestsLdapSync": false, + "Verify": true, + "Encrypt": true, + "SignRequest": false, + "IdpURL": "", + "IdpDescriptorURL": "", + "IdpMetadataURL": "", + "ServiceProviderIdentifier": "", + "AssertionConsumerServiceURL": "", + "SignatureAlgorithm": "RSAwithSHA1", + "CanonicalAlgorithm": "Canonical1.0", + "ScopingIDPProviderId": "", + "ScopingIDPName": "", + "IdpCertificateFile": "", + "PublicCertificateFile": "", + "PrivateKeyFile": "", + "IdAttribute": "", + "GuestAttribute": "", + "EnableAdminAttribute": false, + "AdminAttribute": "", + "FirstNameAttribute": "", + "LastNameAttribute": "", + "EmailAttribute": "", + "UsernameAttribute": "", + "NicknameAttribute": "", + "LocaleAttribute": "", + "PositionAttribute": "", + "LoginButtonText": "SAML", + "LoginButtonColor": "#34a28b", + "LoginButtonBorderColor": "#2389D7", + "LoginButtonTextColor": "#ffffff" + }, + "NativeAppSettings": { + "AppCustomURLSchemes": [ + "mmauth://", + "mmauthbeta://" + ], + "AppDownloadLink": "https://mattermost.com/download/#mattermostApps", + "AndroidAppDownloadLink": "https://mattermost.com/mattermost-android-app/", + "IosAppDownloadLink": "https://mattermost.com/mattermost-ios-app/" + }, + "ClusterSettings": { + "Enable": false, + "ClusterName": "", + "OverrideHostname": "", + "NetworkInterface": "", + "BindAddress": "", + "AdvertiseAddress": "", + "UseIPAddress": true, + "EnableGossipCompression": true, + "EnableExperimentalGossipEncryption": false, + "ReadOnlyConfig": true, + "GossipPort": 8074, + "StreamingPort": 8075, + "MaxIdleConns": 100, + "MaxIdleConnsPerHost": 128, + "IdleConnTimeoutMilliseconds": 90000 + }, + "MetricsSettings": { + "Enable": false, + "BlockProfileRate": 0, + "ListenAddress": ":8067" + }, + "ExperimentalSettings": { + "ClientSideCertEnable": false, + "ClientSideCertCheck": "secondary", + "LinkMetadataTimeoutMilliseconds": 5000, + "RestrictSystemAdmin": false, + "UseNewSAMLLibrary": false, + "EnableSharedChannels": false, + "EnableRemoteClusterService": false, + "EnableAppBar": false, + "PatchPluginsReactDOM": false + }, + "AnalyticsSettings": { + "MaxUsersForStatistics": 2500 + }, + "ElasticsearchSettings": { + "ConnectionURL": "http://localhost:9200", + "Username": "elastic", + "Password": "changeme", + "EnableIndexing": false, + "EnableSearching": false, + "EnableAutocomplete": false, + "Sniff": true, + "PostIndexReplicas": 1, + "PostIndexShards": 1, + "ChannelIndexReplicas": 1, + "ChannelIndexShards": 1, + "UserIndexReplicas": 1, + "UserIndexShards": 1, + "AggregatePostsAfterDays": 365, + "PostsAggregatorJobStartTime": "03:00", + "IndexPrefix": "", + "LiveIndexingBatchSize": 1, + "BatchSize": 10000, + "RequestTimeoutSeconds": 30, + "SkipTLSVerification": false, + "CA": "", + "ClientCert": "", + "ClientKey": "", + "Trace": "" + }, + "BleveSettings": { + "IndexDir": "", + "EnableIndexing": false, + "EnableSearching": false, + "EnableAutocomplete": false, + "BatchSize": 10000 + }, + "DataRetentionSettings": { + "EnableMessageDeletion": false, + "EnableFileDeletion": false, + "EnableBoardsDeletion": false, + "MessageRetentionDays": 365, + "FileRetentionDays": 365, + "BoardsRetentionDays": 365, + "DeletionJobStartTime": "02:00", + "BatchSize": 3000 + }, + "MessageExportSettings": { + "EnableExport": false, + "ExportFormat": "actiance", + "DailyRunTime": "01:00", + "ExportFromTimestamp": 0, + "BatchSize": 10000, + "DownloadExportResults": false, + "GlobalRelaySettings": { + "CustomerType": "A9", + "SMTPUsername": "", + "SMTPPassword": "", + "EmailAddress": "", + "SMTPServerTimeout": 1800 + } + }, + "JobSettings": { + "RunJobs": true, + "RunScheduler": true, + "CleanupJobsThresholdDays": -1, + "CleanupConfigThresholdDays": -1 + }, + "ProductSettings": { + "EnablePublicSharedBoards": false + }, + "PluginSettings": { + "Enable": true, + "EnableUploads": false, + "AllowInsecureDownloadURL": false, + "EnableHealthCheck": true, + "Directory": "./plugins", + "ClientDirectory": "./client/plugins", + "Plugins": { + "playbooks": { + "BotUserID": "fno5xebm33bhpbb7phdxmr91xe" + } + }, + "PluginStates": { + "com.mattermost.apps": { + "Enable": true + }, + "com.mattermost.calls": { + "Enable": true + }, + "com.mattermost.nps": { + "Enable": true + }, + "focalboard": { + "Enable": true + }, + "playbooks": { + "Enable": true + } + }, + "EnableMarketplace": true, + "EnableRemoteMarketplace": true, + "AutomaticPrepackagedPlugins": true, + "RequirePluginSignature": false, + "MarketplaceURL": "https://api.integrations.mattermost.com", + "SignaturePublicKeyFiles": [], + "ChimeraOAuthProxyURL": "" + }, + "DisplaySettings": { + "CustomURLSchemes": [], + "ExperimentalTimezone": true + }, + "GuestAccountsSettings": { + "Enable": false, + "AllowEmailAccounts": true, + "EnforceMultifactorAuthentication": false, + "RestrictCreationToDomains": "" + }, + "ImageProxySettings": { + "Enable": false, + "ImageProxyType": "local", + "RemoteImageProxyURL": "", + "RemoteImageProxyOptions": "" + }, + "CloudSettings": { + "CWSURL": "https://customers.mattermost.com", + "CWSAPIURL": "https://portal.internal.prod.cloud.mattermost.com" + }, + "ImportSettings": { + "Directory": "./import", + "RetentionDays": 30 + }, + "ExportSettings": { + "Directory": "./export", + "RetentionDays": 30 + } +} diff --git a/webapps/mattermost/templates/mattermost.service.j2 b/webapps/mattermost/templates/mattermost.service.j2 new file mode 100644 index 00000000..59668476 --- /dev/null +++ b/webapps/mattermost/templates/mattermost.service.j2 @@ -0,0 +1,20 @@ +[Unit] +Description=Mattermost +After=network.target +After=postgresql.service +Requires=postgresql.service + +[Service] +Type=notify +Restart=always +WorkingDirectory=/home/%i/mattermost +ExecStart=/home/%i/mattermost/bin/mattermost +TimeoutStartSec=3600 +LimitNOFILE=49152 +RestartSec=10 +User=%i +Group=%i + +[Install] +WantedBy=multi-user.target + diff --git a/webapps/mattermost/templates/vhost.conf.j2 b/webapps/mattermost/templates/vhost.conf.j2 new file mode 100644 index 00000000..4f5525c0 --- /dev/null +++ b/webapps/mattermost/templates/vhost.conf.j2 @@ -0,0 +1,58 @@ +upstream backend_{{ service }} { + server 127.0.0.1:{{ mm_port }}; + keepalive 32; +} + +#proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=mattermost_cache:10m max_size=3g inactive=120m use_temp_path=off; + +server { + listen 80; + listen [::]:80; + #listen 443 ssl; + #listen [::]:443 ssl; + + server_name {{ domains | first }}; + + #ssl_certificate /etc/ssl/certs/mattermost.example.com.pem; + #ssl_certificate_key /etc/ssl/private/mattermost.example.com.pem; + + location ~ /api/v[0-9]+/(users/)?websocket$ { + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + client_max_body_size 50M; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Frame-Options SAMEORIGIN; + proxy_buffers 256 16k; + proxy_buffer_size 16k; + client_body_timeout 60; + send_timeout 300; + lingering_timeout 5; + proxy_connect_timeout 90; + proxy_send_timeout 300; + proxy_read_timeout 90s; + proxy_pass http://backend_{{ service }}; + } + + location / { + client_max_body_size 50M; + proxy_set_header Connection ""; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Frame-Options SAMEORIGIN; + proxy_buffers 256 16k; + proxy_buffer_size 16k; + proxy_read_timeout 600s; + #proxy_cache mattermost_cache; + #proxy_cache_revalidate on; + #proxy_cache_min_uses 2; + #proxy_cache_use_stale timeout; + #proxy_cache_lock on; + proxy_http_version 1.1; + proxy_pass http://backend_{{ service }}; + } +} diff --git a/webapps/mattermost/tests/inventory b/webapps/mattermost/tests/inventory new file mode 100644 index 00000000..878877b0 --- /dev/null +++ b/webapps/mattermost/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/webapps/mattermost/tests/test.yml b/webapps/mattermost/tests/test.yml new file mode 100644 index 00000000..8a42bcf3 --- /dev/null +++ b/webapps/mattermost/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - mattermost diff --git a/webapps/mattermost/vars/main.yml b/webapps/mattermost/vars/main.yml new file mode 100644 index 00000000..2053e362 --- /dev/null +++ b/webapps/mattermost/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file