bland-thailand-60821
09/27/2022, 8:19 PMimport * as pulumi from "@pulumi/pulumi";
import * as equinix_metal from "@pulumi/equinix-metal";
import * as fs from "fs";
const userData = fs.readFileSync('bs.sh','utf8');
const projectId = "xxx";
const testProjectSshKey = new equinix_metal.ProjectSshKey("testProjectSshKey", {
publicKey: "ssh-rsa ",
projectId: projectId,
});
const dsbasenode = new equinix_metal.Device("ds-base-node",{
hostname: "ds-base-node",
plan: "c3.small.x86",
metro: "sv",
operatingSystem: "ubuntu_20_04",
billingCycle: "hourly",
projectSshKeyIds: [testProjectSshKey.id],
projectId: projectId,
userData: fs.readFileSync('./basenode.sh'),
});
// Export the name of the project
export const dsbasenodeIP= dsbasenode.accessPublicIpv4;
little-cartoon-10569
09/27/2022, 8:23 PMOutput<string>
? If you change it to an Input<string>
it should work.Output
should not be used for passing values around: always Input
around.bland-thailand-60821
09/27/2022, 8:27 PMlittle-cartoon-10569
09/27/2022, 8:35 PMreadFileSync()
, so it's returning a Buffer. Provide an encoding and the problem will go away.userData: fs.readFileSync('./basenode.sh'),
to this: userData: fs.readFileSync('./basenode.sh', 'utf8'),
bland-thailand-60821
09/27/2022, 8:41 PM#!/bin/sh
sudo apt-get install -y ansible
sudo apt install python3.8
wget -qO - terraform.gpg <https://apt.releases.hashicorp.com/gpg> | sudo gpg --dearmor -o /usr/share/keyrings/terraform-archive-keyring.gpg
sudo echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/terraform-archive-keyring.gpg] <https://apt.releases.hashicorp.com> $(lsb_release -cs) main" > /etc/apt/sources.list.d/terraform.list
sudo apt install terraform
little-cartoon-10569
09/27/2022, 8:41 PMbland-thailand-60821
09/27/2022, 8:41 PMimport * as pulumi from "@pulumi/pulumi";
import * as equinix_metal from "@pulumi/equinix-metal";
import * as fs from "fs";
import { readFileSync } from "fs";
const userData = readFileSync("bs.sh", {
encoding: "utf-8",
});
export { userData };
const projectId = "XXX";
const testProjectSshKey = new equinix_metal.ProjectSshKey("testProjectSshKey", {
publicKey: "ssh-rsa ",
projectId: projectId,
});
const dsbasenode = new equinix_metal.Device("ds-base-node",{
hostname: "ds-base-node",
plan: "c3.small.x86",
metro: "sv",
operatingSystem: "ubuntu_20_04",
billingCycle: "hourly",
projectSshKeyIds: [testProjectSshKey.id],
projectId: projectId,
});
// Export the name of the project
export const dsbasenodeIP= dsbasenode.accessPublicIpv4;
Resources:
3 unchanged
Do you want to perform this update? yes
Updating (stage):
Type Name Status
pulumi:pulumi:Stack metal-auto-stage
Outputs:
dsbasenodeIP: "139.178.70.225"
userData : "#!/bin/sh\n\nsudo apt-get install -y ansible\n\nsudo apt install python3.8\n\nwget -qO - terraform.gpg <https://apt.releases.hashicorp.com/gpg> | sudo gpg --dearmor -o /usr/share/keyrings/terraform-archive-keyring.gpg\n\nsudo echo \"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/terraform-archive-keyring.gpg] <https://apt.releases.hashicorp.com> $(lsb_release -cs) main\" > /etc/apt/sources.list.d/terraform.list\n\nsudo apt install terraform\n\n\n"
little-cartoon-10569
09/27/2022, 8:50 PMbland-thailand-60821
09/27/2022, 9:13 PMDo you want to perform this update? yes
Updating (stage):
Type Name Status Info
+ pulumi:pulumi:Stack metal-auto-stage created 13 messages
+ ├─ equinix-metal:index:ProjectSshKey testProjectSshKey created
+ └─ equinix-metal:index:Device ds-base-node created
Diagnostics:
pulumi:pulumi:Stack (metal-auto-stage):
2022/09/27 13:54:37 [DEBUG] POST <https://api.equinix.com/metal/v1/projects/e981d829-e0ac-463a-ad82-57bae2063c61/ssh-keys>
2022/09/27 13:54:38 [DEBUG] GET <https://api.equinix.com/metal/v1/ssh-keys/4ffc7bb8-eb79-48fc-a268-755d4c9dd4ad>
2022/09/27 13:54:40 [DEBUG] POST <https://api.equinix.com/metal/v1/projects/e981d829-e0ac-463a-ad82-57bae2063c61/devices>
2022/09/27 13:54:51 [DEBUG] GET <https://api.equinix.com/metal/v1/devices/1daef2a9-2b19-4ed1-be34-b255a901eabd?include=project%2Cfacility>
2022/09/27 13:54:56 [DEBUG] GET <https://api.equinix.com/metal/v1/devices/1daef2a9-2b19-4ed1-be34-b255a901eabd?include=project%2Cfacility>
2022/09/27 13:55:03 [DEBUG] GET <https://api.equinix.com/metal/v1/devices/1daef2a9-2b19-4ed1-be34-b255a901eabd?include=project%2Cfacility>
2022/09/27 13:55:14 [DEBUG] GET <https://api.equinix.com/metal/v1/devices/1daef2a9-2b19-4ed1-be34-b255a901eabd?include=project%2Cfacility>
2022/09/27 13:55:26 [DEBUG] GET <https://api.equinix.com/metal/v1/devices/1daef2a9-2b19-4ed1-be34-b255a901eabd?include=project%2Cfacility>
2022/09/27 13:55:37 [DEBUG] GET <https://api.equinix.com/metal/v1/devices/1daef2a9-2b19-4ed1-be34-b255a901eabd?include=project%2Cfacility>
2022/09/27 13:55:49 [DEBUG] GET <https://api.equinix.com/metal/v1/devices/1daef2a9-2b19-4ed1-be34-b255a901eabd?include=project%2Cfacility>
2022/09/27 13:56:00 [DEBUG] GET <https://api.equinix.com/metal/v1/devices/1daef2a9-2b19-4ed1-be34-b255a901eabd?include=project%2Cfacility>
2022/09/27 13:56:12 [DEBUG] GET <https://api.equinix.com/metal/v1/devices/1daef2a9-2b19-4ed1-be34-b255a901eabd?include=project%2Cfacility>
2022/09/27 13:56:13 [DEBUG] GET <https://api.equinix.com/metal/v1/devices/1daef2a9-2b19-4ed1-be34-b255a901eabd?include=project%2Cmetro%2Cfacility>
Outputs:
dsbasenodeIP: "139.178.70.225"
userData : "#!/bin/sh\n\nsudo apt-get install -y ansible\n\nsudo apt install python3.8\n\nwget -qO - terraform.gpg <https://apt.releases.hashicorp.com/gpg> | sudo gpg --dearmor -o /usr/share/keyrings/terraform-archive-keyring.gpg\n\nsudo echo \"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/terraform-archive-keyring.gpg] <https://apt.releases.hashicorp.com> $(lsb_release -cs) main\" > /etc/apt/sources.list.d/terraform.list\n\nsudo apt install terraform\n\n\n"
Resources:
+ 3 created
root@ds-base-node:~# ls
snap
root@ds-base-node:~#
root@ds-base-node:~# ls
snap
root@ds-base-node:~# ls
snap
root@ds-base-node:~# terraform --version
Command 'terraform' not found, but can be installed with:
#!/bin/env node
stocky-restaurant-98004
09/27/2022, 10:09 PMtouch ~/userdata_works
in your script?/var/lib/cloud/instance/user-data.txt
/var/log/cloud-init.log and /var/log/cloud-init-output.log