mmctl icon indicating copy to clipboard operation
mmctl copied to clipboard

mmctl can't set config for newly installed plugin

Open wintamute opened this issue 3 years ago • 2 comments

Please see https://github.com/mattermost/mmctl/issues/427#issuecomment-1124321044 for direction on the task here.

Original post:

I'm currently automating setup of mattermost server including plugins using containers (using the latest version 6.2.1) For the plugin installation and system configuration I'm using a script with mmctl commands. This works well except for the step of setting the configuration of the newly installed plugin (antivirus in this case, didn't test with any other plugins). Only after manually changing the config via the system console in the UI mmctl is able to change the settings.

My guess is that the plugin creates the config path after saving the changes in the system console whereas mmctl only changes existing values. So not sure if this is a bug or intended behaviour, in any case, it prevents fully automating the plugin installation and configuration, you always have to manually save (create) the config via the UI.

+ docker-compose exec -T mmserver mmctl plugin marketplace install antivirus
Plugin Antivirus successfully installed
+ docker-compose exec -T mmserver mmctl plugin enable antivirus
Enabled plugin: antivirus
+ docker-compose exec -T mmserver mmctl config set PluginSettings.Plugins.antivirus.clamavhostport 192.168.10.22:3310
Error: path object type is not supported
+ docker-compose exec -T mmserver mmctl config set PluginSettings.Plugins.antivirus.scantimeoutseconds 10
Error: path object type is not supported

running config shows that the plugin was successfully installed and enabled, but no config

docker-compose exec -T mmserver mmctl config show
# just the plugin part
"PluginSettings": {
    "Enable": true,
    "EnableUploads": false,
    "AllowInsecureDownloadUrl": false,
    "EnableHealthCheck": true,
    "Directory": "/mattermost/plugins/",
    "ClientDirectory": "./client/plugins",
    "Plugins": {
      "playbooks": {
        "BotUserID": "ji5jufxjgir17nccu3619xse9e"
      }
    },
    "PluginStates": {
      "antivirus": {
        "Enable": true
      },
      "com.mattermost.nps": {
        "Enable": true
      },
      "com.mattermost.plugin-incident-management": {
        "Enable": false
      },
      "focalboard": {
        "Enable": true
      },
      "playbooks": {
        "Enable": true
      }
    },

Once I open the systemconsole, I can see the plugin listed and the configuration screen, I can edit the settings and save them. Only now the config is present in the config show output:

docker-compose exec -T mmserver mmctl config show
# just the plugin part
"PluginSettings": {
    "Enable": true,
    "EnableUploads": false,
    "AllowInsecureDownloadUrl": false,
    "EnableHealthCheck": true,
    "Directory": "/mattermost/plugins/",
    "ClientDirectory": "./client/plugins",
    "Plugins": {
      "antivirus": {
        "clamavhostport": "localhost:3310",
        "scantimeoutseconds": 10
      },
      "playbooks": {
        "BotUserID": "ji5jufxjgir17nccu3619xse9e"
      }
    },
    "PluginStates": {
      "antivirus": {
        "Enable": true
      },
      "com.mattermost.nps": {
        "Enable": true
      },
      "com.mattermost.plugin-incident-management": {
        "Enable": false
      },
      "focalboard": {
        "Enable": true
      },
      "playbooks": {
        "Enable": true
      }
    },

Now running the same script again, I can sucessfully change the plugin config:

+ docker-compose exec -T mmserver mmctl plugin marketplace install antivirus
Plugin Antivirus successfully installed
+ docker-compose exec -T mmserver mmctl plugin enable antivirus
Enabled plugin: antivirus
+ docker-compose exec -T mmserver mmctl config set PluginSettings.Plugins.antivirus.clamavhostport 192.168.10.22:3310
Value changed successfully

wintamute avatar Jan 12 '22 15:01 wintamute

Hey @wintamute, thanks for the feedback we will be looking into this. Created the ticket here: https://mattermost.atlassian.net/browse/MM-43065

isacikgoz avatar Apr 05 '22 11:04 isacikgoz

When a plugin is installed, its config structure is not populated at first. As noted in the issue description, the admin needs to submit the plugin's config form from the UI in order to have the config's structure to be populated.

In the config's initial state, the mmctl tool is not able to edit individual values in the nested structure, since the nested structure isn't created yet. The task here is to make it so mmctl is able to create the nested structure if the structure hasn't been initialized, before attempting to edit these plugin setting values.

mickmister avatar May 11 '22 21:05 mickmister

Tracked via https://github.com/mattermost/mattermost/issues/21013

hanzei avatar Jan 22 '24 11:01 hanzei