Comments (6)
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
from vultr-cli.
No ignition field in https://www.vultr.com/api/v2/#operation/create-instance ?
from vultr-cli.
@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.
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
from vultr-cli.
Same with vultr-cli
from vultr-cli.
@ddymko Fixed
Change to version: 1.1.0
from vultr-cli.
Related Issues (20)
- [Feature] - Allow update of bare metal user data without reading from a file
- [BUG] - Load balancer rule create command doesn't work
- [BUG] - CLI requires non-empty VULTR_API_KEY for "help [..]" and "version" subcommands HOT 4
- [Feature] - Omit the `-cli` suffix? (not the repository) HOT 1
- Can't create bare metal instance HOT 2
- [Feature] - iPXE
- Expose "enable firewall" option for kubernetes create command HOT 1
- [BUG] - read_write isn't being passed on Docker Credentials Create
- [BUG] - Listing region availabilities causes a panic HOT 1
- [BUG] - Unable to get cluster config from CLI HOT 2
- [BUG] cannot add firewall rule HOT 4
- [BUG] - Detaching VPC2 does not work, api issue? HOT 6
- [BUG] - vpc2 delete -> 404
- [BUG] - Config file isn't being used to authenticate
- [BUG] - First run of vultr-cli prints warning
- [BUG] - Proxy protocol flag error on load balancer create HOT 1
- [Feature] - Allow attaching VPC2 to instance upon creation
- [BUG] - Error when creating DNS record CAA HOT 2
- [TEST] - Test issue
- [Feature] - Support paging for repositories in container registry HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vultr-cli.