Skip to content

Commit

Permalink
Merge pull request #757 from bottlerocket-os/rename-moondog
Browse files Browse the repository at this point in the history
Rename 'moondog' to 'early-boot-config'
  • Loading branch information
zmrow authored Feb 25, 2020
2 parents 48565fd + d399f0a commit cafe8f2
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 52 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ For more details, see the [apiserver documentation](sources/api/apiserver/).
The [apiclient](sources/api/apiclient/) can be used to make requests.
They're just HTTP requests, but the API client simplifies making requests with the Unix-domain socket.

To make configuration easier, we have [moondog](sources/api/moondog/), which can send an API request for you based on instance user data.
To make configuration easier, we have [early-boot-config](sources/api/early-boot-config/), which can send an API request for you based on instance user data.
If you start a virtual machine, like an EC2 instance, it will read TOML-formatted Bottlerocket configuration from user data and send it to the API server.
This way, you can configure your Bottlerocket instance without having to make API calls after launch.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ Description=Bottlerocket userdata configuration system
# Need network online to talk to IMDS.
After=network-online.target apiserver.service
Requires=network-online.target apiserver.service
# We only want to run once, at first boot. This file is created by moondog
# We only want to run once, at first boot. This file is created by early-boot-config
# after a successful run.
ConditionPathExists=!/var/lib/bottlerocket/moondog.ran
ConditionPathExists=!/var/lib/bottlerocket/early-boot-config.ran

[Service]
Type=oneshot
ExecStart=/usr/bin/moondog
ExecStart=/usr/bin/early-boot-config
RemainAfterExit=true
StandardError=journal+console

Expand Down
16 changes: 8 additions & 8 deletions packages/os/os.spec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Source5: updog-toml

# 1xx sources: systemd units
Source100: apiserver.service
Source101: moondog.service
Source101: early-boot-config.service
Source102: sundog.service
Source103: storewolf.service
Source105: settings-applier.service
Expand All @@ -45,10 +45,10 @@ Summary: Bottlerocket API client
%description -n %{_cross_os}apiclient
%{summary}.

%package -n %{_cross_os}moondog
%package -n %{_cross_os}early-boot-config
Summary: Bottlerocket userdata configuration system
Requires: %{_cross_os}apiserver = %{version}-%{release}
%description -n %{_cross_os}moondog
%description -n %{_cross_os}early-boot-config
%{summary}.

%package -n %{_cross_os}netdog
Expand Down Expand Up @@ -149,7 +149,7 @@ Summary: Thar data store migrations
mkdir bin
%cargo_build --manifest-path %{_builddir}/sources/Cargo.toml \
-p apiserver \
-p moondog \
-p early-boot-config \
-p netdog \
-p sundog \
-p schnauzer \
Expand Down Expand Up @@ -180,7 +180,7 @@ done
install -d %{buildroot}%{_cross_bindir}
for p in \
apiserver \
moondog netdog sundog schnauzer pluto bork \
early-boot-config netdog sundog schnauzer pluto bork \
thar-be-settings servicedog host-containers \
storewolf settings-committer \
migrator \
Expand Down Expand Up @@ -252,9 +252,9 @@ install -p -m 0644 %{S:201} %{buildroot}%{_cross_tmpfilesdir}/host-containers.co
%files -n %{_cross_os}apiclient
%{_cross_bindir}/apiclient

%files -n %{_cross_os}moondog
%{_cross_bindir}/moondog
%{_cross_unitdir}/moondog.service
%files -n %{_cross_os}early-boot-config
%{_cross_bindir}/early-boot-config
%{_cross_unitdir}/early-boot-config.service

%files -n %{_cross_os}netdog
%{_cross_bindir}/netdog
Expand Down
4 changes: 2 additions & 2 deletions packages/os/settings-applier.service
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[Unit]
Description=Applies settings to create config files
After=storewolf.service sundog.service moondog.service apiserver.service
After=storewolf.service sundog.service early-boot-config.service apiserver.service
Requires=apiserver.service
Wants=storewolf.service sundog.service moondog.service
Wants=storewolf.service sundog.service early-boot-config.service

[Service]
Type=oneshot
Expand Down
2 changes: 1 addition & 1 deletion packages/os/sundog.service
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Unit]
Description=User-specified setting generators
# Need network access to support commands talking to IMDS.
After=network-online.target apiserver.service moondog.service
After=network-online.target apiserver.service early-boot-config.service
Requires=network-online.target apiserver.service

