From 4c2d21275ace066a47e94712a7a7f2746ccecaad Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Tue, 14 Mar 2017 12:56:23 +1000 Subject: [PATCH] add an example service using EXTRA_CMDLINE Signed-off-by: Sven Dowideit --- docs/os/running-rancheros/server/pxe/index.md | 14 ++++++++++++++ tests/cmdline_test.go | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/docs/os/running-rancheros/server/pxe/index.md b/docs/os/running-rancheros/server/pxe/index.md index f9a7f517..ae8753d6 100644 --- a/docs/os/running-rancheros/server/pxe/index.md +++ b/docs/os/running-rancheros/server/pxe/index.md @@ -31,6 +31,20 @@ kernel ${base-url}/vmlinuz rancher.state.dev=LABEL=RANCHER_STATE rancher.state.a The hidden part of the command line can be accessed with either `sudo ros config get rancher.environment.EXTRA_CMDLINE`, or by using a service file's environment array. +An example service.yml file: + +``` +test: + image: alpine + command: echo "tell me a secret ${EXTRA_CMDLINE}" + labels: + io.rancher.os.scope: system + environment: + - EXTRA_CMDLINE +``` + +When this service is run, the `EXTRA_CMDLINE` will be set. + ### cloud-init Datasources diff --git a/tests/cmdline_test.go b/tests/cmdline_test.go index 14fbffc2..fd007c24 100755 --- a/tests/cmdline_test.go +++ b/tests/cmdline_test.go @@ -36,4 +36,23 @@ func (s *QemuSuite) TestElideCmdLine(c *C) { ) // And then add a service.yml file example. + s.CheckCall(c, + `echo 'test: + image: alpine + command: echo "tell me a secret ${EXTRA_CMDLINE}" + labels: + io.rancher.os.scope: system + environment: + - EXTRA_CMDLINE +' > test.yml`) + s.CheckCall(c, "sudo mv test.yml /var/lib/rancher/conf/test.yml") + s.CheckCall(c, "sudo ros service enable /var/lib/rancher/conf/test.yml") + s.CheckCall(c, "sudo ros service up test") + s.CheckOutput(c, + "test_1 | tell me a secret /init cc.hostname=nope rancher.password=three\n", + Equals, + "sudo ros service logs test | grep secret", + ) + + // TODO: add a test showing we have the right password set }