rundeck / terraform-provider-rundeck

Terraform Rundeck provider
https://www.terraform.io/docs/providers/rundeck/
Mozilla Public License 2.0
52 stars 61 forks source link

private_key ressource import corrumption to execute sshj-ssh commands .... Cannot invoke "net.schmizz.sshj.userauth.keyprovider.KeyProvider.getPublic()" because "this.kProv" is null #125

Open mdelagliere opened 7 months ago

mdelagliere commented 7 months ago

Hi there,

Terraform Version

Terraform v1.7.5 on linux_amd64

Affected Resource(s)

terraform { required_providers { rundeck = { source = "rundeck/rundeck" version = "0.4.7" } } }

resource "rundeck_private_key" "id_rsa_test" { path = "project/terraform/id_rsa_test.pem" key_material = "$${file(\"/home/USERHOME/.ssh/id_rsa_test.pem\")}" } resource "rundeck_project" "terraform" { name = var.nom_projet description = var.description_projet

Utilisation d'un chemin unique pour stocker les clés SSH

ssh_key_storage_path = "keys/${rundeck_private_key.id_rsa_test.path}" default_node_executor_plugin = "sshj-ssh"

 resource_model_source {
   type = "file"
   config = {
       format = "resourceyaml"
       file = "/var/lib/rundeck/remote-node.yml"
       writable = true
       generateFileAutomatically = "false"
       ssh_authentication_type = "privateKey"
   }

}

extra_config = { "project.label" = var.label_projet "project.ssh-authentication" = "privateKey" "project.ssh-key-storage-path" = "keys/project/terraform/id_rsa_test.pem" "resources.source.1.config.file" = "/var/lib/rundeck/remote-node.yml" "resources.source.1.config.format" = "resourceyaml" "resources.source.1.config.generateFileAutomatically" = "false" "resources.source.1.config.ssh_authentication_type" = "privateKey" "resources.source.1.config.writable" = "true" "resources.source.1.type" = "file" "service.FileCopier.default.provider" = "sshj-scp" "service.NodeExecutor.default.provider" = "sshj-ssh" } }

from commands'project menu :

Failed: Unknown: Cannot invoke "net.schmizz.sshj.userauth.keyprovider.KeyProvider.getPublic()" because "this.kProv" is null Execution failed: 34 in project terraform: [Workflow result: , step failures: {1=Dispatch failed on 1 nodes: [remote-node: Unknown: Cannot invoke "net.schmizz.sshj.userauth.keyprovider.KeyProvider.getPublic()" because "this.kProv" is null + {dataContext=MultiDataContextImpl(map={ContextView(node:remote-node)=BaseDataContext{{exec={exitCode=-1}}}, ContextView(step:1, node:remote-node)=BaseDataContext{{exec={exitCode=-1}}}}, base=null)} ]}, Node failures: {remote-node=[Unknown: Cannot invoke "net.schmizz.sshj.userauth.keyprovider.KeyProvider.getPublic()" because "this.kProv" is null + {dataContext=MultiDataContextImpl(map={ContextView(node:remote-node)=BaseDataContext{{exec={exitCode=-1}}}, ContextView(step:1, node:remote-node)=BaseDataContext{{exec={exitCode=-1}}}}, base=null)} ]}, status: failed]

to soluce that, i overwrite key from gui menu key storage with

-----BEGIN RSA PRIVATE KEY----- MIIJKAIBAAKCAgEA0KkNQEihbMdmXFetDgVxh3q++zSzDbor2EYx7HHN6TZNpg/N -----END RSA PRIVATE KEY----- and when i did that, command menu it does work well ....

i need help

remote-node.yml : remote-node: description: Remote SSH Swarm Server hostname: IP_OF_REMOTE nodename: swarm-manager osArch: amd64 osFamily: unix osName: Linux osVersion: 5.15.0-89-generic tags: 'swarm' username: michael ssh-key-storage-path: keys/project/terraform/id_rsa_test.pem

fdevans commented 1 month ago

Sorry, I'm not following what the issue is here. Can you please provide more detail?