forked from joakimk/pipeline
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Peter Wall <[email protected]>
- Loading branch information
Showing
4 changed files
with
65 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
class Api::CloudInitsController < ApiController | ||
# This bootstraps github actions runners. | ||
def show | ||
data = | ||
{ | ||
users: [ | ||
{ | ||
name: "username", | ||
plain_text_passwd: "password", | ||
lock_passwd: false, | ||
chpasswd: { expire: false }, | ||
sudo: "ALL=(ALL) NOPASSWD:ALL", | ||
shell: "/bin/bash" | ||
} | ||
], | ||
disable_root: true, | ||
ssh_pwauth: false, | ||
ssh_deletekeys: true, | ||
packages: [ "curl" ], | ||
package_update: true, | ||
package_upgrade: true, | ||
write_files: [ | ||
{ | ||
path: "/etc/motd", | ||
content: "Hello there." | ||
} | ||
], | ||
runcmd: [ | ||
"systemctl stop sshd", | ||
"systemctl disable sshd", | ||
"curl https://maintenance.auctionet.dev/it-ran", | ||
"reboot" | ||
] | ||
} | ||
|
||
yaml = "#cloud-config\n" + | ||
data | ||
.deep_stringify_keys | ||
.to_yaml.sub("---", "") | ||
|
||
render plain: yaml, content_type: "text/cloud-config" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require "spec_helper" | ||
|
||
RSpec.describe "GET /api/cloud_init", type: :request do | ||
it "gets a cloud init config if you have the right api token" do | ||
allow(App).to receive(:api_token).and_return("secret") | ||
|
||
get "/api/cloud_init?token=secret" | ||
|
||
expect(response).to be_successful | ||
expect(response.body).to include("#cloud-config") | ||
end | ||
|
||
it "fails when the api token is wrong" do | ||
allow(App).to receive(:api_token).and_return("secret") | ||
|
||
get "/api/cloud_init?token=wrong" | ||
|
||
expect(response).not_to be_successful | ||
expect(response.body).not_to include("#cloud-config") | ||
end | ||
end |