Giter Site home page Giter Site logo

Comments (6)

Fudoshiki avatar Fudoshiki commented on August 18, 2024

Using API v2

export BASE64=`fcct config.ign | base64`

curl --location --request POST 'https://api.vultr.com/v2/instances' \
--header "Authorization: Bearer $VULTR_API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
	"region" : "ams",
	"plan" : "vhf-1c-1gb",
	"label" : "example.com",
	"os_id" : "391",
	"user_data" : "$BASE64",
	"enable_ipv6": "true",
  "tag": "Web",
  "hostname": "example.com"
}'

same issue

Снимок экрана 2020-11-23 в 10 04 25

from vultr-cli.

Fudoshiki avatar Fudoshiki commented on August 18, 2024

No ignition field in https://www.vultr.com/api/v2/#operation/create-instance ?

from vultr-cli.

ddymko avatar ddymko commented on August 18, 2024

@Fudoshiki the ignition file should be passed in as userdata

Here is a sample ignition file

{
  "ignition": { "version": "2.2.0" },
  "systemd": {
    "units": [{
      "name": "example.service",
      "enabled": true,
      "contents": "[Service]\nType=oneshot\nExecStart=/usr/bin/echo Hello World\n\n[Install]\nWantedBy=multi-user.target"
    }]
  }
}

The base64 would be

ewogICJpZ25pdGlvbiI6IHsgInZlcnNpb24iOiAiMi4yLjAiIH0sCiAgInN5c3RlbWQiOiB7CiAgICAidW5pdHMiOiBbewogICAgICAibmFtZSI6ICJleGFtcGxlLnNlcnZpY2UiLAogICAgICAiZW5hYmxlZCI6IHRydWUsCiAgICAgICJjb250ZW50cyI6ICJbU2VydmljZV1cblR5cGU9b25lc2hvdFxuRXhlY1N0YXJ0PS91c3IvYmluL2VjaG8gSGVsbG8gV29ybGRcblxuW0luc3RhbGxdXG5XYW50ZWRCeT1tdWx0aS11c2VyLnRhcmdldCIKICAgIH1dCiAgfQp9

You would then pass this into your curl request


curl --location --request POST 'https://api.vultr.com/v2/instances' \
--header "Authorization: Bearer $VULTR_API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
	"region" : "ams",
	"plan" : "vhf-1c-1gb",
	"label" : "example.com",
	"os_id" : "391",
	"user_data" : "ewogICJpZ25pdGlvbiI6IHsgInZlcnNpb24iOiAiMi4yLjAiIH0sCiAgInN5c3RlbWQiOiB7CiAgICAidW5pdHMiOiBbewogICAgICAibmFtZSI6ICJleGFtcGxlLnNlcnZpY2UiLAogICAgICAiZW5hYmxlZCI6IHRydWUsCiAgICAgICJjb250ZW50cyI6ICJbU2VydmljZV1cblR5cGU9b25lc2hvdFxuRXhlY1N0YXJ0PS91c3IvYmluL2VjaG8gSGVsbG8gV29ybGRcblxuW0luc3RhbGxdXG5XYW50ZWRCeT1tdWx0aS11c2VyLnRhcmdldCIKICAgIH1dCiAgfQp9",
	"enable_ipv6": "true",
  "tag": "Web",
  "hostname": "example.com"
}'

The same goes for the CLI you will need to pass in the b64 value

from vultr-cli.

Fudoshiki avatar Fudoshiki commented on August 18, 2024

config.fcc

variant: fcos
version: 1.2.0
passwd:
  users:
    - name: core
      ssh_authorized_keys:
        - ssh-key ...
      groups: [ sudo, docker ]
storage:
  directories:
    - path: /opt/releases
      overwrite: true
      mode: 0755

Run fcct config.fcc and got output

{"ignition":{"version":"3.2.0"},"passwd":{"users":[{"groups":["sudo","docker"],"name":"core","sshAuthorizedKeys":["ssh-key ..."]}]},"storage":{"directories":[{"overwrite":true,"path":"/opt/releases","mode":493}]}}

