rundeck-plugins / ansible-plugin

Ansible Integration for Rundeck
MIT License
331 stars 100 forks source link

Cannot invoke "org.rundeck.storage.api.Path.getPath()" because "path" is null #357

Open len-ro opened 6 months ago

len-ro commented 6 months ago

Hello,

In the process of migrating rundeck 4.17 -> 5.1.2 I noticed none of the jobs ran due to:

[quartzScheduler_Worker-1] - Execution failed: 394004 in project symphony: [Workflow result: , step failures: {2=PluginFailed: Cannot invoke "org.rundeck.storage.api.Path.getPath()" because "path" is null}, Node failures: {devops.diapason-treasury.com=[]}, status: failed]

After investigation I found the stackTrace to be, related to tag v3.2.9:

Failed executing step plugin [com.batix.rundeck.plugins.AnsiblePlaybookWorkflowStep]: java.lang.NullPointerException: Cannot invoke "org.rundeck.storage.api.Path.getPath()" because "path" is null
    at com.dtolabs.rundeck.core.storage.ProjectKeyStorageContextProvider.environmentForPath(ProjectKeyStorageContextProvider.java:40)
    at com.dtolabs.rundeck.core.storage.AuthRundeckStorageTree.authorizedPath(AuthRundeckStorageTree.java:62)
    at com.dtolabs.rundeck.core.storage.AuthRundeckStorageTree.getResource(AuthRundeckStorageTree.java:125)
    at com.dtolabs.rundeck.core.storage.AuthRundeckStorageTree.getResource(AuthRundeckStorageTree.java:32)
    at com.dtolabs.rundeck.core.storage.ResolvedExtTree.getResource(ResolvedExtTree.java:68)
    at org.rundeck.storage.impl.DelegateTree.getResource(DelegateTree.java:56)
    at com.rundeck.plugins.ansible.ansible.AnsibleRunnerBuilder.getPassphraseStorageData(AnsibleRunnerBuilder.java:930)
    at com.rundeck.plugins.ansible.ansible.AnsibleRunnerBuilder.getPassphrase(AnsibleRunnerBuilder.java:898)
    at com.rundeck.plugins.ansible.ansible.AnsibleRunnerBuilder.buildAnsibleRunner(AnsibleRunnerBuilder.java:729)
    at com.rundeck.plugins.ansible.plugin.AnsiblePlaybookWorkflowStep.executeStep(AnsiblePlaybookWorkflowStep.java:88)
    at com.dtolabs.rundeck.core.execution.workflow.steps.StepPluginAdapter.executeWorkflowStep(StepPluginAdapter.java:120)
    at com.dtolabs.rundeck.core.execution.ExecutionServiceImpl.executeStep(ExecutionServiceImpl.java:111)
    at com.dtolabs.rundeck.core.execution.workflow.BaseWorkflowExecutor.executeWFItem(BaseWorkflowExecutor.java:285)

I managed to fix this by modifying AnsibleRunnerBuilder.java:

public String getPassphraseStorageData(String storagePath) throws ConfigurationException {
        if(storagePath == null) {
            return null;
        }
        Path path = PathUtil.asPath(storagePath);

to return null if storagePath is null.

I am providing the fix if someone needs it also. Thank you.