pulumi-command icon indicating copy to clipboard operation
pulumi-command copied to clipboard

Add the ability for a command to be used as information gathering on the system

Open callicles opened this issue 10 months ago • 1 comments

Hello!

  • Vote on this issue by adding a 👍 reaction
  • If you want to implement this feature, comment to let us know (we'll work with you on design, scheduling, etc.)

Issue details

I am trying to write a script to setup a VM with docker and a whole stack. I was thinking I could use the commands to gather facts about the machine like you would do in ansible.

something like

    new remote.Command("isDockerInstalled", {
        connection: connectionParameters,
        create: "docker info",
    });

and use that to determine if I need to install docker. However the command fails (docker is not installed initially)

and I get a wall of red in pulumi.

I am a beginner with pulumi so if there is a better way to do this - happy to be redirected.

Thank you

callicles avatar Apr 18 '24 22:04 callicles

Thanks for filing this @callicles. Would you mind sharing the full output you get from pulumi and the contents of pulumi about?

However, depending on exactly what you're trying to do, you may not need to use the a remote.Command resource here at all. The main value of using Command is that you can leverage pulumi's state management engine when you're running commands that manipulate the state of your infrastructure (eg. if you were installing docker on the server).

If you're just running informational commands, you could just run the remote command in your program directly using a library like simple-ssh.

At any rate, we'd still love to see the details of the error message and if you share more about the larger use case you're working on, we can try to give additional advice about the best way to accomplish your goals.

mjeffryes avatar Apr 18 '24 23:04 mjeffryes