[Service]
Expand Down
2 changes: 1 addition & 1 deletion packages/release/release.spec
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Requires: %{_cross_os}kernel
Requires: %{_cross_os}kernel-modules
Requires: %{_cross_os}kernel-devel
Requires: %{_cross_os}bork
Requires: %{_cross_os}moondog
Requires: %{_cross_os}early-boot-config
Requires: %{_cross_os}schnauzer
Requires: %{_cross_os}netdog
Requires: %{_cross_os}selinux-policy
Expand Down
34 changes: 17 additions & 17 deletions sources/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sources/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = [
"api/apiserver",
"api/apiclient",
"api/bork",
"api/moondog",
"api/early-boot-config",
"api/netdog",
"api/sundog",
"api/schnauzer",
Expand Down
6 changes: 3 additions & 3 deletions sources/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ If there are any pending transactions in the data store when storewolf starts, t
The API server for Bottlerocket starts next.
This gives users (and later components) the ability to read or change settings in the data store, and have any changes applied to the system.

### moondog
### early-boot-config

[Further docs](moondog/)
[Further docs](early-boot-config/)

Moondog applies settings changes that the user requests through EC2 user data.
early-boot-config applies settings changes that the user requests through EC2 user data.
Think of it as cloud-init but smaller in scope; we only accept TOML-formatted settings that the API understands, right now.

It only runs on first boot.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "moondog"
name = "early-boot-config"
version = "0.1.0"
authors = ["Zac Mrowicki <[email protected]>"]
license = "Apache-2.0 OR MIT"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# moondog
# early-boot-config

Current version: 0.1.0

## Introduction

moondog sends provider-specific platform data to the Bottlerocket API.
early-boot-config sends provider-specific platform data to the Bottlerocket API.

For most providers this means configuration from user data and platform metadata, taken from
something like an instance metadata service.

Currently, Amazon EC2 is supported through the IMDSv1 HTTP API. Data will be taken from files in
/etc/moondog instead, if available, for testing purposes.
/etc/early-boot-config instead, if available, for testing purposes.

## Colophon

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*!
# Introduction
moondog sends provider-specific platform data to the Bottlerocket API.
early-boot-config sends provider-specific platform data to the Bottlerocket API.
For most providers this means configuration from user data and platform metadata, taken from
something like an instance metadata service.
Currently, Amazon EC2 is supported through the IMDSv1 HTTP API. Data will be taken from files in
/etc/moondog instead, if available, for testing purposes.
/etc/early-boot-config instead, if available, for testing purposes.
*/

#![deny(rust_2018_idioms)]
Expand All @@ -33,12 +33,10 @@ const API_SETTINGS_URI: &str = "/settings";
// We change settings in the shared transaction used by boot-time services.
const TRANSACTION: &str = "bottlerocket-launch";

// We only want to run moondog once, at first boot. Our systemd unit file has a
// We only want to run early-boot-config once, at first boot. Our systemd unit file has a
// ConditionPathExists that will prevent it from running again if this file exists.
// We create it after running successfully.
const MARKER_FILE: &str = "/var/lib/bottlerocket/moondog.ran";

type Result<T> = std::result::Result<T, MoondogError>;
const MARKER_FILE: &str = "/var/lib/bottlerocket/early-boot-config.ran";

mod error {
use http::StatusCode;
Expand All @@ -60,7 +58,7 @@ mod error {

#[derive(Debug, Snafu)]
#[snafu(visibility = "pub(super)")]
pub(super) enum MoondogError {
pub(super) enum Error {
#[snafu(display("Error {}ing '{}': {}", method, uri, source))]
Request {
method: String,
Expand Down Expand Up @@ -125,7 +123,8 @@ mod error {
Logger { source: simplelog::TermLogError },
}
}
use error::MoondogError;

type Result<T> = std::result::Result<T, error::Error>;

/// Support for new platforms can be added by implementing this trait.
trait PlatformDataProvider {
Expand All @@ -145,9 +144,9 @@ impl AwsDataProvider {
// FIXME Pin to a date version that supports IMDSv2 once such a date version is available.
const IMDS_TOKEN_ENDPOINT: &'static str = "http://169.254.169.254/latest/api/token";

const USER_DATA_FILE: &'static str = "/etc/moondog/user-data";
const USER_DATA_FILE: &'static str = "/etc/early-boot-config/user-data";
const USER_DATA_ENDPOINT: &'static str = "http://169.254.169.254/2018-09-24/user-data";
const IDENTITY_DOCUMENT_FILE: &'static str = "/etc/moondog/identity-document";
const IDENTITY_DOCUMENT_FILE: &'static str = "/etc/early-boot-config/identity-document";
const IDENTITY_DOCUMENT_ENDPOINT: &'static str =
"http://169.254.169.254/2018-09-24/dynamic/instance-identity/document";

Expand Down Expand Up @@ -409,7 +408,7 @@ fn run() -> Result<()> {
TermLogger::init(args.log_level, LogConfig::default(), TerminalMode::Mixed)
.context(error::Logger)?;

info!("Moondog started");
info!("early-boot-config started");

// Figure out the current provider
info!("Detecting platform data provider");
Expand Down

0 comments on commit cafe8f2

Please sign in to comment.