With fcct config.fcc | base64 got output

eyJpZ25pdGlvbiI6eyJ2ZXJzaW9uIjoiMy4yLjAifSwicGFzc3dkIjp7InVzZXJzIjpbeyJncm91cHMiOlsic3VkbyIsImRvY2tlciJdLCJuYW1lIjoiY29ayZSIsInNzaEF1dGhvcml6ZWRLZXlzIjpbInNzaC1lZDI1NTE5IEFBQUFDM056YUMxbFpESTFOVEU1QUFBQUlIM2dFV2NhTnNsNGIrdzNYelg3VVMrMzc5QUZmUkFmaUlrRUVFNTFHUDUrIGZ1ZG9zaGlraS5hcmlAZ21haWwuY29tIl19XX0sInN0b3JhZ2UiOnsiZGlZWN0b3JpZXMiOlt7Im92ZXJ3cml0ZSI6dHJ1ZSwicGF0aCI6Ii9vcHQvcmVsZWFzZXMiLCJtb2RlIjo0OTN9XX19Cg==

fcct config.fcc | base64 | base64 -d returning config back

{"ignition":{"version":"3.2.0"},"passwd":{"users":[{"groups":["sudo","docker"],"name":"core","sshAuthorizedKeys":["ssh-key ..."]}]},"storage":{"directories":[{"overwrite":true,"path":"/opt/releases","mode":493}]}}

Now put it in request

curl --location --request POST 'https://api.vultr.com/v2/instances' \
--header "Authorization: Bearer $VULTR_API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
  "region" : "ams",
  "plan" : "vhf-1c-1gb",
  "label" : "example.com",
  "os_id" : "391",
  "user_data" : "eyJpZ25pdGlvbiI6eyJ2ZXJzaW9uIjoiMy4yLjAifSwicGFzc3dkIjp7InVzZXJzIjpbeyJncm91cHMiOlsic3VkbyIsImRvY2tlciJdLCJuYW1lIjoiY29ayZSIsInNzaEF1dGhvcml6ZWRLZXlzIjpbInNzaC1lZDI1NTE5IEFBQUFDM056YUMxbFpESTFOVEU1QUFBQUlIM2dFV2NhTnNsNGIrdzNYelg3VVMrMzc5QUZmUkFmaUlrRUVFNTFHUDUrIGZ1ZG9zaGlraS5hcmlAZ21haWwuY29tIl19XX0sInN0b3JhZ2UiOnsiZGlZWN0b3JpZXMiOlt7Im92ZXJ3cml0ZSI6dHJ1ZSwicGF0aCI6Ii9vcHQvcmVsZWFzZXMiLCJtb2RlIjo0OTN9XX19Cg==",
  "enable_ipv6": "true",
  "tag": "Web",
  "hostname": "example.com"
}'

result

{"instance":{"id":"9669cd2c-dbb1-4630-b2de-de24d4371524","os":"Fedora CoreOS","ram":1024,"disk":0,"main_ip":"0.0.0.0","vcpu_count":1,"region":"ams","plan":"vhf-1c-1gb","date_created":"2020-11-23T14:40:17+00:00","status":"pending","allowed_bandwidth":1000,"netmask_v4":"","gateway_v4":"0.0.0.0","power_status":"running","server_status":"none","v6_network":"","v6_main_ip":"","v6_network_size":0,"label":"example.com","internal_ip":"","kvm":"","tag":"Web","os_id":391,"app_id":0,"firewall_group_id":"","features":[],"default_password":"Yv!6Ao]U}[nS%xWd"}}%

But os can't start. In console this error

Снимок экрана 2020-11-23 в 19 43 30

from vultr-cli.

Fudoshiki avatar Fudoshiki commented on August 18, 2024

Same with vultr-cli

from vultr-cli.

Fudoshiki avatar Fudoshiki commented on August 18, 2024

@ddymko Fixed
Change to version: 1.1.0

from vultr-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.