Compare commits
109 Commits
v0.5.0-rc3
...
v0.6.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70f2c8dd3a | ||
|
|
3b68017af5 | ||
|
|
2081b1be95 | ||
|
|
73d0790e30 | ||
|
|
3262aa7497 | ||
|
|
17e01a3771 | ||
|
|
4d8da95bc7 | ||
|
|
70df9efc4c | ||
|
|
d4a026dc5d | ||
|
|
5d02e35df7 | ||
|
|
22a3722aa0 | ||
|
|
258a5a173c | ||
|
|
2e6f31599a | ||
|
|
345aa57c80 | ||
|
|
0631e90ee0 | ||
|
|
aa10d84b75 | ||
|
|
bd904fcbda | ||
|
|
b11ed7c1ef | ||
|
|
f5be4686d5 | ||
|
|
ec85b27621 | ||
|
|
c2a58aeb70 | ||
|
|
c54da1924b | ||
|
|
05132c0dd6 | ||
|
|
bffe4e5d3e | ||
|
|
f64314b82f | ||
|
|
92e20827d8 | ||
|
|
22ab564dac | ||
|
|
d725d99fa5 | ||
|
|
f468cdb307 | ||
|
|
48c40a57c5 | ||
|
|
3de6cabcff | ||
|
|
a375cf6635 | ||
|
|
c0bcb61158 | ||
|
|
360b576411 | ||
|
|
dcc4962fdf | ||
|
|
2cfe4d289d | ||
|
|
723278a440 | ||
|
|
4bbfdadfde | ||
|
|
4677af8419 | ||
|
|
5ffc77e797 | ||
|
|
e4a94a81ef | ||
|
|
bbab6aa760 | ||
|
|
42d966bd52 | ||
|
|
90cefae4d8 | ||
|
|
5eda685ff5 | ||
|
|
8d79d67ca4 | ||
|
|
ecb3880846 | ||
|
|
6ed44af89a | ||
|
|
7a1609a398 | ||
|
|
894aa8054b | ||
|
|
4edba20d24 | ||
|
|
da69a464fb | ||
|
|
add2080fb2 | ||
|
|
31193538e6 | ||
|
|
26a9331e41 | ||
|
|
8c5c3fe09d | ||
|
|
42748a2c4b | ||
|
|
11cf2a195b | ||
|
|
4b3198dff4 | ||
|
|
abbff8d89a | ||
|
|
be58e0a8c0 | ||
|
|
69db72ffc5 | ||
|
|
b04536e55f | ||
|
|
be49936400 | ||
|
|
a81be13f82 | ||
|
|
c386353481 | ||
|
|
2631eb118c | ||
|
|
9d603a6388 | ||
|
|
65468736df | ||
|
|
33c5060e45 | ||
|
|
d90d9b7f19 | ||
|
|
455e36bb0e | ||
|
|
6abdeb34d6 | ||
|
|
80c72d0761 | ||
|
|
3fb47bcc47 | ||
|
|
e827095b94 | ||
|
|
d4801494a1 | ||
|
|
64711f9e66 | ||
|
|
7890844e47 | ||
|
|
0a053c62ab | ||
|
|
14040ba772 | ||
|
|
6658917591 | ||
|
|
c67475cbaa | ||
|
|
889cb9eea8 | ||
|
|
7601fae952 | ||
|
|
d69915040d | ||
|
|
e5f1f299f0 | ||
|
|
b1368b27fc | ||
|
|
f703b8d396 | ||
|
|
25628b7df4 | ||
|
|
782f9059ba | ||
|
|
6b4222888c | ||
|
|
1877cfa16b | ||
|
|
3700ba4726 | ||
|
|
ad6c25e0cc | ||
|
|
83332ceade | ||
|
|
c1cd100dae | ||
|
|
0c7fb4f1f9 | ||
|
|
df6d77fff7 | ||
|
|
eec5363a20 | ||
|
|
22887dfb0b | ||
|
|
b882a7c049 | ||
|
|
da80b76883 | ||
|
|
579991f458 | ||
|
|
bbf5735e9e | ||
|
|
0f4640ec57 | ||
|
|
2846f26e5b | ||
|
|
16ea661b6b | ||
|
|
321318819c |
@@ -1,5 +1,6 @@
|
||||
.DS_Store
|
||||
.idea
|
||||
.trash-cache
|
||||
bin
|
||||
state
|
||||
build
|
||||
|
||||
@@ -29,13 +29,11 @@ RUN apt-get update && \
|
||||
module-init-tools \
|
||||
openssh-client \
|
||||
pkg-config \
|
||||
python-pip \
|
||||
qemu \
|
||||
qemu-kvm \
|
||||
rsync \
|
||||
sudo \
|
||||
syslinux-common \
|
||||
tox \
|
||||
vim \
|
||||
wget \
|
||||
xorriso
|
||||
@@ -53,9 +51,9 @@ ARG DOCKER_VERSION=1.11.2
|
||||
ARG DOCKER_PATCH_VERSION=v${DOCKER_VERSION}-ros1
|
||||
ARG DOCKER_BUILD_VERSION=1.10.3
|
||||
ARG DOCKER_BUILD_PATCH_VERSION=v${DOCKER_BUILD_VERSION}-ros1
|
||||
ARG SELINUX_POLICY_URL=https://github.com/rancher/refpolicy/releases/download/v0.0.2/policy.29
|
||||
ARG SELINUX_POLICY_URL=https://github.com/rancher/refpolicy/releases/download/v0.0.3/policy.29
|
||||
|
||||
ARG KERNEL_URL_amd64=https://github.com/rancher/os-kernel/releases/download/Ubuntu-4.4.0-23.41-rancher2-2/linux-4.4.10-rancher-x86.tar.gz
|
||||
ARG KERNEL_URL_amd64=https://github.com/rancher/os-kernel/releases/download/Ubuntu-4.4.0-34.53-rancher1/linux-4.4.16-rancher-x86.tar.gz
|
||||
ARG KERNEL_URL_arm64=https://github.com/imikushin/os-kernel/releases/download/Estuary-4.4.0-arm64.8/linux-4.4.0-rancher-arm64.tar.gz
|
||||
|
||||
ARG DOCKER_URL_amd64=https://get.docker.com/builds/Linux/x86_64/docker-${DOCKER_VERSION}.tgz
|
||||
@@ -70,11 +68,11 @@ ARG OS_RELEASES_YML=https://releases.rancher.com/os
|
||||
|
||||
ARG OS_SERVICES_REPO=https://raw.githubusercontent.com/${OS_REPO}/os-services
|
||||
ARG IMAGE_NAME=${OS_REPO}/os
|
||||
ARG DFS_IMAGE=${OS_REPO}/docker:v${DOCKER_VERSION}-1
|
||||
ARG DFS_IMAGE=${OS_REPO}/docker:v${DOCKER_VERSION}-2
|
||||
|
||||
ARG OS_BASE_URL_amd64=https://github.com/rancher/os-base/releases/download/v2016.05-3/os-base_amd64.tar.xz
|
||||
ARG OS_BASE_URL_arm64=https://github.com/rancher/os-base/releases/download/v2016.05-3/os-base_arm64.tar.xz
|
||||
ARG OS_BASE_URL_arm=https://github.com/rancher/os-base/releases/download/v2016.05-3/os-base_arm.tar.xz
|
||||
ARG OS_BASE_URL_amd64=https://github.com/rancher/os-base/releases/download/v2016.05-5/os-base_amd64.tar.xz
|
||||
ARG OS_BASE_URL_arm64=https://github.com/rancher/os-base/releases/download/v2016.05-5/os-base_arm64.tar.xz
|
||||
ARG OS_BASE_URL_arm=https://github.com/rancher/os-base/releases/download/v2016.05-5/os-base_arm.tar.xz
|
||||
######################################################
|
||||
|
||||
# Set up environment and export all ARGS as ENV
|
||||
@@ -111,9 +109,9 @@ ENV BUILD_DOCKER_URL=BUILD_DOCKER_URL_${ARCH} \
|
||||
OS_RELEASES_YML=${OS_RELEASES_YML} \
|
||||
OS_REPO=${OS_REPO} \
|
||||
OS_SERVICES_REPO=${OS_SERVICES_REPO} \
|
||||
PATH=${GOPATH}/bin:/usr/local/go/bin:$PATH \
|
||||
REPO_VERSION=master \
|
||||
SELINUX_POLICY_URL=${SELINUX_POLICY_URL}
|
||||
ENV PATH=${GOPATH}/bin:/usr/local/go/bin:$PATH
|
||||
|
||||
RUN mkdir -p ${DOWNLOADS}
|
||||
|
||||
@@ -139,12 +137,11 @@ RUN ln -sf go-6 /usr/bin/go && \
|
||||
RUN curl -fL ${!BUILD_DOCKER_URL} > /usr/bin/docker && \
|
||||
chmod +x /usr/bin/docker
|
||||
|
||||
# Install Target Docker
|
||||
RUN curl -fL ${!DOCKER_URL} > ${DOWNLOADS}/docker.tgz
|
||||
|
||||
# Install Trash
|
||||
RUN go get github.com/rancher/trash
|
||||
|
||||
RUN go get gopkg.in/check.v1
|
||||
|
||||
# Install dapper
|
||||
RUN curl -sL https://releases.rancher.com/dapper/latest/dapper-`uname -s`-`uname -m | sed 's/arm.*/arm/'` > /usr/bin/dapper && \
|
||||
chmod +x /usr/bin/dapper
|
||||
|
||||
55
README.md
55
README.md
@@ -14,29 +14,38 @@ it would really be bad if somebody did `docker rm -f $(docker ps -qa)` and delet
|
||||
|
||||
## Latest Release
|
||||
|
||||
**v0.4.5 - Docker 1.10.3- Linux 4.2.8**
|
||||
**v0.5.0 - Docker 1.11.2 - Linux 4.4.10**
|
||||
|
||||
### ISO
|
||||
|
||||
https://releases.rancher.com/os/latest/rancheros.iso
|
||||
https://releases.rancher.com/os/v0.4.5/rancheros.iso
|
||||
https://releases.rancher.com/os/v0.5.0/rancheros.iso
|
||||
|
||||
**Note**: you must login using `rancher` for username and password.
|
||||
|
||||
### Additional Downloads
|
||||
|
||||
#### Latest
|
||||
|
||||
* https://releases.rancher.com/os/latest/initrd
|
||||
* https://releases.rancher.com/os/latest/iso-checksums.txt
|
||||
* https://releases.rancher.com/os/latest/rancheros-v0.4.5.tar.gz
|
||||
* https://releases.rancher.com/os/latest/rancheros-openstack.img
|
||||
* https://releases.rancher.com/os/latest/rancheros-raspberry-pi.zip
|
||||
* https://releases.rancher.com/os/latest/rancheros-v0.5.0.tar.gz
|
||||
* https://releases.rancher.com/os/latest/rancheros.iso
|
||||
* https://releases.rancher.com/os/latest/rootfs_arm.tar.gz
|
||||
* https://releases.rancher.com/os/latest/vmlinuz
|
||||
|
||||
#### v0.5.0
|
||||
|
||||
* https://releases.rancher.com/os/v0.4.5/initrd
|
||||
* https://releases.rancher.com/os/v0.4.5/iso-checksums.txt
|
||||
* https://releases.rancher.com/os/v0.4.5/rancheros-v0.4.5.tar.gz
|
||||
* https://releases.rancher.com/os/v0.4.5/rancheros.iso
|
||||
* https://releases.rancher.com/os/v0.4.5/vmlinuz
|
||||
* https://releases.rancher.com/os/v0.5.0/initrd
|
||||
* https://releases.rancher.com/os/v0.5.0/iso-checksums.txt
|
||||
* https://releases.rancher.com/os/v0.5.0/rancheros-openstack.img
|
||||
* https://releases.rancher.com/os/v0.5.0/rancheros-raspberry-pi.zip
|
||||
* https://releases.rancher.com/os/v0.5.0/rancheros-v0.5.0.tar.gz
|
||||
* https://releases.rancher.com/os/v0.5.0/rancheros.iso
|
||||
* https://releases.rancher.com/os/v0.5.0/rootfs_arm.tar.gz
|
||||
* https://releases.rancher.com/os/v0.5.0/vmlinuz
|
||||
|
||||
**Note**: you can use `http` instead of `https` in the above URLs, e.g. for iPXE.
|
||||
|
||||
@@ -48,28 +57,26 @@ SSH keys are added to the **`rancher`** user, so you must log in using the **ran
|
||||
|
||||
Region | Type | AMI |
|
||||
-------|------|------
|
||||
ap-northeast-1 | HVM | [ami-918761f0](https://console.aws.amazon.com/ec2/home?region=ap-northeast-1#launchInstanceWizard:ami=ami-918761f0)
|
||||
ap-northeast-2 | HVM | [ami-7874bc16](https://console.aws.amazon.com/ec2/home?region=ap-northeast-2#launchInstanceWizard:ami=ami-7874bc16)
|
||||
ap-southeast-1 | HVM | [ami-c5e533a6](https://console.aws.amazon.com/ec2/home?region=ap-southeast-1#launchInstanceWizard:ami=ami-c5e533a6)
|
||||
ap-southeast-2 | HVM | [ami-4c7a552f](https://console.aws.amazon.com/ec2/home?region=ap-southeast-2#launchInstanceWizard:ami=ami-4c7a552f)
|
||||
eu-central-1 | HVM | [ami-8740ade8](https://console.aws.amazon.com/ec2/home?region=eu-central-1#launchInstanceWizard:ami=ami-8740ade8)
|
||||
eu-west-1 | HVM | [ami-6343d610](https://console.aws.amazon.com/ec2/home?region=eu-west-1#launchInstanceWizard:ami=ami-6343d610)
|
||||
sa-east-1 | HVM | [ami-0b991167](https://console.aws.amazon.com/ec2/home?region=sa-east-1#launchInstanceWizard:ami=ami-0b991167)
|
||||
us-east-1 | HVM | [ami-812ec0ec](https://console.aws.amazon.com/ec2/home?region=us-east-1#launchInstanceWizard:ami=ami-812ec0ec)
|
||||
us-west-1 | HVM | [ami-cc255dac](https://console.aws.amazon.com/ec2/home?region=us-west-1#launchInstanceWizard:ami=ami-cc255dac)
|
||||
us-west-2 | HVM | [ami-58fe0238](https://console.aws.amazon.com/ec2/home?region=us-west-2#launchInstanceWizard:ami=ami-58fe0238)
|
||||
ap-northeast-1 | HVM | [ami-a452a2c5](https://console.aws.amazon.com/ec2/home?region=ap-northeast-1#launchInstanceWizard:ami=ami-a452a2c5)
|
||||
ap-northeast-2 | HVM | [ami-928e44fc](https://console.aws.amazon.com/ec2/home?region=ap-northeast-2#launchInstanceWizard:ami=ami-928e44fc)
|
||||
ap-southeast-1 | HVM | [ami-529f4231](https://console.aws.amazon.com/ec2/home?region=ap-southeast-1#launchInstanceWizard:ami=ami-529f4231)
|
||||
ap-southeast-2 | HVM | [ami-fc577c9f](https://console.aws.amazon.com/ec2/home?region=ap-southeast-2#launchInstanceWizard:ami=ami-fc577c9f)
|
||||
eu-central-1 | HVM | [ami-4a7f9425](https://console.aws.amazon.com/ec2/home?region=eu-central-1#launchInstanceWizard:ami=ami-4a7f9425)
|
||||
eu-west-1 | HVM | [ami-997b1eea](https://console.aws.amazon.com/ec2/home?region=eu-west-1#launchInstanceWizard:ami=ami-997b1eea)
|
||||
sa-east-1 | HVM | [ami-98198cf4](https://console.aws.amazon.com/ec2/home?region=sa-east-1#launchInstanceWizard:ami=ami-98198cf4)
|
||||
us-east-1 | HVM | [ami-1071ca07](https://console.aws.amazon.com/ec2/home?region=us-east-1#launchInstanceWizard:ami=ami-1071ca07)
|
||||
us-west-1 | HVM | [ami-a57730c5](https://console.aws.amazon.com/ec2/home?region=us-west-1#launchInstanceWizard:ami=ami-a57730c5)
|
||||
us-west-2 | HVM | [ami-f0f03190](https://console.aws.amazon.com/ec2/home?region=us-west-2#launchInstanceWizard:ami=ami-f0f03190)
|
||||
ap-south-1 | HVM | [ami-de97fdb1](https://console.aws.amazon.com/ec2/home?region=ap-south-1#launchInstanceWizard:ami=ami-de97fdb1)
|
||||
|
||||
### Google Compute Engine (Experimental)
|
||||
### Google Compute Engine
|
||||
|
||||
We are providing a disk image that users can download and import for use in Google Compute Engine. The image can be obtained from the release artifacts for RancherOS v0.3.0 or later.
|
||||
We are providing a disk image that users can download and import for use in Google Compute Engine. The image can be obtained from the release artifacts for RancherOS.
|
||||
|
||||
[Download Image](https://github.com/rancher/os/releases/download/v0.4.5/rancheros-v0.4.5.tar.gz)
|
||||
[Download Image](https://github.com/rancher/os/releases/download/v0.5.0/rancheros-v0.5.0.tar.gz)
|
||||
|
||||
Please follow the directions at our [docs to launch in GCE](http://docs.rancher.com/os/running-rancheros/cloud/gce/).
|
||||
|
||||
#### Known issues/ToDos
|
||||
* Add GCE daemon support. (Manages users)
|
||||
|
||||
## Documentation for RancherOS
|
||||
|
||||
Please refer to our [RancherOS Documentation](http://docs.rancher.com/os/) website to read all about RancherOS. It has detailed information on how RancherOS works, getting-started and other details.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package cloudinit
|
||||
package cloudinitexecute
|
||||
|
||||
import (
|
||||
"os"
|
||||
174
cmd/cloudinitexecute/cloudinitexecute.go
Normal file
174
cmd/cloudinitexecute/cloudinitexecute.go
Normal file
@@ -0,0 +1,174 @@
|
||||
package cloudinitexecute
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/coreos/coreos-cloudinit/system"
|
||||
rancherConfig "github.com/rancher/os/config"
|
||||
"github.com/rancher/os/docker"
|
||||
"github.com/rancher/os/util"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
const (
|
||||
resizeStamp = "/var/lib/rancher/resizefs.done"
|
||||
sshKeyName = "rancheros-cloud-config"
|
||||
)
|
||||
|
||||
var (
|
||||
console bool
|
||||
preConsole bool
|
||||
flags *flag.FlagSet
|
||||
)
|
||||
|
||||
func init() {
|
||||
flags = flag.NewFlagSet(os.Args[0], flag.ContinueOnError)
|
||||
flags.BoolVar(&console, "console", false, "apply console configuration")
|
||||
flags.BoolVar(&preConsole, "pre-console", false, "apply pre-console configuration")
|
||||
}
|
||||
|
||||
func Main() {
|
||||
flags.Parse(os.Args[1:])
|
||||
|
||||
log.Infof("Running cloud-init-execute: pre-console=%v, console=%v", preConsole, console)
|
||||
|
||||
cfg := rancherConfig.LoadConfig()
|
||||
|
||||
if !console && !preConsole {
|
||||
console = true
|
||||
preConsole = true
|
||||
}
|
||||
|
||||
if console {
|
||||
ApplyConsole(cfg)
|
||||
}
|
||||
if preConsole {
|
||||
applyPreConsole(cfg)
|
||||
}
|
||||
}
|
||||
|
||||
func ApplyConsole(cfg *rancherConfig.CloudConfig) {
|
||||
if len(cfg.SSHAuthorizedKeys) > 0 {
|
||||
authorizeSSHKeys("rancher", cfg.SSHAuthorizedKeys, sshKeyName)
|
||||
authorizeSSHKeys("docker", cfg.SSHAuthorizedKeys, sshKeyName)
|
||||
}
|
||||
|
||||
WriteFiles(cfg, "console")
|
||||
|
||||
for _, mount := range cfg.Mounts {
|
||||
if len(mount) != 4 {
|
||||
log.Errorf("Unable to mount %s: must specify exactly four arguments", mount[1])
|
||||
}
|
||||
device := util.ResolveDevice(mount[0])
|
||||
|
||||
if mount[2] == "swap" {
|
||||
cmd := exec.Command("swapon", device)
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
log.Errorf("Unable to swapon %s: %v", device, err)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
cmdArgs := []string{device, mount[1]}
|
||||
if mount[2] != "" {
|
||||
cmdArgs = append(cmdArgs, "-t", mount[2])
|
||||
}
|
||||
if mount[3] != "" {
|
||||
cmdArgs = append(cmdArgs, "-o", mount[3])
|
||||
}
|
||||
cmd := exec.Command("mount", cmdArgs...)
|
||||
if err := cmd.Run(); err != nil {
|
||||
log.Errorf("Failed to mount %s: %v", mount[1], err)
|
||||
}
|
||||
}
|
||||
|
||||
for _, runcmd := range cfg.Runcmd {
|
||||
if len(runcmd) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
cmd := exec.Command(runcmd[0], runcmd[1:]...)
|
||||
cmd.Stdin = os.Stdin
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
if err := cmd.Run(); err != nil {
|
||||
log.Errorf("Failed to run %s: %v", runcmd, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func WriteFiles(cfg *rancherConfig.CloudConfig, container string) {
|
||||
for _, file := range cfg.WriteFiles {
|
||||
fileContainer := file.Container
|
||||
if fileContainer == "" {
|
||||
fileContainer = "console"
|
||||
}
|
||||
if fileContainer != container {
|
||||
continue
|
||||
}
|
||||
|
||||
f := system.File{
|
||||
File: file.File,
|
||||
}
|
||||
fullPath, err := system.WriteFile(&f, "/")
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{"err": err, "path": fullPath}).Error("Error writing file")
|
||||
continue
|
||||
}
|
||||
log.Printf("Wrote file %s to filesystem", fullPath)
|
||||
}
|
||||
}
|
||||
|
||||
func applyPreConsole(cfg *rancherConfig.CloudConfig) {
|
||||
if _, err := os.Stat(resizeStamp); os.IsNotExist(err) && cfg.Rancher.ResizeDevice != "" {
|
||||
if err := resizeDevice(cfg); err == nil {
|
||||
os.Create(resizeStamp)
|
||||
} else {
|
||||
log.Errorf("Failed to resize %s: %s", cfg.Rancher.ResizeDevice, err)
|
||||
}
|
||||
}
|
||||
|
||||
for k, v := range cfg.Rancher.Sysctl {
|
||||
elems := []string{"/proc", "sys"}
|
||||
elems = append(elems, strings.Split(k, ".")...)
|
||||
path := path.Join(elems...)
|
||||
if err := ioutil.WriteFile(path, []byte(v), 0644); err != nil {
|
||||
log.Errorf("Failed to set sysctl key %s: %s", k, err)
|
||||
}
|
||||
}
|
||||
|
||||
client, err := docker.NewSystemClient()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
for _, restart := range cfg.Rancher.RestartServices {
|
||||
if err = client.ContainerRestart(context.Background(), restart, 10); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func resizeDevice(cfg *rancherConfig.CloudConfig) error {
|
||||
cmd := exec.Command("growpart", cfg.Rancher.ResizeDevice, "1")
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cmd = exec.Command("resize2fs", fmt.Sprintf("%s1", cfg.Rancher.ResizeDevice))
|
||||
err = cmd.Run()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -13,22 +13,17 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package cloudinit
|
||||
package cloudinitsave
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
yaml "github.com/cloudfoundry-incubator/candiedyaml"
|
||||
"github.com/docker/docker/pkg/mount"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/coreos/coreos-cloudinit/config"
|
||||
@@ -41,9 +36,8 @@ import (
|
||||
"github.com/coreos/coreos-cloudinit/datasource/proc_cmdline"
|
||||
"github.com/coreos/coreos-cloudinit/datasource/url"
|
||||
"github.com/coreos/coreos-cloudinit/pkg"
|
||||
"github.com/coreos/coreos-cloudinit/system"
|
||||
"github.com/rancher/netconf"
|
||||
"github.com/rancher/os/cmd/cloudinit/gce"
|
||||
"github.com/rancher/os/cmd/cloudinitsave/gce"
|
||||
rancherConfig "github.com/rancher/os/config"
|
||||
"github.com/rancher/os/util"
|
||||
)
|
||||
@@ -52,13 +46,9 @@ const (
|
||||
datasourceInterval = 100 * time.Millisecond
|
||||
datasourceMaxInterval = 30 * time.Second
|
||||
datasourceTimeout = 5 * time.Minute
|
||||
sshKeyName = "rancheros-cloud-config"
|
||||
resizeStamp = "/var/lib/rancher/resizefs.done"
|
||||
)
|
||||
|
||||
var (
|
||||
save bool
|
||||
execute bool
|
||||
network bool
|
||||
flags *flag.FlagSet
|
||||
)
|
||||
@@ -66,15 +56,20 @@ var (
|
||||
func init() {
|
||||
flags = flag.NewFlagSet(os.Args[0], flag.ContinueOnError)
|
||||
flags.BoolVar(&network, "network", true, "use network based datasources")
|
||||
flags.BoolVar(&save, "save", false, "save cloud config and exit")
|
||||
flags.BoolVar(&execute, "execute", false, "execute saved cloud config")
|
||||
}
|
||||
|
||||
func Main() {
|
||||
flags.Parse(os.Args[1:])
|
||||
|
||||
log.Infof("Running cloud-init-save: network=%v", network)
|
||||
|
||||
if err := saveCloudConfig(); err != nil {
|
||||
log.Errorf("Failed to save cloud-config: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func saveFiles(cloudConfigBytes, scriptBytes []byte, metadata datasource.Metadata) error {
|
||||
os.MkdirAll(rancherConfig.CloudConfigDir, os.ModeDir|0600)
|
||||
os.Remove(rancherConfig.CloudConfigScriptFile)
|
||||
os.Remove(rancherConfig.CloudConfigBootFile)
|
||||
os.Remove(rancherConfig.MetaDataFile)
|
||||
|
||||
if len(scriptBytes) > 0 {
|
||||
log.Infof("Writing to %s", rancherConfig.CloudConfigScriptFile)
|
||||
@@ -84,10 +79,12 @@ func saveFiles(cloudConfigBytes, scriptBytes []byte, metadata datasource.Metadat
|
||||
}
|
||||
}
|
||||
|
||||
if err := util.WriteFileAtomic(rancherConfig.CloudConfigBootFile, cloudConfigBytes, 400); err != nil {
|
||||
return err
|
||||
if len(cloudConfigBytes) > 0 {
|
||||
if err := util.WriteFileAtomic(rancherConfig.CloudConfigBootFile, cloudConfigBytes, 400); err != nil {
|
||||
return err
|
||||
}
|
||||
log.Infof("Written to %s:\n%s", rancherConfig.CloudConfigBootFile, string(cloudConfigBytes))
|
||||
}
|
||||
log.Infof("Written to %s:\n%s", rancherConfig.CloudConfigBootFile, string(cloudConfigBytes))
|
||||
|
||||
metaDataBytes, err := yaml.Marshal(metadata)
|
||||
if err != nil {
|
||||
@@ -171,104 +168,6 @@ func fetchUserData() ([]byte, datasource.Metadata, error) {
|
||||
return userDataBytes, metadata, nil
|
||||
}
|
||||
|
||||
func resizeDevice(cfg *rancherConfig.CloudConfig) error {
|
||||
cmd := exec.Command("growpart", cfg.Rancher.ResizeDevice, "1")
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cmd = exec.Command("partprobe")
|
||||
err = cmd.Run()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cmd = exec.Command("resize2fs", fmt.Sprintf("%s1", cfg.Rancher.ResizeDevice))
|
||||
err = cmd.Run()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func executeCloudConfig() error {
|
||||
cc := rancherConfig.LoadConfig()
|
||||
|
||||
if len(cc.SSHAuthorizedKeys) > 0 {
|
||||
authorizeSSHKeys("rancher", cc.SSHAuthorizedKeys, sshKeyName)
|
||||
authorizeSSHKeys("docker", cc.SSHAuthorizedKeys, sshKeyName)
|
||||
}
|
||||
|
||||
for _, file := range cc.WriteFiles {
|
||||
f := system.File{File: file}
|
||||
fullPath, err := system.WriteFile(&f, "/")
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{"err": err, "path": fullPath}).Error("Error writing file")
|
||||
continue
|
||||
}
|
||||
log.Printf("Wrote file %s to filesystem", fullPath)
|
||||
}
|
||||
|
||||
if _, err := os.Stat(resizeStamp); os.IsNotExist(err) && cc.Rancher.ResizeDevice != "" {
|
||||
if err := resizeDevice(cc); err == nil {
|
||||
os.Create(resizeStamp)
|
||||
} else {
|
||||
log.Errorf("Failed to resize %s: %s", cc.Rancher.ResizeDevice, err)
|
||||
}
|
||||
}
|
||||
|
||||
for _, configMount := range cc.Mounts {
|
||||
if len(configMount) != 4 {
|
||||
log.Errorf("Unable to mount %s: must specify exactly four arguments", configMount[1])
|
||||
}
|
||||
device := util.ResolveDevice(configMount[0])
|
||||
if configMount[2] == "swap" {
|
||||
cmd := exec.Command("swapon", device)
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
log.Errorf("Unable to swapon %s: %v", device, err)
|
||||
}
|
||||
continue
|
||||
}
|
||||
if err := mount.Mount(device, configMount[1], configMount[2], configMount[3]); err != nil {
|
||||
log.Errorf("Unable to mount %s: %v", configMount[1], err)
|
||||
}
|
||||
}
|
||||
|
||||
for k, v := range cc.Rancher.Sysctl {
|
||||
elems := []string{"/proc", "sys"}
|
||||
elems = append(elems, strings.Split(k, ".")...)
|
||||
path := path.Join(elems...)
|
||||
if err := ioutil.WriteFile(path, []byte(v), 0644); err != nil {
|
||||
log.Errorf("Failed to set sysctl key %s: %s", k, err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Main() {
|
||||
flags.Parse(os.Args[1:])
|
||||
|
||||
log.Infof("Running cloud-init: save=%v, execute=%v", save, execute)
|
||||
|
||||
if save {
|
||||
err := saveCloudConfig()
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{"err": err}).Error("Failed to save cloud-config")
|
||||
}
|
||||
}
|
||||
|
||||
if execute {
|
||||
err := executeCloudConfig()
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{"err": err}).Error("Failed to execute cloud-config")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// getDatasources creates a slice of possible Datasources for cloudinit based
|
||||
// on the different source command-line flags.
|
||||
func getDatasources(cfg *rancherConfig.CloudConfig) []datasource.Datasource {
|
||||
@@ -1,4 +1,4 @@
|
||||
package cloudinit
|
||||
package cloudinitsave
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
309
cmd/console/console.go
Normal file
309
cmd/console/console.go
Normal file
@@ -0,0 +1,309 @@
|
||||
package console
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"regexp"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/rancher/os/cmd/cloudinitexecute"
|
||||
"github.com/rancher/os/config"
|
||||
"github.com/rancher/os/util"
|
||||
)
|
||||
|
||||
const (
|
||||
consoleDone = "/run/console-done"
|
||||
dockerHome = "/home/docker"
|
||||
gettyCmd = "/sbin/agetty"
|
||||
rancherHome = "/home/rancher"
|
||||
startScript = "/opt/rancher/bin/start.sh"
|
||||
)
|
||||
|
||||
type symlink struct {
|
||||
oldname, newname string
|
||||
}
|
||||
|
||||
func Main() {
|
||||
cfg := config.LoadConfig()
|
||||
|
||||
if _, err := os.Stat(rancherHome); os.IsNotExist(err) {
|
||||
if err := os.MkdirAll(rancherHome, 0755); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
if err := os.Chown(rancherHome, 1100, 1100); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
if _, err := os.Stat(dockerHome); os.IsNotExist(err) {
|
||||
if err := os.MkdirAll(dockerHome, 0755); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
if err := os.Chown(dockerHome, 1101, 1101); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
password := config.GetCmdline("rancher.password")
|
||||
cmd := exec.Command("chpasswd")
|
||||
cmd.Stdin = strings.NewReader(fmt.Sprint("rancher:", password))
|
||||
if err := cmd.Run(); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
cmd = exec.Command("bash", "-c", `sed -E -i 's/(rancher:.*:).*(:.*:.*:.*:.*:.*:.*)$/\1\2/' /etc/shadow`)
|
||||
if err := cmd.Run(); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
if err := setupSSH(cfg); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
if err := writeRespawn(); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
if err := modifySshdConfig(); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
if err := writeOsRelease(); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
for _, link := range []symlink{
|
||||
{"/var/lib/rancher/engine/docker", "/usr/bin/docker"},
|
||||
{"/var/lib/rancher/engine/docker-containerd", "/usr/bin/docker-containerd"},
|
||||
{"/var/lib/rancher/engine/docker-containerd-ctr", "/usr/bin/docker-containerd-ctr"},
|
||||
{"/var/lib/rancher/engine/docker-containerd-shim", "/usr/bin/docker-containerd-shim"},
|
||||
{"/var/lib/rancher/engine/dockerd", "/usr/bin/dockerd"},
|
||||
{"/var/lib/rancher/engine/docker-proxy", "/usr/bin/docker-proxy"},
|
||||
{"/var/lib/rancher/engine/docker-runc", "/usr/bin/docker-runc"},
|
||||
} {
|
||||
syscall.Unlink(link.newname)
|
||||
if err := os.Symlink(link.oldname, link.newname); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
cmd = exec.Command("bash", "-c", `echo 'RancherOS \n \l' > /etc/issue`)
|
||||
if err := cmd.Run(); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
cmd = exec.Command("bash", "-c", `echo $(/sbin/ifconfig | grep -B1 "inet addr" |awk '{ if ( $1 == "inet" ) { print $2 } else if ( $2 == "Link" ) { printf "%s:" ,$1 } }' |awk -F: '{ print $1 ": " $3}') >> /etc/issue`)
|
||||
if err := cmd.Run(); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
cloudinitexecute.ApplyConsole(cfg)
|
||||
|
||||
if err := runScript(config.CloudConfigScriptFile); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
if err := runScript(startScript); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
if err := runScript("/etc/rc.local"); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
os.Setenv("TERM", "linux")
|
||||
|
||||
respawnBinPath, err := exec.LookPath("respawn")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if err := ioutil.WriteFile(consoleDone, []byte(cfg.Rancher.Console), 0644); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
log.Fatal(syscall.Exec(respawnBinPath, []string{"respawn", "-f", "/etc/respawn.conf"}, os.Environ()))
|
||||
}
|
||||
|
||||
func generateRespawnConf(cmdline string) string {
|
||||
var respawnConf bytes.Buffer
|
||||
|
||||
for i := 1; i < 7; i++ {
|
||||
tty := fmt.Sprintf("tty%d", i)
|
||||
|
||||
respawnConf.WriteString(gettyCmd)
|
||||
if strings.Contains(cmdline, fmt.Sprintf("rancher.autologin=%s", tty)) {
|
||||
respawnConf.WriteString(" --autologin rancher")
|
||||
}
|
||||
respawnConf.WriteString(fmt.Sprintf(" 115200 %s\n", tty))
|
||||
}
|
||||
|
||||
for _, tty := range []string{"ttyS0", "ttyS1", "ttyS2", "ttyS3", "ttyAMA0"} {
|
||||
if !strings.Contains(cmdline, fmt.Sprintf("console=%s", tty)) {
|
||||
continue
|
||||
}
|
||||
|
||||
respawnConf.WriteString(gettyCmd)
|
||||
if strings.Contains(cmdline, fmt.Sprintf("rancher.autologin=%s", tty)) {
|
||||
respawnConf.WriteString(" --autologin rancher")
|
||||
}
|
||||
respawnConf.WriteString(fmt.Sprintf(" 115200 %s\n", tty))
|
||||
}
|
||||
|
||||
respawnConf.WriteString("/usr/sbin/sshd -D")
|
||||
|
||||
return respawnConf.String()
|
||||
}
|
||||
|
||||
func writeRespawn() error {
|
||||
cmdline, err := ioutil.ReadFile("/proc/cmdline")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
respawn := generateRespawnConf(string(cmdline))
|
||||
|
||||
files, err := ioutil.ReadDir("/etc/respawn.conf.d")
|
||||
if err == nil {
|
||||
for _, f := range files {
|
||||
p := path.Join("/etc/respawn.conf.d", f.Name())
|
||||
content, err := ioutil.ReadFile(p)
|
||||
if err != nil {
|
||||
log.Error("Failed to read %s: %v", p, err)
|
||||
continue
|
||||
}
|
||||
respawn += fmt.Sprintf("\n%s", string(content))
|
||||
}
|
||||
} else if !os.IsNotExist(err) {
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
return ioutil.WriteFile("/etc/respawn.conf", []byte(respawn), 0644)
|
||||
}
|
||||
|
||||
func modifySshdConfig() error {
|
||||
sshdConfig, err := ioutil.ReadFile("/etc/ssh/sshd_config")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sshdConfigString := string(sshdConfig)
|
||||
|
||||
for _, item := range []string{
|
||||
"UseDNS no",
|
||||
"PermitRootLogin no",
|
||||
"ServerKeyBits 2048",
|
||||
"AllowGroups docker",
|
||||
} {
|
||||
match, err := regexp.Match("^"+item, sshdConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !match {
|
||||
sshdConfigString += fmt.Sprintf("%s\n", item)
|
||||
}
|
||||
}
|
||||
|
||||
return ioutil.WriteFile("/etc/ssh/sshd_config", []byte(sshdConfigString), 0644)
|
||||
}
|
||||
|
||||
func writeOsRelease() error {
|
||||
idLike := "busybox"
|
||||
if osRelease, err := ioutil.ReadFile("/etc/os-release"); err == nil {
|
||||
for _, line := range strings.Split(string(osRelease), "\n") {
|
||||
if strings.HasPrefix(line, "ID_LIKE") {
|
||||
split := strings.Split(line, "ID_LIKE")
|
||||
if len(split) > 1 {
|
||||
idLike = split[1]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ioutil.WriteFile("/etc/os-release", []byte(fmt.Sprintf(`
|
||||
NAME="RancherOS"
|
||||
VERSION=%s
|
||||
ID=rancheros
|
||||
ID_LIKE=%s
|
||||
VERSION_ID=%s
|
||||
PRETTY_NAME="RancherOS %s"
|
||||
HOME_URL=
|
||||
SUPPORT_URL=
|
||||
BUG_REPORT_URL=
|
||||
BUILD_ID=
|
||||
`, config.VERSION, idLike, config.VERSION, config.VERSION)), 0644)
|
||||
}
|
||||
|
||||
func setupSSH(cfg *config.CloudConfig) error {
|
||||
for _, keyType := range []string{"rsa", "dsa", "ecdsa", "ed25519"} {
|
||||
outputFile := fmt.Sprintf("/etc/ssh/ssh_host_%s_key", keyType)
|
||||
outputFilePub := fmt.Sprintf("/etc/ssh/ssh_host_%s_key.pub", keyType)
|
||||
|
||||
if _, err := os.Stat(outputFile); err == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
saved, savedExists := cfg.Rancher.Ssh.Keys[keyType]
|
||||
pub, pubExists := cfg.Rancher.Ssh.Keys[keyType+"-pub"]
|
||||
|
||||
if savedExists && pubExists {
|
||||
// TODO check permissions
|
||||
if err := util.WriteFileAtomic(outputFile, []byte(saved), 0600); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := util.WriteFileAtomic(outputFilePub, []byte(pub), 0600); err != nil {
|
||||
return err
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
cmd := exec.Command("bash", "-c", fmt.Sprintf("ssh-keygen -f %s -N '' -t %s", outputFile, keyType))
|
||||
if err := cmd.Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
savedBytes, err := ioutil.ReadFile(outputFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pubBytes, err := ioutil.ReadFile(outputFilePub)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
config.Set(fmt.Sprintf("rancher.ssh.keys.%s", keyType), string(savedBytes))
|
||||
config.Set(fmt.Sprintf("rancher.ssh.keys.%s-pub", keyType), string(pubBytes))
|
||||
}
|
||||
|
||||
return os.MkdirAll("/var/run/sshd", 0644)
|
||||
}
|
||||
|
||||
func runScript(path string) error {
|
||||
if !util.ExistsAndExecutable(path) {
|
||||
return nil
|
||||
}
|
||||
|
||||
script, err := os.Open(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
magic := make([]byte, 2)
|
||||
if _, err = script.Read(magic); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cmd := exec.Command("/bin/sh", path)
|
||||
if string(magic) == "#!" {
|
||||
cmd = exec.Command(path)
|
||||
}
|
||||
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
|
||||
return cmd.Run()
|
||||
}
|
||||
@@ -33,7 +33,7 @@ func Main() {
|
||||
},
|
||||
{
|
||||
Name: "console",
|
||||
Usage: "console container commands",
|
||||
Usage: "manage which console container is used",
|
||||
HideHelp: true,
|
||||
Subcommands: consoleSubcommands(),
|
||||
},
|
||||
@@ -45,6 +45,18 @@ func Main() {
|
||||
SkipFlagParsing: true,
|
||||
Action: devAction,
|
||||
},
|
||||
{
|
||||
Name: "engine",
|
||||
Usage: "manage which Docker engine is used",
|
||||
HideHelp: true,
|
||||
Subcommands: engineSubcommands(),
|
||||
},
|
||||
{
|
||||
Name: "entrypoint",
|
||||
HideHelp: true,
|
||||
SkipFlagParsing: true,
|
||||
Action: entrypointAction,
|
||||
},
|
||||
{
|
||||
Name: "env",
|
||||
ShortName: "e",
|
||||
|
||||
@@ -30,6 +30,10 @@ func consoleSubcommands() []cli.Command {
|
||||
Name: "force, f",
|
||||
Usage: "do not prompt for input",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "no-pull",
|
||||
Usage: "don't pull console image",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -67,7 +71,7 @@ func consoleSwitch(c *cli.Context) error {
|
||||
}
|
||||
}
|
||||
|
||||
if newConsole != "default" {
|
||||
if !c.Bool("no-pull") && newConsole != "default" {
|
||||
if err := compose.StageServices(cfg, newConsole); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
139
cmd/control/engine.go
Normal file
139
cmd/control/engine.go
Normal file
@@ -0,0 +1,139 @@
|
||||
package control
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/codegangsta/cli"
|
||||
composeConfig "github.com/docker/libcompose/config"
|
||||
"github.com/docker/libcompose/project/options"
|
||||
"github.com/rancher/os/compose"
|
||||
"github.com/rancher/os/config"
|
||||
"github.com/rancher/os/util/network"
|
||||
)
|
||||
|
||||
const (
|
||||
dockerDone = "/run/docker-done"
|
||||
)
|
||||
|
||||
func engineSubcommands() []cli.Command {
|
||||
return []cli.Command{
|
||||
{
|
||||
Name: "switch",
|
||||
Usage: "switch Docker engine without a reboot",
|
||||
Action: engineSwitch,
|
||||
Flags: []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "force, f",
|
||||
Usage: "do not prompt for input",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "no-pull",
|
||||
Usage: "don't pull console image",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "enable",
|
||||
Usage: "set Docker engine to be switched on next reboot",
|
||||
Action: engineEnable,
|
||||
},
|
||||
{
|
||||
Name: "list",
|
||||
Usage: "list available Docker engines",
|
||||
Action: engineList,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func engineSwitch(c *cli.Context) error {
|
||||
if len(c.Args()) != 1 {
|
||||
log.Fatal("Must specify exactly one Docker engine to switch to")
|
||||
}
|
||||
newEngine := c.Args()[0]
|
||||
|
||||
cfg := config.LoadConfig()
|
||||
|
||||
project, err := compose.GetProject(cfg, true, false)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if err = project.Stop(context.Background(), 10, "docker"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
project.ServiceConfigs.Add("docker", &composeConfig.ServiceConfig{})
|
||||
|
||||
if err = compose.LoadService(project, cfg, true, newEngine); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if err = project.Up(context.Background(), options.Up{}, "docker"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if err := config.Set("rancher.docker.engine", newEngine); err != nil {
|
||||
log.Errorf("Failed to update rancher.docker.engine: %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func engineEnable(c *cli.Context) error {
|
||||
if len(c.Args()) != 1 {
|
||||
log.Fatal("Must specify exactly one Docker engine to enable")
|
||||
}
|
||||
newEngine := c.Args()[0]
|
||||
|
||||
cfg := config.LoadConfig()
|
||||
|
||||
if err := compose.StageServices(cfg, newEngine); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := config.Set("rancher.docker.engine", newEngine); err != nil {
|
||||
log.Errorf("Failed to update 'rancher.docker.engine': %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func engineList(c *cli.Context) error {
|
||||
cfg := config.LoadConfig()
|
||||
|
||||
engines, err := network.GetEngines(cfg.Rancher.Repositories.ToArray())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sort.Strings(engines)
|
||||
|
||||
currentEngine := currentEngine()
|
||||
|
||||
for _, engine := range engines {
|
||||
if engine == currentEngine {
|
||||
fmt.Printf("current %s\n", engine)
|
||||
} else if engine == cfg.Rancher.Docker.Engine {
|
||||
fmt.Printf("enabled %s\n", engine)
|
||||
} else {
|
||||
fmt.Printf("disabled %s\n", engine)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func currentEngine() (engine string) {
|
||||
engineBytes, err := ioutil.ReadFile(dockerDone)
|
||||
if err == nil {
|
||||
engine = strings.TrimSpace(string(engineBytes))
|
||||
} else {
|
||||
log.Warnf("Failed to detect current Docker engine: %v", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
76
cmd/control/entrypoint.go
Normal file
76
cmd/control/entrypoint.go
Normal file
@@ -0,0 +1,76 @@
|
||||
package control
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"syscall"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/codegangsta/cli"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/rancher/os/cmd/cloudinitexecute"
|
||||
"github.com/rancher/os/config"
|
||||
"github.com/rancher/os/docker"
|
||||
"github.com/rancher/os/util"
|
||||
)
|
||||
|
||||
const (
|
||||
ca = "/etc/ssl/certs/ca-certificates.crt"
|
||||
caBase = "/etc/ssl/certs/ca-certificates.crt.rancher"
|
||||
)
|
||||
|
||||
func entrypointAction(c *cli.Context) error {
|
||||
if _, err := os.Stat("/host/dev"); err == nil {
|
||||
cmd := exec.Command("mount", "--rbind", "/host/dev", "/dev")
|
||||
if err := cmd.Run(); err != nil {
|
||||
log.Errorf("Failed to mount /dev: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := util.FileCopy(caBase, ca); err != nil && !os.IsNotExist(err) {
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
cfg := config.LoadConfig()
|
||||
|
||||
shouldWriteFiles := false
|
||||
for _, file := range cfg.WriteFiles {
|
||||
if file.Container != "" {
|
||||
shouldWriteFiles = true
|
||||
}
|
||||
}
|
||||
|
||||
if shouldWriteFiles {
|
||||
writeFiles(cfg)
|
||||
}
|
||||
|
||||
if len(os.Args) < 3 {
|
||||
return nil
|
||||
}
|
||||
|
||||
binary, err := exec.LookPath(os.Args[2])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return syscall.Exec(binary, os.Args[2:], os.Environ())
|
||||
}
|
||||
|
||||
func writeFiles(cfg *config.CloudConfig) error {
|
||||
id, err := util.GetCurrentContainerId()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
client, err := docker.NewSystemClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
info, err := client.ContainerInspect(context.Background(), id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cloudinitexecute.WriteFiles(cfg, info.Name[1:])
|
||||
return nil
|
||||
}
|
||||
@@ -116,7 +116,7 @@ func runInstall(image, installType, cloudConfig, device string, force, reboot bo
|
||||
return err
|
||||
}
|
||||
|
||||
if reboot && yes(in, "Continue with reboot") {
|
||||
if reboot && (force || yes(in, "Continue with reboot")) {
|
||||
log.Info("Rebooting")
|
||||
power.Reboot()
|
||||
}
|
||||
|
||||
79
cmd/dockerinit/main.go
Normal file
79
cmd/dockerinit/main.go
Normal file
@@ -0,0 +1,79 @@
|
||||
package dockerinit
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/rancher/os/config"
|
||||
"github.com/rancher/os/util"
|
||||
)
|
||||
|
||||
const (
|
||||
consoleDone = "/run/console-done"
|
||||
dockerConf = "/var/lib/rancher/conf/docker"
|
||||
dockerDone = "/run/docker-done"
|
||||
dockerLog = "/var/log/docker.log"
|
||||
)
|
||||
|
||||
func Main() {
|
||||
for {
|
||||
if _, err := os.Stat(consoleDone); err == nil {
|
||||
break
|
||||
}
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
}
|
||||
|
||||
dockerBin := "/usr/bin/docker"
|
||||
for _, binPath := range []string{
|
||||
"/opt/bin",
|
||||
"/usr/local/bin",
|
||||
"/var/lib/rancher/docker",
|
||||
} {
|
||||
if util.ExistsAndExecutable(path.Join(binPath, "dockerd")) {
|
||||
dockerBin = path.Join(binPath, "dockerd")
|
||||
break
|
||||
}
|
||||
if util.ExistsAndExecutable(path.Join(binPath, "docker")) {
|
||||
dockerBin = path.Join(binPath, "docker")
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if err := syscall.Mount("", "/", "", syscall.MS_SHARED|syscall.MS_REC, ""); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
if err := syscall.Mount("", "/run", "", syscall.MS_SHARED|syscall.MS_REC, ""); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
mountInfo, err := ioutil.ReadFile("/proc/self/mountinfo")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
for _, mount := range strings.Split(string(mountInfo), "\n") {
|
||||
if strings.Contains(mount, "/var/lib/docker /var/lib/docker") && strings.Contains(mount, "rootfs") {
|
||||
os.Setenv("DOCKER_RAMDISK", "1")
|
||||
}
|
||||
}
|
||||
|
||||
args := []string{
|
||||
"bash",
|
||||
"-c",
|
||||
fmt.Sprintf(`[ -e %s ] && source %s; exec /usr/bin/dockerlaunch %s %s $DOCKER_OPTS >> %s 2>&1`, dockerConf, dockerConf, dockerBin, strings.Join(os.Args[1:], " "), dockerLog),
|
||||
}
|
||||
|
||||
cfg := config.LoadConfig()
|
||||
|
||||
if err := ioutil.WriteFile(dockerDone, []byte(cfg.Rancher.Docker.Engine), 0644); err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
||||
log.Fatal(syscall.Exec("/bin/bash", args, os.Environ()))
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"os"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
composeConfig "github.com/docker/libcompose/config"
|
||||
"github.com/docker/libcompose/project/options"
|
||||
"github.com/rancher/os/compose"
|
||||
"github.com/rancher/os/config"
|
||||
@@ -24,6 +25,8 @@ func Main() {
|
||||
}
|
||||
|
||||
if newConsole != "default" {
|
||||
project.ServiceConfigs.Add("console", &composeConfig.ServiceConfig{})
|
||||
|
||||
if err = compose.LoadService(project, cfg, true, newConsole); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path"
|
||||
"strconv"
|
||||
"syscall"
|
||||
"time"
|
||||
@@ -29,9 +30,15 @@ const (
|
||||
DOCKER_PID_FILE = "/var/run/docker.pid"
|
||||
DOCKER_COMMAND = "docker-init"
|
||||
userDocker = "user-docker"
|
||||
sourceDirectory = "/engine"
|
||||
destDirectory = "/var/lib/rancher/engine"
|
||||
)
|
||||
|
||||
func Main() {
|
||||
if err := copyBinaries(sourceDirectory, destDirectory); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
cfg := config.LoadConfig()
|
||||
|
||||
execID, resp, err := startDocker(cfg)
|
||||
@@ -64,6 +71,59 @@ func Main() {
|
||||
os.Exit(state.ExitCode)
|
||||
}
|
||||
|
||||
func copyBinaries(source, dest string) error {
|
||||
if err := os.MkdirAll(dest, 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
files, err := ioutil.ReadDir(dest)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, file := range files {
|
||||
if err = os.RemoveAll(path.Join(dest, file.Name())); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
files, err = ioutil.ReadDir(source)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, file := range files {
|
||||
sourceFile := path.Join(source, file.Name())
|
||||
destFile := path.Join(dest, file.Name())
|
||||
|
||||
in, err := os.Open(sourceFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
out, err := os.Create(destFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err = io.Copy(out, in); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = out.Sync(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = in.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = out.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := os.Chmod(destFile, 0751); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func writeCerts(cfg *config.CloudConfig) error {
|
||||
outDir := control.ServerTlsPath
|
||||
if err := os.MkdirAll(outDir, 0700); err != nil {
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
yaml "github.com/cloudfoundry-incubator/candiedyaml"
|
||||
composeConfig "github.com/docker/libcompose/config"
|
||||
"github.com/docker/libcompose/project"
|
||||
"github.com/rancher/os/config"
|
||||
"github.com/rancher/os/docker"
|
||||
@@ -61,12 +62,17 @@ func projectReload(p *project.Project, useNetwork *bool, loadConsole bool, envir
|
||||
enabled[service] = service
|
||||
}
|
||||
|
||||
if !loadConsole || cfg.Rancher.Console == "" || cfg.Rancher.Console == "default" {
|
||||
return nil
|
||||
if loadConsole && cfg.Rancher.Console != "" && cfg.Rancher.Console != "default" {
|
||||
if err := LoadService(p, cfg, *useNetwork, cfg.Rancher.Console); err != nil && err != network.ErrNoNetwork {
|
||||
log.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := LoadService(p, cfg, *useNetwork, cfg.Rancher.Console); err != nil && err != network.ErrNoNetwork {
|
||||
log.Error(err)
|
||||
if cfg.Rancher.Docker.Engine != "" && cfg.Rancher.Docker.Engine != cfg.Rancher.Defaults.Docker.Engine {
|
||||
p.ServiceConfigs.Add("docker", &composeConfig.ServiceConfig{})
|
||||
if err := LoadService(p, cfg, *useNetwork, cfg.Rancher.Docker.Engine); err != nil && err != network.ErrNoNetwork {
|
||||
log.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -39,6 +39,12 @@ func Get(key string) (interface{}, error) {
|
||||
return v, nil
|
||||
}
|
||||
|
||||
func GetCmdline(key string) interface{} {
|
||||
cmdline := readCmdline()
|
||||
v, _ := getOrSetVal(key, cmdline, nil)
|
||||
return v
|
||||
}
|
||||
|
||||
func Set(key string, value interface{}) error {
|
||||
existing, err := readConfigs(nil, false, true, CloudConfigFile)
|
||||
if err != nil {
|
||||
|
||||
@@ -108,6 +108,7 @@ func TestParseCmdline(t *testing.T) {
|
||||
"key1": "value1",
|
||||
"key2": "value2",
|
||||
"keyArray": []interface{}{int64(1), int64(2)},
|
||||
"strArray": []interface{}{"url:http://192.168.1.100/cloud-config"},
|
||||
"obj1": map[interface{}]interface{}{
|
||||
"key3": "3value",
|
||||
"obj2": map[interface{}]interface{}{
|
||||
@@ -120,7 +121,7 @@ func TestParseCmdline(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
actual := parseCmdline("a b rancher.rescue rancher.keyArray=[1,2] rancher.key1=value1 c rancher.key2=value2 rancher.obj1.key3=3value rancher.obj1.obj2.key4 rancher.key5=5 rancher.key6=a,b rancher.key7=a\nb")
|
||||
actual := parseCmdline("a b rancher.rescue rancher.keyArray=[1,2] rancher.strArray=[\"url:http://192.168.1.100/cloud-config\"] rancher.key1=value1 c rancher.key2=value2 rancher.obj1.key3=3value rancher.obj1.obj2.key4 rancher.key5=5 rancher.key6=a,b rancher.key7=a\nb")
|
||||
|
||||
assert.Equal(expected, actual)
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ func readCmdline() map[interface{}]interface{} {
|
||||
|
||||
log.Debugf("Config cmdline %s", cmdLine)
|
||||
|
||||
cmdLineObj := parseCmdline(strings.TrimSpace(string(cmdLine)))
|
||||
cmdLineObj := parseCmdline(strings.TrimSpace(util.UnescapeKernelParams(string(cmdLine))))
|
||||
|
||||
return cmdLineObj
|
||||
}
|
||||
|
||||
@@ -85,10 +85,16 @@ type Repositories map[string]Repository
|
||||
|
||||
type CloudConfig struct {
|
||||
SSHAuthorizedKeys []string `yaml:"ssh_authorized_keys"`
|
||||
WriteFiles []config.File `yaml:"write_files"`
|
||||
WriteFiles []File `yaml:"write_files"`
|
||||
Hostname string `yaml:"hostname"`
|
||||
Mounts [][]string `yaml:"mounts,omitempty"`
|
||||
Rancher RancherConfig `yaml:"rancher,omitempty"`
|
||||
Runcmd [][]string `yaml:"runcmd,omitempty"`
|
||||
}
|
||||
|
||||
type File struct {
|
||||
config.File
|
||||
Container string `yaml:"container,omitempty"`
|
||||
}
|
||||
|
||||
type RancherConfig struct {
|
||||
@@ -119,6 +125,7 @@ type RancherConfig struct {
|
||||
Defaults Defaults `yaml:"defaults,omitempty"`
|
||||
ResizeDevice string `yaml:"resize_device,omitempty"`
|
||||
Sysctl map[string]string `yaml:"sysctl,omitempty"`
|
||||
RestartServices []string `yaml:"restart_services,omitempty"`
|
||||
}
|
||||
|
||||
type UpgradeConfig struct {
|
||||
@@ -128,6 +135,7 @@ type UpgradeConfig struct {
|
||||
}
|
||||
|
||||
type DockerConfig struct {
|
||||
Engine string `yaml:"engine,omitempty"`
|
||||
TLS bool `yaml:"tls,omitempty"`
|
||||
TLSArgs []string `yaml:"tls_args,flow,omitempty"`
|
||||
Args []string `yaml:"args,flow,omitempty"`
|
||||
@@ -149,6 +157,7 @@ type StateConfig struct {
|
||||
Directory string `yaml:"directory,omitempty"`
|
||||
FsType string `yaml:"fstype,omitempty"`
|
||||
Dev string `yaml:"dev,omitempty"`
|
||||
Wait bool `yaml:"wait,omitempty"`
|
||||
Required bool `yaml:"required,omitempty"`
|
||||
Autoformat []string `yaml:"autoformat,omitempty"`
|
||||
FormatZero bool `yaml:"formatzero,omitempty"`
|
||||
@@ -164,6 +173,7 @@ type CloudInit struct {
|
||||
|
||||
type Defaults struct {
|
||||
Hostname string `yaml:"hostname,omitempty"`
|
||||
Docker DockerConfig `yaml:"docker,omitempty"`
|
||||
Network netconf.NetworkConfig `yaml:"network,omitempty"`
|
||||
}
|
||||
|
||||
|
||||
@@ -107,14 +107,14 @@ func (s *Service) shouldRebuild(ctx context.Context) (bool, error) {
|
||||
if newRebuildLabel == "always" {
|
||||
return true, nil
|
||||
}
|
||||
if s.Name() == "console" && cfg.Rancher.ForceConsoleRebuild {
|
||||
if err := config.Set("rancher.force_console_rebuild", false); err != nil {
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
if outOfSync {
|
||||
if s.Name() == "console" {
|
||||
if cfg.Rancher.ForceConsoleRebuild {
|
||||
if err := config.Set("rancher.force_console_rebuild", false); err != nil {
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
origConsoleLabel := containerInfo.Config.Labels[config.CONSOLE]
|
||||
newConsoleLabel := s.Config().Labels[config.CONSOLE]
|
||||
if newConsoleLabel != origConsoleLabel {
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 18 KiB |
@@ -32,8 +32,8 @@ RUN rm /sbin/poweroff /sbin/reboot /sbin/halt && \
|
||||
adduser docker sudo && \
|
||||
echo '%sudo ALL=(ALL) ALL' >> /etc/sudoers
|
||||
COPY inputrc /etc/inputrc
|
||||
COPY entry.sh /usr/sbin/entry.sh
|
||||
COPY growpart /usr/bin/growpart
|
||||
RUN sed -i -e 's/duid/clientid/g' /etc/dhcpcd.conf
|
||||
RUN sed -i s/"partx --update \"\$part\" \"\$dev\""/"partx --update --nr \"\$part\" \"\$dev\""/g /usr/bin/growpart && \
|
||||
sed -i -e 's/duid/clientid/g' /etc/dhcpcd.conf
|
||||
|
||||
ENTRYPOINT ["/usr/sbin/entry.sh"]
|
||||
ENTRYPOINT ["/usr/bin/ros", "entrypoint"]
|
||||
|
||||
3
images/02-acpid/Dockerfile
Normal file
3
images/02-acpid/Dockerfile
Normal file
@@ -0,0 +1,3 @@
|
||||
FROM rancher/os-base
|
||||
COPY lid /etc/acpi/events/
|
||||
COPY suspend.sh /etc/acpi/suspend.sh
|
||||
2
images/02-acpid/lid
Normal file
2
images/02-acpid/lid
Normal file
@@ -0,0 +1,2 @@
|
||||
event=button/lid
|
||||
action=/etc/acpi/suspend.sh %e
|
||||
4
images/02-acpid/suspend.sh
Executable file
4
images/02-acpid/suspend.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
if [ "$3" = "close" ]; then
|
||||
echo -n "mem" > /sys/power/state
|
||||
fi
|
||||
@@ -12,7 +12,7 @@ for dev in ${DEVS[@]}; do
|
||||
|
||||
# Test for our magic string (it means that the disk was made by ./boot2docker init)
|
||||
HEADER=`dd if=${dev} bs=1 count=${#MAGIC} 2>/dev/null`
|
||||
|
||||
|
||||
if [ "$HEADER" = "$MAGIC" ]; then
|
||||
# save the preload userdata.tar file
|
||||
dd if=${dev} of=/userdata.tar bs=1 count=8192
|
||||
@@ -23,10 +23,10 @@ for dev in ${DEVS[@]}; do
|
||||
# do not auto-format if the disk does not begin with 1MB filled with 00
|
||||
continue
|
||||
fi
|
||||
|
||||
mkfs.ext4 -L RANCHER_STATE ${dev}
|
||||
|
||||
|
||||
|
||||
if [ -e "/userdata.tar" ]; then
|
||||
mkfs.ext4 -L B2D_STATE ${dev}
|
||||
mkdir -p /mnt/new-root
|
||||
mount -t ext4 ${dev} /mnt/new-root
|
||||
pushd /mnt/new-root
|
||||
@@ -49,7 +49,7 @@ rancher:
|
||||
|
||||
ssh_authorized_keys:
|
||||
- ${AUTHORIZED_KEY1}
|
||||
- ${AUTHORIZED_KEY2}
|
||||
- ${AUTHORIZED_KEY2}
|
||||
|
||||
users:
|
||||
- name: docker
|
||||
@@ -59,6 +59,8 @@ users:
|
||||
EOF
|
||||
popd
|
||||
umount /mnt/new-root
|
||||
else
|
||||
mkfs.ext4 -L RANCHER_STATE ${dev}
|
||||
fi
|
||||
|
||||
# do not check another device
|
||||
|
||||
@@ -12,4 +12,4 @@ else
|
||||
mount -t 9p -o trans=virtio,version=9p2000.L config-2 ${MOUNT_POINT} 2>/dev/null || true
|
||||
fi
|
||||
|
||||
cloud-init -save -network=${CLOUD_INIT_NETWORK:-true}
|
||||
cloud-init-save -network=${CLOUD_INIT_NETWORK:-true}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
FROM rancher/os-base
|
||||
COPY console.sh docker-init update-ssh-keys rancheros-install /usr/sbin/
|
||||
COPY update-ssh-keys /usr/sbin/
|
||||
COPY build/lsb-release /etc/
|
||||
RUN sed -i 's/rancher:!/rancher:*/g' /etc/shadow && \
|
||||
sed -i 's/docker:!/docker:*/g' /etc/shadow && \
|
||||
@@ -7,10 +7,6 @@ RUN sed -i 's/rancher:!/rancher:*/g' /etc/shadow && \
|
||||
echo '## allow password less for rancher user' >> /etc/sudoers && \
|
||||
echo 'rancher ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers && \
|
||||
echo '## allow password less for docker user' >> /etc/sudoers && \
|
||||
echo 'docker ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers && \
|
||||
ln -sf /usr/bin/docker.dist /usr/bin/docker && \
|
||||
ln -sf /usr/bin/docker-containerd.dist /usr/bin/docker-containerd && \
|
||||
ln -sf /usr/bin/docker-containerd-shim.dist /usr/bin/docker-containerd-shim && \
|
||||
ln -sf /usr/bin/docker-runc.dist /usr/bin/docker-runc
|
||||
echo 'docker ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
|
||||
COPY prompt.sh /etc/profile.d/
|
||||
CMD ["/usr/sbin/console.sh"]
|
||||
|
||||
@@ -1,138 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e -x
|
||||
|
||||
setup_ssh()
|
||||
{
|
||||
for i in rsa dsa ecdsa ed25519; do
|
||||
local output=/etc/ssh/ssh_host_${i}_key
|
||||
if [ ! -s $output ]; then
|
||||
local saved="$(ros config get rancher.ssh.keys.${i})"
|
||||
local pub="$(ros config get rancher.ssh.keys.${i}-pub)"
|
||||
|
||||
if [[ -n "$saved" && -n "$pub" ]]; then
|
||||
(
|
||||
umask 077
|
||||
temp_file=$(mktemp)
|
||||
echo "$saved" > ${temp_file}
|
||||
mv ${temp_file} ${output}
|
||||
temp_file=$(mktemp)
|
||||
echo "$pub" > ${temp_file}
|
||||
mv ${temp_file} ${output}.pub
|
||||
)
|
||||
else
|
||||
ssh-keygen -f $output -N '' -t $i
|
||||
ros config set -- rancher.ssh.keys.${i} "$(<${output})"
|
||||
ros config set -- rancher.ssh.keys.${i}-pub "$(<${output}.pub)"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
mkdir -p /var/run/sshd
|
||||
}
|
||||
|
||||
RANCHER_HOME=/home/rancher
|
||||
if [ ! -d ${RANCHER_HOME} ]; then
|
||||
mkdir -p ${RANCHER_HOME}
|
||||
chown rancher:rancher ${RANCHER_HOME}
|
||||
chmod 2755 ${RANCHER_HOME}
|
||||
fi
|
||||
|
||||
DOCKER_HOME=/home/docker
|
||||
if [ ! -d ${DOCKER_HOME} ]; then
|
||||
mkdir -p ${DOCKER_HOME}
|
||||
chown docker:docker ${DOCKER_HOME}
|
||||
chmod 2755 ${DOCKER_HOME}
|
||||
fi
|
||||
|
||||
echo 1000000000 > /proc/sys/fs/file-max
|
||||
|
||||
for i in $(</proc/cmdline); do
|
||||
case $i in
|
||||
rancher.password=*)
|
||||
PASSWORD=$(echo $i | sed 's/rancher.password=//')
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -n "$PASSWORD" ]; then
|
||||
echo "rancher:$PASSWORD" | chpasswd
|
||||
sed -E -i 's/(rancher:.*:).*(:.*:.*:.*:.*:.*:.*)$/\1\2/' /etc/shadow
|
||||
fi
|
||||
|
||||
setup_ssh
|
||||
|
||||
cat > /etc/respawn.conf << EOF
|
||||
/sbin/getty 115200 tty6
|
||||
/sbin/getty 115200 tty5
|
||||
/sbin/getty 115200 tty4
|
||||
/sbin/getty 115200 tty3
|
||||
/sbin/getty 115200 tty2
|
||||
/sbin/getty 115200 tty1
|
||||
/usr/sbin/sshd -D
|
||||
EOF
|
||||
|
||||
for i in ttyS{0..4} ttyAMA0; do
|
||||
if grep -q 'console='$i /proc/cmdline; then
|
||||
echo '/sbin/getty 115200' $i >> /etc/respawn.conf
|
||||
fi
|
||||
done
|
||||
|
||||
if ! grep -q '^UseDNS no' /etc/ssh/sshd_config; then
|
||||
echo "UseDNS no" >> /etc/ssh/sshd_config
|
||||
fi
|
||||
|
||||
if ! grep -q '^PermitRootLogin no' /etc/ssh/sshd_config; then
|
||||
echo "PermitRootLogin no" >> /etc/ssh/sshd_config
|
||||
fi
|
||||
|
||||
if ! grep -q '^ServerKeyBits 2048' /etc/ssh/sshd_config; then
|
||||
echo "ServerKeyBits 2048" >> /etc/ssh/sshd_config
|
||||
fi
|
||||
|
||||
if ! grep -q '^AllowGroups docker' /etc/ssh/sshd_config; then
|
||||
echo "AllowGroups docker" >> /etc/ssh/sshd_config
|
||||
fi
|
||||
|
||||
VERSION="$(ros os version)"
|
||||
ID_TYPE="busybox"
|
||||
if [ -e /etc/os-release ] && grep -q 'ID_LIKE=' /etc/os-release; then
|
||||
ID_TYPE=$(grep 'ID_LIKE=' /etc/os-release | cut -d'=' -f2)
|
||||
fi
|
||||
|
||||
cat > /etc/os-release << EOF
|
||||
NAME="RancherOS"
|
||||
VERSION=$VERSION
|
||||
ID=rancheros
|
||||
ID_LIKE=$ID_TYPE
|
||||
VERSION_ID=$VERSION
|
||||
PRETTY_NAME="RancherOS"
|
||||
HOME_URL=
|
||||
SUPPORT_URL=
|
||||
BUG_REPORT_URL=
|
||||
BUILD_ID=
|
||||
EOF
|
||||
|
||||
echo 'RancherOS \n \l' > /etc/issue
|
||||
echo $(/sbin/ifconfig | grep -B1 "inet addr" |awk '{ if ( $1 == "inet" ) { print $2 } else if ( $2 == "Link" ) { printf "%s:" ,$1 } }' |awk -F: '{ print $1 ": " $3}') >> /etc/issue
|
||||
|
||||
cloud-init -execute
|
||||
|
||||
if [ -x /var/lib/rancher/conf/cloud-config-script ]; then
|
||||
echo "Running /var/lib/rancher/conf/cloud-config-script"
|
||||
/var/lib/rancher/conf/cloud-config-script || true
|
||||
fi
|
||||
|
||||
if [ -x /opt/rancher/bin/start.sh ]; then
|
||||
echo Executing custom script
|
||||
/opt/rancher/bin/start.sh || true
|
||||
fi
|
||||
|
||||
echo `ros config get rancher.console` > /run/console-done
|
||||
|
||||
if [ -x /etc/rc.local ]; then
|
||||
echo Executing rc.local
|
||||
/etc/rc.local || true
|
||||
fi
|
||||
|
||||
export TERM=linux
|
||||
exec respawn -f /etc/respawn.conf
|
||||
@@ -1,29 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
if [ -e /var/lib/rancher/conf/docker ]; then
|
||||
source /var/lib/rancher/conf/docker
|
||||
fi
|
||||
|
||||
while [ ! -e /run/console-done ]; do
|
||||
sleep 1
|
||||
done
|
||||
|
||||
DOCKER_BIN=$(which docker) || DOCKER_BIN=/usr/bin/docker
|
||||
|
||||
for i in /opt/bin /usr/local/bin; do
|
||||
if [ -x ${i}/docker ]; then
|
||||
PATH=${i}:$PATH
|
||||
DOCKER_BIN=${i}/docker
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
mount --make-shared /
|
||||
mount --make-shared /run
|
||||
|
||||
if [ "$(grep '/var/lib/docker /var/lib/docker ' /proc/self/mountinfo | awk '{print $9}')" = "rootfs" ]; then
|
||||
export DOCKER_RAMDISK=1
|
||||
fi
|
||||
|
||||
exec /usr/bin/dockerlaunch $DOCKER_BIN "$@" $DOCKER_OPTS >>/var/log/docker.log 2>&1
|
||||
@@ -1,9 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
cat <<EOF
|
||||
As of RancherOS v0.4.0 'rancheros-install' is obsolete.
|
||||
Please use 'ros install' instead.
|
||||
EOF
|
||||
|
||||
exit 1
|
||||
@@ -1,7 +1,4 @@
|
||||
FROM rancher/os-base
|
||||
RUN ln -sf /usr/bin/docker.dist /usr/bin/docker && \
|
||||
ln -sf /usr/bin/docker-containerd.dist /usr/bin/docker-containerd && \
|
||||
ln -sf /usr/bin/docker-containerd-shim.dist /usr/bin/docker-containerd-shim && \
|
||||
ln -sf /usr/bin/docker-runc.dist /usr/bin/docker-runc
|
||||
RUN ln -sf /var/lib/rancher/engine/docker /usr/bin/docker
|
||||
COPY preload.sh /
|
||||
CMD ["/preload.sh"]
|
||||
|
||||
@@ -4,6 +4,12 @@ set -e
|
||||
BASE=${1:-${PRELOAD_DIR}}
|
||||
BASE=${BASE:-/mnt/preload}
|
||||
|
||||
if [ "${SYSTEM_IMAGES}" = "true" ]; then
|
||||
docker_bin=system-docker
|
||||
else
|
||||
docker_bin=docker
|
||||
fi
|
||||
|
||||
should_load() {
|
||||
file=${1}
|
||||
if [[ ${file} =~ \.done$ ]]; then echo false
|
||||
@@ -26,7 +32,7 @@ if [ -d ${BASE} ]; then
|
||||
if [[ ${file} =~ \.t?gz$ ]]; then CAT="${CAT} | gunzip"; fi
|
||||
if [[ ${file} =~ \.t?xz$ ]]; then CAT="${CAT} | unxz"; fi
|
||||
wait-for-docker
|
||||
CAT="${CAT} | docker load"
|
||||
CAT="${CAT} | ${docker_bin} load"
|
||||
echo loading from ${path}
|
||||
eval ${CAT} || :
|
||||
touch ${path}.done || :
|
||||
|
||||
@@ -8,11 +8,26 @@ udevd --daemon
|
||||
udevadm trigger --action=add
|
||||
udevadm settle
|
||||
|
||||
if [ "$BOOTSTRAP" = true ]; then
|
||||
# This was needed to get USB devices to fully register
|
||||
# There is probably a better way to do this
|
||||
killall udevd
|
||||
udevd --daemon
|
||||
udevadm trigger --action=add
|
||||
udevadm settle
|
||||
dev=$(ros config get rancher.state.dev)
|
||||
wait=$(ros config get rancher.state.wait)
|
||||
if [ "$BOOTSTRAP" != true ] || [ "$dev" == "" ] || [ "$wait" != "true" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
for i in `seq 1 30`; do
|
||||
drive=$(ros dev $dev)
|
||||
if [ "$drive" != "" ]; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
drive=$(ros dev $dev)
|
||||
if [ "$drive" = "" ]; then
|
||||
exit
|
||||
fi
|
||||
for i in `seq 1 30`; do
|
||||
if [ -e $drive ]; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
67
init/init.go
67
init/init.go
@@ -19,7 +19,8 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
STATE string = "/state"
|
||||
STATE string = "/state"
|
||||
BOOT2DOCKER_MAGIC string = "boot2docker, please format-me"
|
||||
|
||||
TMPFS_MAGIC int64 = 0x01021994
|
||||
RAMFS_MAGIC int64 = 0x858458f6
|
||||
@@ -143,18 +144,21 @@ func tryMountState(cfg *config.CloudConfig) error {
|
||||
}
|
||||
|
||||
func tryMountAndBootstrap(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
||||
if isInitrd() {
|
||||
if err := tryMountState(cfg); !cfg.Rancher.State.Required && err != nil {
|
||||
return cfg, nil
|
||||
} else if err != nil {
|
||||
return cfg, err
|
||||
}
|
||||
|
||||
log.Debugf("Switching to new root at %s %s", STATE, cfg.Rancher.State.Directory)
|
||||
if err := switchRoot(STATE, cfg.Rancher.State.Directory, cfg.Rancher.RmUsr); err != nil {
|
||||
return cfg, err
|
||||
}
|
||||
if !isInitrd() || cfg.Rancher.State.Dev == "" {
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
if err := tryMountState(cfg); !cfg.Rancher.State.Required && err != nil {
|
||||
return cfg, nil
|
||||
} else if err != nil {
|
||||
return cfg, err
|
||||
}
|
||||
|
||||
log.Debugf("Switching to new root at %s %s", STATE, cfg.Rancher.State.Directory)
|
||||
if err := switchRoot(STATE, cfg.Rancher.State.Directory, cfg.Rancher.RmUsr); err != nil {
|
||||
return cfg, err
|
||||
}
|
||||
|
||||
return mountOem(cfg)
|
||||
}
|
||||
|
||||
@@ -213,6 +217,7 @@ func RunInit() error {
|
||||
log.Debug("Booting off a persistent filesystem")
|
||||
}
|
||||
|
||||
boot2DockerEnvironment := false
|
||||
initFuncs := []config.CfgFunc{
|
||||
func(c *config.CloudConfig) (*config.CloudConfig, error) {
|
||||
return c, dockerlaunch.PrepareFs(&mountConfig)
|
||||
@@ -233,8 +238,44 @@ func RunInit() error {
|
||||
return cfg, nil
|
||||
},
|
||||
loadModules,
|
||||
func(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
||||
if util.ResolveDevice("LABEL=B2D_STATE") != "" {
|
||||
boot2DockerEnvironment = true
|
||||
cfg.Rancher.State.Dev = "LABEL=B2D_STATE"
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
devices := []string{"/dev/sda", "/dev/vda"}
|
||||
data := make([]byte, len(BOOT2DOCKER_MAGIC))
|
||||
|
||||
for _, device := range devices {
|
||||
f, err := os.Open(device)
|
||||
if err == nil {
|
||||
defer f.Close()
|
||||
|
||||
_, err = f.Read(data)
|
||||
if err == nil && string(data) == BOOT2DOCKER_MAGIC {
|
||||
boot2DockerEnvironment = true
|
||||
cfg.Rancher.State.Dev = "LABEL=B2D_STATE"
|
||||
cfg.Rancher.State.Autoformat = []string{device}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return cfg, nil
|
||||
},
|
||||
tryMountAndBootstrap,
|
||||
func(_ *config.CloudConfig) (*config.CloudConfig, error) {
|
||||
func(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
||||
if boot2DockerEnvironment {
|
||||
if err := config.Set("rancher.state.dev", cfg.Rancher.State.Dev); err != nil {
|
||||
log.Errorf("Failed to update rancher.state.dev: %v", err)
|
||||
}
|
||||
if err := config.Set("rancher.state.autoformat", cfg.Rancher.State.Autoformat); err != nil {
|
||||
log.Errorf("Failed to update rancher.state.autoformat: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
return config.LoadConfig(), nil
|
||||
},
|
||||
loadModules,
|
||||
|
||||
45
main.go
45
main.go
@@ -7,8 +7,11 @@ import (
|
||||
"github.com/docker/docker/pkg/reexec"
|
||||
"github.com/rancher/cniglue"
|
||||
"github.com/rancher/docker-from-scratch"
|
||||
"github.com/rancher/os/cmd/cloudinit"
|
||||
"github.com/rancher/os/cmd/cloudinitexecute"
|
||||
"github.com/rancher/os/cmd/cloudinitsave"
|
||||
"github.com/rancher/os/cmd/console"
|
||||
"github.com/rancher/os/cmd/control"
|
||||
"github.com/rancher/os/cmd/dockerinit"
|
||||
"github.com/rancher/os/cmd/network"
|
||||
"github.com/rancher/os/cmd/power"
|
||||
"github.com/rancher/os/cmd/respawn"
|
||||
@@ -21,24 +24,28 @@ import (
|
||||
)
|
||||
|
||||
var entrypoints = map[string]func(){
|
||||
"cloud-init": cloudinit.Main,
|
||||
"docker": docker.Main,
|
||||
"dockerlaunch": dockerlaunch.Main,
|
||||
"halt": power.Halt,
|
||||
"init": osInit.MainInit,
|
||||
"netconf": network.Main,
|
||||
"poweroff": power.PowerOff,
|
||||
"reboot": power.Reboot,
|
||||
"respawn": respawn.Main,
|
||||
"ros-sysinit": sysinit.Main,
|
||||
"shutdown": power.Main,
|
||||
"switch-console": switchconsole.Main,
|
||||
"system-docker": systemdocker.Main,
|
||||
"user-docker": userdocker.Main,
|
||||
"wait-for-docker": wait.Main,
|
||||
"cni-glue": glue.Main,
|
||||
"bridge": bridge.Main,
|
||||
"host-local": hostlocal.Main,
|
||||
"cloud-init-execute": cloudinitexecute.Main,
|
||||
"cloud-init-save": cloudinitsave.Main,
|
||||
"console": console.Main,
|
||||
"console.sh": console.Main,
|
||||
"docker": docker.Main,
|
||||
"docker-init": dockerinit.Main,
|
||||
"dockerlaunch": dockerlaunch.Main,
|
||||
"halt": power.Halt,
|
||||
"init": osInit.MainInit,
|
||||
"netconf": network.Main,
|
||||
"poweroff": power.PowerOff,
|
||||
"reboot": power.Reboot,
|
||||
"respawn": respawn.Main,
|
||||
"ros-sysinit": sysinit.Main,
|
||||
"shutdown": power.Main,
|
||||
"switch-console": switchconsole.Main,
|
||||
"system-docker": systemdocker.Main,
|
||||
"user-docker": userdocker.Main,
|
||||
"wait-for-docker": wait.Main,
|
||||
"cni-glue": glue.Main,
|
||||
"bridge": bridge.Main,
|
||||
"host-local": hostlocal.Main,
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
@@ -4,6 +4,13 @@ rancher:
|
||||
SUFFIX: {{.SUFFIX}}
|
||||
defaults:
|
||||
hostname: {{.HOSTNAME_DEFAULT}}
|
||||
{{if eq "amd64" .ARCH -}}
|
||||
docker:
|
||||
engine: docker-1.12.1
|
||||
{{else -}}
|
||||
docker:
|
||||
engine: docker-1.11.2
|
||||
{{end -}}
|
||||
network:
|
||||
dns:
|
||||
nameservers: [8.8.8.8, 8.8.4.4]
|
||||
@@ -39,6 +46,7 @@ rancher:
|
||||
- /dev:/host/dev
|
||||
- /lib/modules:/lib/modules
|
||||
- /lib/firmware:/lib/firmware
|
||||
- /usr/bin/ros:/usr/bin/ros:ro
|
||||
autoformat:
|
||||
autoformat:
|
||||
image: {{.OS_REPO}}/os-autoformat:{{.VERSION}}{{.SUFFIX}}
|
||||
@@ -62,6 +70,7 @@ rancher:
|
||||
- /dev:/host/dev
|
||||
- /lib/modules:/lib/modules
|
||||
- /lib/firmware:/lib/firmware
|
||||
- /usr/bin/ros:/usr/bin/ros:ro
|
||||
bootstrap_docker:
|
||||
args: [daemon, -s, overlay, -b, none, --restart=false, -g, /var/lib/system-docker,
|
||||
-G, root, -H, 'unix:///var/run/system-docker.sock', --userland-proxy=false]
|
||||
@@ -71,16 +80,17 @@ rancher:
|
||||
- configdrive:/media/config-2
|
||||
repositories:
|
||||
core:
|
||||
url: {{.OS_SERVICES_REPO}}/{{.REPO_VERSION}}{{.SUFFIX}}
|
||||
url: {{.OS_SERVICES_REPO}}/{{.REPO_VERSION}}
|
||||
state:
|
||||
fstype: auto
|
||||
dev: LABEL=RANCHER_STATE
|
||||
oem_fstype: auto
|
||||
oem_dev: LABEL=RANCHER_OEM
|
||||
sysctl:
|
||||
fs.file-max: 1000000000
|
||||
services:
|
||||
{{if eq "amd64" .ARCH -}}
|
||||
acpid:
|
||||
image: {{.OS_REPO}}/os-base:{{.VERSION}}{{.SUFFIX}}
|
||||
image: {{.OS_REPO}}/os-acpid:{{.VERSION}}{{.SUFFIX}}
|
||||
command: /usr/sbin/acpid -f
|
||||
labels:
|
||||
io.rancher.os.scope: system
|
||||
@@ -119,6 +129,19 @@ rancher:
|
||||
volumes_from:
|
||||
- command-volumes
|
||||
- system-volumes
|
||||
cloud-init-execute:
|
||||
image: {{.OS_REPO}}/os-base:{{.VERSION}}{{.SUFFIX}}
|
||||
command: cloud-init-execute -pre-console
|
||||
labels:
|
||||
io.rancher.os.detach: "false"
|
||||
io.rancher.os.scope: system
|
||||
io.rancher.os.after: cloud-init
|
||||
net: host
|
||||
uts: host
|
||||
privileged: true
|
||||
volumes_from:
|
||||
- command-volumes
|
||||
- system-volumes
|
||||
cloud-init-pre:
|
||||
image: {{.OS_REPO}}/os-cloudinit:{{.VERSION}}{{.SUFFIX}}
|
||||
environment:
|
||||
@@ -127,7 +150,7 @@ rancher:
|
||||
io.rancher.os.detach: "false"
|
||||
io.rancher.os.reloadconfig: "true"
|
||||
io.rancher.os.scope: system
|
||||
io.rancher.os.after: preload-system-images
|
||||
io.rancher.os.after: udev,preload-system-images
|
||||
net: host
|
||||
uts: host
|
||||
privileged: true
|
||||
@@ -145,10 +168,6 @@ rancher:
|
||||
privileged: true
|
||||
read_only: true
|
||||
volumes:
|
||||
- /usr/bin/docker-containerd:/usr/bin/docker-containerd.dist:ro
|
||||
- /usr/bin/docker-containerd-shim:/usr/bin/docker-containerd-shim.dist:ro
|
||||
- /usr/bin/docker-runc:/usr/bin/docker-runc.dist:ro
|
||||
- /usr/bin/docker:/usr/bin/docker.dist:ro
|
||||
- /usr/bin/ros:/usr/bin/dockerlaunch:ro
|
||||
- /usr/bin/ros:/usr/bin/user-docker:ro
|
||||
- /usr/bin/ros:/usr/bin/system-docker:ro
|
||||
@@ -158,12 +177,17 @@ rancher:
|
||||
- /usr/bin/ros:/sbin/shutdown:ro
|
||||
- /usr/bin/ros:/usr/bin/respawn:ro
|
||||
- /usr/bin/ros:/usr/bin/ros:ro
|
||||
- /usr/bin/ros:/usr/bin/cloud-init:ro
|
||||
- /usr/bin/ros:/usr/bin/cloud-init-execute:ro
|
||||
- /usr/bin/ros:/usr/bin/cloud-init-save:ro
|
||||
- /usr/bin/ros:/usr/sbin/netconf:ro
|
||||
- /usr/bin/ros:/usr/sbin/wait-for-docker:ro
|
||||
- /usr/bin/ros:/usr/bin/switch-console:ro
|
||||
- /usr/bin/ros:/usr/bin/console:ro
|
||||
- /usr/bin/ros:/usr/sbin/console.sh:ro
|
||||
- /usr/bin/ros:/usr/sbin/docker-init:ro
|
||||
console:
|
||||
image: {{.OS_REPO}}/os-console:{{.VERSION}}{{.SUFFIX}}
|
||||
command: console
|
||||
labels:
|
||||
io.rancher.os.scope: system
|
||||
io.rancher.os.after: network
|
||||
@@ -211,7 +235,7 @@ rancher:
|
||||
command: netconf --stop-network-pre
|
||||
labels:
|
||||
io.rancher.os.scope: system
|
||||
io.rancher.os.after: cloud-init
|
||||
io.rancher.os.after: cloud-init-execute
|
||||
net: host
|
||||
uts: host
|
||||
pid: host
|
||||
@@ -229,8 +253,13 @@ rancher:
|
||||
uts: host
|
||||
privileged: true
|
||||
restart: always
|
||||
volumes_from:
|
||||
- command-volumes
|
||||
- system-volumes
|
||||
preload-system-images:
|
||||
image: {{.OS_REPO}}/os-preload:{{.VERSION}}{{.SUFFIX}}
|
||||
environment:
|
||||
- SYSTEM_IMAGES=true
|
||||
labels:
|
||||
io.rancher.os.detach: "false"
|
||||
io.rancher.os.scope: system
|
||||
@@ -268,6 +297,7 @@ rancher:
|
||||
privileged: true
|
||||
restart: always
|
||||
volumes_from:
|
||||
- command-volumes
|
||||
- system-volumes
|
||||
system-volumes:
|
||||
image: {{.OS_REPO}}/os-base:{{.VERSION}}{{.SUFFIX}}
|
||||
@@ -298,12 +328,13 @@ rancher:
|
||||
udev-cold:
|
||||
image: {{.OS_REPO}}/os-udev:{{.VERSION}}{{.SUFFIX}}
|
||||
labels:
|
||||
io.rancher.os.detach: "false"
|
||||
io.rancher.os.scope: system
|
||||
io.rancher.os.before: udev
|
||||
net: host
|
||||
uts: host
|
||||
privileged: true
|
||||
volumes_from:
|
||||
- command-volumes
|
||||
- system-volumes
|
||||
udev:
|
||||
image: {{.OS_REPO}}/os-udev:{{.VERSION}}{{.SUFFIX}}
|
||||
@@ -312,11 +343,13 @@ rancher:
|
||||
labels:
|
||||
io.rancher.os.detach: "true"
|
||||
io.rancher.os.scope: system
|
||||
io.rancher.os.after: udev-cold
|
||||
net: host
|
||||
uts: host
|
||||
privileged: true
|
||||
restart: always
|
||||
volumes_from:
|
||||
- command-volumes
|
||||
- system-volumes
|
||||
user-volumes:
|
||||
image: {{.OS_REPO}}/os-base:{{.VERSION}}{{.SUFFIX}}
|
||||
@@ -332,7 +365,11 @@ rancher:
|
||||
- /home:/home
|
||||
- /opt:/opt
|
||||
docker:
|
||||
image: {{.OS_REPO}}/os-base:{{.VERSION}}{{.SUFFIX}}
|
||||
{{if eq "amd64" .ARCH -}}
|
||||
image: {{.OS_REPO}}/os-docker:1.12.1{{.SUFFIX}}
|
||||
{{else -}}
|
||||
image: {{.OS_REPO}}/os-docker:1.11.2{{.SUFFIX}}
|
||||
{{end -}}
|
||||
command: /usr/bin/user-docker
|
||||
environment:
|
||||
- HTTP_PROXY
|
||||
@@ -349,8 +386,6 @@ rancher:
|
||||
restart: always
|
||||
volumes_from:
|
||||
- all-volumes
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/host/sys/fs/cgroup
|
||||
system_docker:
|
||||
exec: true
|
||||
args: [daemon, --log-opt, max-size=25m, --log-opt, max-file=2, -s, overlay,
|
||||
@@ -361,6 +396,11 @@ rancher:
|
||||
url: {{.OS_RELEASES_YML}}/releases{{.SUFFIX}}.yml
|
||||
image: {{.OS_REPO}}/os
|
||||
docker:
|
||||
{{if eq "amd64" .ARCH -}}
|
||||
engine: docker-1.12.1
|
||||
{{else -}}
|
||||
engine: docker-1.11.2
|
||||
{{end -}}
|
||||
tls_args: [--tlsverify, --tlscacert=/etc/docker/tls/ca.pem, --tlscert=/etc/docker/tls/server-cert.pem, --tlskey=/etc/docker/tls/server-key.pem,
|
||||
'-H=0.0.0.0:2376']
|
||||
args: [daemon, --log-opt, max-size=25m, --log-opt, max-file=2, -s, overlay, -G, docker, -H, 'unix:///var/run/docker.sock']
|
||||
|
||||
@@ -85,7 +85,7 @@ set timeout="1"
|
||||
|
||||
menuentry "RancherOS-current" {
|
||||
set root=(hd0,msdos1)
|
||||
linux /boot/vmlinuz-${VERSION}-rancheros ${append_line} console=${CONSOLE}
|
||||
linux /boot/vmlinuz-${VERSION}-rancheros ${append_line} rancher.state.dev=LABEL=RANCHER_STATE rancher.state.wait console=${CONSOLE}
|
||||
initrd /boot/initrd-${VERSION}-rancheros
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ if [ ! -z ${ROLLBACK_VERSION} ]; then
|
||||
cat >>${grub_cfg} <<EOF
|
||||
menuentry "RancherOS-rollback" {
|
||||
set root=(hd0,msdos1)
|
||||
linux /boot/vmlinuz-${ROLLBACK_VERSION}-rancheros ${append_line} console=${CONSOLE}
|
||||
linux /boot/vmlinuz-${ROLLBACK_VERSION}-rancheros ${append_line} rancher.state.dev=LABEL=RANCHER_STATE rancher.state.wait console=${CONSOLE}
|
||||
initrd /boot/initrd-${ROLLBACK_VERSION}-rancheros
|
||||
}
|
||||
EOF
|
||||
@@ -123,7 +123,7 @@ hiddenmenu
|
||||
|
||||
title RancherOS ${VERSION}-(current)
|
||||
root (hd0)
|
||||
kernel /boot/vmlinuz-${VERSION}-rancheros ${append_line} console=${CONSOLE}
|
||||
kernel /boot/vmlinuz-${VERSION}-rancheros ${append_line} rancher.state.dev=LABEL=RANCHER_STATE rancher.state.wait console=${CONSOLE}
|
||||
initrd /boot/initrd-${VERSION}-rancheros
|
||||
|
||||
EOF
|
||||
@@ -133,7 +133,7 @@ if [ ! -z ${ROLLBACK_VERSION} ]; then
|
||||
cat >> ${grub_file}<<EOF
|
||||
title RancherOS ${ROLLBACK_VERSION}-(rollback)
|
||||
root (hd0)
|
||||
kernel /boot/vmlinuz-${ROLLBACK_VERSION}-rancheros ${append_line} console=${CONSOLE}
|
||||
kernel /boot/vmlinuz-${ROLLBACK_VERSION}-rancheros ${append_line} rancher.state.dev=LABEL=RANCHER_STATE rancher.state.wait console=${CONSOLE}
|
||||
initrd /boot/initrd-${ROLLBACK_VERSION}-rancheros
|
||||
EOF
|
||||
fi
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
# help: Run Python based integration tests
|
||||
# help: Run integration tests
|
||||
set -e
|
||||
|
||||
if [ "$INTEGRATION_TESTS" = 0 ]; then
|
||||
@@ -8,10 +8,10 @@ fi
|
||||
|
||||
source $(dirname $0)/version
|
||||
|
||||
cd $(dirname $0)/../tests/integration
|
||||
cd $(dirname $0)/../tests
|
||||
|
||||
if [ ! -e ../../dist/artifacts/initrd ]; then
|
||||
../../scripts/dev
|
||||
if [ ! -e ../dist/artifacts/initrd ]; then
|
||||
../scripts/dev
|
||||
fi
|
||||
|
||||
tox "$@"
|
||||
go test -timeout 20m
|
||||
|
||||
@@ -2,4 +2,4 @@ default rancheros
|
||||
label rancheros
|
||||
kernel /boot/vmlinuz
|
||||
initrd /boot/initrd
|
||||
append quiet rancher.password=rancher rancher.state.autoformat=[/dev/sda,/dev/vda]
|
||||
append quiet rancher.autologin=tty1 rancher.autologin=ttyS0
|
||||
|
||||
@@ -22,10 +22,14 @@ ln -s usr/bin/ros ${INITRD_DIR}/init
|
||||
ln -s bin ${INITRD_DIR}/usr/sbin
|
||||
ln -s usr/sbin ${INITRD_DIR}/sbin
|
||||
ln -s ros ${INITRD_DIR}/usr/bin/system-docker
|
||||
ln -s ros ${INITRD_DIR}/usr/bin/docker-runc
|
||||
ln -s ../../../../usr/bin/ros ${INITRD_DIR}/usr/var/lib/cni/bin/bridge
|
||||
ln -s ../../../../usr/bin/ros ${INITRD_DIR}/usr/var/lib/cni/bin/host-local
|
||||
|
||||
tar xvzf ${DOWNLOADS}/docker.tgz -C ${INITRD_DIR}/usr/bin --strip-components=1
|
||||
# Support upgrades from old persistent consoles that bind mount these
|
||||
touch ${INITRD_DIR}/usr/bin/docker-containerd
|
||||
touch ${INITRD_DIR}/usr/bin/docker-containerd-shim
|
||||
touch ${INITRD_DIR}/usr/bin/docker
|
||||
|
||||
if [ -e ${DOWNLOADS}/kernel.tar.gz ]; then
|
||||
mkdir -p ${BUILD}/kernel
|
||||
@@ -54,8 +58,7 @@ fi
|
||||
DFS_ARCH=$(docker create ${DFS_IMAGE}${SUFFIX})
|
||||
trap "docker rm -fv ${DFS_ARCH} >/dev/null" EXIT
|
||||
|
||||
docker export ${DFS_ARCH} | tar xf - -C ${INITRD_DIR} --exclude=usr/bin/dockerlaunch \
|
||||
--exclude=usr/bin/docker \
|
||||
docker export ${DFS_ARCH} | tar xf - -C ${INITRD_DIR} --exclude=usr/bin/docker* \
|
||||
--exclude=usr/share/git-core \
|
||||
--exclude=usr/bin/git \
|
||||
--exclude=usr/bin/ssh \
|
||||
|
||||
@@ -6,6 +6,8 @@ cd $(dirname $0)/..
|
||||
|
||||
ARTIFACTS=$(pwd)/dist/artifacts
|
||||
CD=${BUILD}/cd
|
||||
ISO=${ARTIFACTS}/$(echo ${DISTRIB_ID} | tr '[:upper:]' '[:lower:]').iso
|
||||
CHECKSUM=iso-checksums.txt
|
||||
|
||||
mkdir -p ${CD}/boot/isolinux
|
||||
mkdir -p ${CD}/boot/isolinux
|
||||
@@ -25,4 +27,10 @@ cd ${CD} && xorriso \
|
||||
-no-emul-boot -boot-load-size 4 -boot-info-table \
|
||||
-b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat \
|
||||
-isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin \
|
||||
-o ${ARTIFACTS}/$(echo ${DISTRIB_ID} | tr '[:upper:]' '[:lower:]').iso ${CD}
|
||||
-o $ISO ${CD}
|
||||
|
||||
cd $(dirname $ISO)
|
||||
rm -f $CHECKSUM
|
||||
for algo in sha256 md5; do
|
||||
echo "$algo: $(${algo}sum $(basename $ISO))" >> $CHECKSUM
|
||||
done
|
||||
|
||||
@@ -18,7 +18,7 @@ mkdir -p ${ARTIFACTS} ${PREPOP_DIR}
|
||||
if [ "$(docker info | grep 'Storage Driver: ' | sed 's/Storage Driver: //')" != "overlay" ]; then
|
||||
echo Overlay storage driver is require to prepackage exploded images
|
||||
echo packaging images.tar instead
|
||||
tar czf ${ARTIFACTS}/rootfs.tar.gz --exclude lib/modules --exclude lib/firmware -C ${INITRD_DIR} .
|
||||
tar czf ${ARTIFACTS}/rootfs${SUFFIX}.tar.gz --exclude lib/modules --exclude lib/firmware -C ${INITRD_DIR} .
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -26,7 +26,10 @@ DFS=$(docker run -d --privileged -v /lib/modules/$(uname -r):/lib/modules/$(unam
|
||||
trap "docker rm -fv ${DFS_ARCH} ${DFS}" EXIT
|
||||
docker exec -i ${DFS} docker load < ${INITRD_DIR}/usr/share/ros/images.tar
|
||||
docker stop ${DFS}
|
||||
docker run --rm --volumes-from=${DFS} rancher/os-base tar -c -C /var/lib/docker ./image | tar -x -C ${PREPOP_DIR}
|
||||
docker run --rm --volumes-from=${DFS} rancher/os-base tar -c -C /var/lib/docker ./overlay | tar -x -C ${PREPOP_DIR}
|
||||
docker run --rm --volumes-from=${DFS} --entrypoint /bin/bash rancher/os-base -c "tar -c -C /var/lib/docker ./image" | tar -x -C ${PREPOP_DIR}
|
||||
docker run --rm --volumes-from=${DFS} --entrypoint /bin/bash rancher/os-base -c "tar -c -C /var/lib/docker ./overlay" | tar -x -C ${PREPOP_DIR}
|
||||
|
||||
tar czf ${ARTIFACTS}/rootfs.tar.gz --exclude usr/share/ros/images.tar --exclude lib/modules --exclude lib/firmware -C ${INITRD_DIR} .
|
||||
tar -cf ${ARTIFACTS}/rootfs${SUFFIX}.tar --exclude usr/share/ros/images.tar --exclude lib/modules --exclude lib/firmware -C ${INITRD_DIR} .
|
||||
tar -rf ${ARTIFACTS}/rootfs${SUFFIX}.tar -C ${IMAGE_CACHE} .
|
||||
rm -f ${ARTIFACTS}/rootfs${SUFFIX}.tar.gz
|
||||
gzip ${ARTIFACTS}/rootfs${SUFFIX}.tar
|
||||
|
||||
@@ -3,7 +3,7 @@ set -e
|
||||
|
||||
source $(dirname $0)/version
|
||||
export REPO_VERSION=$VERSION
|
||||
export COMPRESS=lzma
|
||||
export COMPRESS="xz --format=lzma -9 --memlimit-compress=80% -e"
|
||||
export INTEGRATION_TESTS=0
|
||||
|
||||
exec $(dirname $0)/ci
|
||||
|
||||
@@ -120,9 +120,9 @@ if [ "$REBUILD" == "1" ] || [ ! -e ${INITRD} ]; then
|
||||
popd >/dev/null
|
||||
fi
|
||||
|
||||
KERNEL_ARGS="quiet rancher.password=rancher console=${TTYCONS} ${QEMU_APPEND}"
|
||||
KERNEL_ARGS="quiet rancher.password=rancher console=${TTYCONS} rancher.autologin=${TTYCONS} ${QEMU_APPEND}"
|
||||
if [ "$FORMAT" == "1" ]; then
|
||||
KERNEL_ARGS="${KERNEL_ARGS} rancher.state.formatzero=true rancher.state.autoformat=[/dev/sda,/dev/vda]"
|
||||
KERNEL_ARGS="${KERNEL_ARGS} rancher.state.dev=LABEL=RANCHER_STATE rancher.state.formatzero=true rancher.state.autoformat=[/dev/sda,/dev/vda]"
|
||||
fi
|
||||
if [ "$RM_USR" == "1" ]; then
|
||||
KERNEL_ARGS="${KERNEL_ARGS} rancher.rm_usr"
|
||||
|
||||
@@ -6,7 +6,7 @@ cd $(dirname $0)/..
|
||||
|
||||
echo Running tests
|
||||
|
||||
PACKAGES=". $(find -name '*.go' | xargs -I{} dirname {} | cut -f2 -d/ | sort -u | grep -Ev '(^\.$|.git|.trash-cache|vendor|bin)' | sed -e 's!^!./!' -e 's!$!/...!')"
|
||||
PACKAGES=". $(find -name '*.go' | xargs -I{} dirname {} | cut -f2 -d/ | sort -u | grep -Ev '(^\.$|.git|.trash-cache|vendor|bin|tests)' | sed -e 's!^!./!' -e 's!$!/...!')"
|
||||
|
||||
if [ "$ARCH" = "amd64" ]; then
|
||||
RACE="-race"
|
||||
|
||||
@@ -3,8 +3,6 @@ rancher:
|
||||
environment:
|
||||
ETCD_DISCOVERY: https://discovery.etcd.io/c2c219023108cda9529364d6d983fe13
|
||||
FLANNEL_NETWORK: 10.244.0.0/16
|
||||
services_include:
|
||||
kernel-headers: true
|
||||
network:
|
||||
interfaces:
|
||||
eth*:
|
||||
@@ -16,4 +14,4 @@ rancher:
|
||||
docker:
|
||||
args: [daemon, --log-opt, max-file=2, --log-opt, max-size=25m, -s, overlay, -G, docker, -H, 'unix:///var/run/docker.sock', --userland-proxy=false]
|
||||
ssh_authorized_keys:
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDUlsWAL5Rf0Wis/A7k7Tlqx0fZS60VzCZrPZYbP/wkL95jv0XzCx8bd1rZHeybblHPDNpND3BLv4qPY5DxRyexF4seGuzcJI/pOvGUGjQondeMPgDTFEo5w939gSdeTZcfXzQ0wAVhzwDbgH4zPfMzbdoo8Aiu9jkKljXw8IFju0gh+t6iKkGZCIjKT9o7zza1vGfkodhvi2V3VzPdNO28gaxZaRNtmBYUoVnGyR6nXN1Q3CJaVuh5o6GPCOqrhHNbYOFZKBpDiHbxPhVpxHQD2+8yUSGTG7WW75FfZePja5y8d0c/O5L37ZYx4AZAd3KgQYDBT2XCEJGQNawNbfpt
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC85w9stZyiLQp/DkVO6fqwiShYcj1ClKdtCqgHtf+PLpJkFReSFu8y21y+ev09gsSMRRrjF7yt0pUHV6zncQhVeqsZtgc5WbELY2DOYUGmRn/CCvPbXovoBrQjSorqlBmpuPwsStYLr92Xn+VVsMNSUIegHY22DphGbDKG85vrKB8HxUxGIDxFBds/uE8FhSy+xsoyT/jUZDK6pgq2HnGl6D81ViIlKecpOpWlW3B+fea99ADNyZNVvDzbHE5pcI3VRw8u59WmpWOUgT6qacNVACl8GqpBvQk8sw7O/X9DSZHCKafeD9G5k+GYbAUz92fKWrx/lOXfUXPS3+c8dRIF
|
||||
@@ -99,4 +99,4 @@ rancher:
|
||||
-----END RSA PRIVATE KEY-----
|
||||
|
||||
ssh_authorized_keys:
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDUlsWAL5Rf0Wis/A7k7Tlqx0fZS60VzCZrPZYbP/wkL95jv0XzCx8bd1rZHeybblHPDNpND3BLv4qPY5DxRyexF4seGuzcJI/pOvGUGjQondeMPgDTFEo5w939gSdeTZcfXzQ0wAVhzwDbgH4zPfMzbdoo8Aiu9jkKljXw8IFju0gh+t6iKkGZCIjKT9o7zza1vGfkodhvi2V3VzPdNO28gaxZaRNtmBYUoVnGyR6nXN1Q3CJaVuh5o6GPCOqrhHNbYOFZKBpDiHbxPhVpxHQD2+8yUSGTG7WW75FfZePja5y8d0c/O5L37ZYx4AZAd3KgQYDBT2XCEJGQNawNbfpt
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC85w9stZyiLQp/DkVO6fqwiShYcj1ClKdtCqgHtf+PLpJkFReSFu8y21y+ev09gsSMRRrjF7yt0pUHV6zncQhVeqsZtgc5WbELY2DOYUGmRn/CCvPbXovoBrQjSorqlBmpuPwsStYLr92Xn+VVsMNSUIegHY22DphGbDKG85vrKB8HxUxGIDxFBds/uE8FhSy+xsoyT/jUZDK6pgq2HnGl6D81ViIlKecpOpWlW3B+fea99ADNyZNVvDzbHE5pcI3VRw8u59WmpWOUgT6qacNVACl8GqpBvQk8sw7O/X9DSZHCKafeD9G5k+GYbAUz92fKWrx/lOXfUXPS3+c8dRIF
|
||||
5
tests/assets/test_03/cloud-config.yml
Normal file
5
tests/assets/test_03/cloud-config.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
#cloud-config
|
||||
rancher:
|
||||
console: debian
|
||||
ssh_authorized_keys:
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC85w9stZyiLQp/DkVO6fqwiShYcj1ClKdtCqgHtf+PLpJkFReSFu8y21y+ev09gsSMRRrjF7yt0pUHV6zncQhVeqsZtgc5WbELY2DOYUGmRn/CCvPbXovoBrQjSorqlBmpuPwsStYLr92Xn+VVsMNSUIegHY22DphGbDKG85vrKB8HxUxGIDxFBds/uE8FhSy+xsoyT/jUZDK6pgq2HnGl6D81ViIlKecpOpWlW3B+fea99ADNyZNVvDzbHE5pcI3VRw8u59WmpWOUgT6qacNVACl8GqpBvQk8sw7O/X9DSZHCKafeD9G5k+GYbAUz92fKWrx/lOXfUXPS3+c8dRIF
|
||||
6
tests/assets/test_05/cloud-config.yml
Normal file
6
tests/assets/test_05/cloud-config.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
#cloud-config
|
||||
rancher:
|
||||
docker:
|
||||
engine: docker-1.10.3
|
||||
ssh_authorized_keys:
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC85w9stZyiLQp/DkVO6fqwiShYcj1ClKdtCqgHtf+PLpJkFReSFu8y21y+ev09gsSMRRrjF7yt0pUHV6zncQhVeqsZtgc5WbELY2DOYUGmRn/CCvPbXovoBrQjSorqlBmpuPwsStYLr92Xn+VVsMNSUIegHY22DphGbDKG85vrKB8HxUxGIDxFBds/uE8FhSy+xsoyT/jUZDK6pgq2HnGl6D81ViIlKecpOpWlW3B+fea99ADNyZNVvDzbHE5pcI3VRw8u59WmpWOUgT6qacNVACl8GqpBvQk8sw7O/X9DSZHCKafeD9G5k+GYbAUz92fKWrx/lOXfUXPS3+c8dRIF
|
||||
18
tests/assets/test_11/cloud-config.yml
Normal file
18
tests/assets/test_11/cloud-config.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
#cloud-config
|
||||
rancher:
|
||||
environment:
|
||||
A: A
|
||||
BB: BB
|
||||
BC: BC
|
||||
services:
|
||||
env:
|
||||
image: busybox
|
||||
command: env
|
||||
labels:
|
||||
io.rancher.os.scope: system
|
||||
io.rancher.os.before: console
|
||||
environment:
|
||||
- A
|
||||
- B*
|
||||
ssh_authorized_keys:
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC85w9stZyiLQp/DkVO6fqwiShYcj1ClKdtCqgHtf+PLpJkFReSFu8y21y+ev09gsSMRRrjF7yt0pUHV6zncQhVeqsZtgc5WbELY2DOYUGmRn/CCvPbXovoBrQjSorqlBmpuPwsStYLr92Xn+VVsMNSUIegHY22DphGbDKG85vrKB8HxUxGIDxFBds/uE8FhSy+xsoyT/jUZDK6pgq2HnGl6D81ViIlKecpOpWlW3B+fea99ADNyZNVvDzbHE5pcI3VRw8u59WmpWOUgT6qacNVACl8GqpBvQk8sw7O/X9DSZHCKafeD9G5k+GYbAUz92fKWrx/lOXfUXPS3+c8dRIF
|
||||
3
tests/assets/test_12/cloud-config.yml
Normal file
3
tests/assets/test_12/cloud-config.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
#cloud-config
|
||||
ssh_authorized_keys:
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC85w9stZyiLQp/DkVO6fqwiShYcj1ClKdtCqgHtf+PLpJkFReSFu8y21y+ev09gsSMRRrjF7yt0pUHV6zncQhVeqsZtgc5WbELY2DOYUGmRn/CCvPbXovoBrQjSorqlBmpuPwsStYLr92Xn+VVsMNSUIegHY22DphGbDKG85vrKB8HxUxGIDxFBds/uE8FhSy+xsoyT/jUZDK6pgq2HnGl6D81ViIlKecpOpWlW3B+fea99ADNyZNVvDzbHE5pcI3VRw8u59WmpWOUgT6qacNVACl8GqpBvQk8sw7O/X9DSZHCKafeD9G5k+GYbAUz92fKWrx/lOXfUXPS3+c8dRIF
|
||||
4
tests/assets/test_13/cloud-config.yml
Normal file
4
tests/assets/test_13/cloud-config.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
#cloud-config
|
||||
hostname: rancher-test
|
||||
ssh_authorized_keys:
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC85w9stZyiLQp/DkVO6fqwiShYcj1ClKdtCqgHtf+PLpJkFReSFu8y21y+ev09gsSMRRrjF7yt0pUHV6zncQhVeqsZtgc5WbELY2DOYUGmRn/CCvPbXovoBrQjSorqlBmpuPwsStYLr92Xn+VVsMNSUIegHY22DphGbDKG85vrKB8HxUxGIDxFBds/uE8FhSy+xsoyT/jUZDK6pgq2HnGl6D81ViIlKecpOpWlW3B+fea99ADNyZNVvDzbHE5pcI3VRw8u59WmpWOUgT6qacNVACl8GqpBvQk8sw7O/X9DSZHCKafeD9G5k+GYbAUz92fKWrx/lOXfUXPS3+c8dRIF
|
||||
6
tests/assets/test_22/cloud-config.yml
Normal file
6
tests/assets/test_22/cloud-config.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
#cloud-config
|
||||
rancher:
|
||||
services_include:
|
||||
kernel-headers: true
|
||||
ssh_authorized_keys:
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC85w9stZyiLQp/DkVO6fqwiShYcj1ClKdtCqgHtf+PLpJkFReSFu8y21y+ev09gsSMRRrjF7yt0pUHV6zncQhVeqsZtgc5WbELY2DOYUGmRn/CCvPbXovoBrQjSorqlBmpuPwsStYLr92Xn+VVsMNSUIegHY22DphGbDKG85vrKB8HxUxGIDxFBds/uE8FhSy+xsoyT/jUZDK6pgq2HnGl6D81ViIlKecpOpWlW3B+fea99ADNyZNVvDzbHE5pcI3VRw8u59WmpWOUgT6qacNVACl8GqpBvQk8sw7O/X9DSZHCKafeD9G5k+GYbAUz92fKWrx/lOXfUXPS3+c8dRIF
|
||||
@@ -5,5 +5,8 @@ write_files:
|
||||
- path: /home/rancher/test
|
||||
mounts:
|
||||
- ["/test", "/home/rancher/test", "", "bind"]
|
||||
- [/dev/vdb, /home/rancher/a, ext4, ""]
|
||||
- [/dev/vdb, /home/rancher/b, "", ""]
|
||||
- [/dev/vdb, /home/rancher/c, auto, defaults]
|
||||
ssh_authorized_keys:
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC85w9stZyiLQp/DkVO6fqwiShYcj1ClKdtCqgHtf+PLpJkFReSFu8y21y+ev09gsSMRRrjF7yt0pUHV6zncQhVeqsZtgc5WbELY2DOYUGmRn/CCvPbXovoBrQjSorqlBmpuPwsStYLr92Xn+VVsMNSUIegHY22DphGbDKG85vrKB8HxUxGIDxFBds/uE8FhSy+xsoyT/jUZDK6pgq2HnGl6D81ViIlKecpOpWlW3B+fea99ADNyZNVvDzbHE5pcI3VRw8u59WmpWOUgT6qacNVACl8GqpBvQk8sw7O/X9DSZHCKafeD9G5k+GYbAUz92fKWrx/lOXfUXPS3+c8dRIF
|
||||
30
tests/assets/test_24/cloud-config.yml
Normal file
30
tests/assets/test_24/cloud-config.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
#cloud-config
|
||||
write_files:
|
||||
- path: "/test"
|
||||
permissions: "0644"
|
||||
owner: "root"
|
||||
content: |
|
||||
console content
|
||||
- path: "/test2"
|
||||
container: console
|
||||
permissions: "0644"
|
||||
owner: "root"
|
||||
content: |
|
||||
console content
|
||||
- path: "/test"
|
||||
container: ntp
|
||||
permissions: "0644"
|
||||
owner: "root"
|
||||
content: |
|
||||
ntp content
|
||||
- path: "/test"
|
||||
container: syslog
|
||||
permissions: "0644"
|
||||
owner: "root"
|
||||
content: |
|
||||
syslog content
|
||||
rancher:
|
||||
restart_services: [syslog]
|
||||
ssh_authorized_keys:
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC85w9stZyiLQp/DkVO6fqwiShYcj1ClKdtCqgHtf+PLpJkFReSFu8y21y+ev09gsSMRRrjF7yt0pUHV6zncQhVeqsZtgc5WbELY2DOYUGmRn/CCvPbXovoBrQjSorqlBmpuPwsStYLr92Xn+VVsMNSUIegHY22DphGbDKG85vrKB8HxUxGIDxFBds/uE8FhSy+xsoyT/jUZDK6pgq2HnGl6D81ViIlKecpOpWlW3B+fea99ADNyZNVvDzbHE5pcI3VRw8u59WmpWOUgT6qacNVACl8GqpBvQk8sw7O/X9DSZHCKafeD9G5k+GYbAUz92fKWrx/lOXfUXPS3+c8dRIF
|
||||
|
||||
7
tests/assets/test_25/cloud-config.yml
Normal file
7
tests/assets/test_25/cloud-config.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
#cloud-config
|
||||
rancher:
|
||||
console: debian
|
||||
docker:
|
||||
engine: docker-1.10.3
|
||||
ssh_authorized_keys:
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC85w9stZyiLQp/DkVO6fqwiShYcj1ClKdtCqgHtf+PLpJkFReSFu8y21y+ev09gsSMRRrjF7yt0pUHV6zncQhVeqsZtgc5WbELY2DOYUGmRn/CCvPbXovoBrQjSorqlBmpuPwsStYLr92Xn+VVsMNSUIegHY22DphGbDKG85vrKB8HxUxGIDxFBds/uE8FhSy+xsoyT/jUZDK6pgq2HnGl6D81ViIlKecpOpWlW3B+fea99ADNyZNVvDzbHE5pcI3VRw8u59WmpWOUgT6qacNVACl8GqpBvQk8sw7O/X9DSZHCKafeD9G5k+GYbAUz92fKWrx/lOXfUXPS3+c8dRIF
|
||||
30
tests/assets/test_26/cloud-config.yml
Normal file
30
tests/assets/test_26/cloud-config.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
#cloud-config
|
||||
write_files:
|
||||
- path: /usr/bin/test
|
||||
permissions: "0755"
|
||||
owner: root
|
||||
content: |
|
||||
#!/bin/bash
|
||||
touch /home/rancher/test1
|
||||
- path: /opt/rancher/bin/start.sh
|
||||
permissions: "0755"
|
||||
owner: root
|
||||
content: |
|
||||
touch /home/rancher/test3
|
||||
- path: /etc/rc.local
|
||||
permissions: "0755"
|
||||
owner: root
|
||||
content: |
|
||||
touch /home/rancher/test4
|
||||
- path: /var/lib/rancher/conf/cloud-config-script
|
||||
permissions: "0755"
|
||||
owner: root
|
||||
content: |
|
||||
#!/bin/bash
|
||||
touch /home/rancher/test5
|
||||
runcmd:
|
||||
- []
|
||||
- [ test ]
|
||||
- [ touch, /home/rancher/test2 ]
|
||||
ssh_authorized_keys:
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC85w9stZyiLQp/DkVO6fqwiShYcj1ClKdtCqgHtf+PLpJkFReSFu8y21y+ev09gsSMRRrjF7yt0pUHV6zncQhVeqsZtgc5WbELY2DOYUGmRn/CCvPbXovoBrQjSorqlBmpuPwsStYLr92Xn+VVsMNSUIegHY22DphGbDKG85vrKB8HxUxGIDxFBds/uE8FhSy+xsoyT/jUZDK6pgq2HnGl6D81ViIlKecpOpWlW3B+fea99ADNyZNVvDzbHE5pcI3VRw8u59WmpWOUgT6qacNVACl8GqpBvQk8sw7O/X9DSZHCKafeD9G5k+GYbAUz92fKWrx/lOXfUXPS3+c8dRIF
|
||||
11
tests/cloud_config_hostname_test.go
Normal file
11
tests/cloud_config_hostname_test.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package integration
|
||||
|
||||
import . "gopkg.in/check.v1"
|
||||
|
||||
func (s *QemuSuite) TestCloudConfigHostname(c *C) {
|
||||
err := s.RunQemu("--cloud-config", "./tests/assets/test_13/cloud-config.yml")
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
s.CheckCall(c, "hostname | grep rancher-test")
|
||||
s.CheckCall(c, "cat /etc/hosts | grep rancher-test")
|
||||
}
|
||||
117
tests/common_test.go
Normal file
117
tests/common_test.go
Normal file
@@ -0,0 +1,117 @@
|
||||
package integration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
. "gopkg.in/check.v1"
|
||||
)
|
||||
|
||||
func Test(t *testing.T) { TestingT(t) }
|
||||
|
||||
func init() {
|
||||
Suite(&QemuSuite{
|
||||
runCommand: "../scripts/run",
|
||||
sshCommand: "../scripts/ssh",
|
||||
})
|
||||
}
|
||||
|
||||
var (
|
||||
BusyboxImage = map[string]string{
|
||||
"amd64": "busybox",
|
||||
"arm": "armhf/busybox",
|
||||
"arm64": "aarch64/busybox",
|
||||
}[runtime.GOARCH]
|
||||
NginxImage = map[string]string{
|
||||
"amd64": "nginx",
|
||||
"arm": "armhfbuild/nginx",
|
||||
"arm64": "armhfbuild/nginx",
|
||||
}[runtime.GOARCH]
|
||||
DockerUrl = "https://experimental.docker.com/builds/Linux/x86_64/docker-1.10.0-dev"
|
||||
Version = os.Getenv("VERSION")
|
||||
Suffix = os.Getenv("SUFFIX")
|
||||
)
|
||||
|
||||
type QemuSuite struct {
|
||||
runCommand string
|
||||
sshCommand string
|
||||
qemuCmd *exec.Cmd
|
||||
}
|
||||
|
||||
func (s *QemuSuite) TearDownTest(c *C) {
|
||||
c.Assert(s.qemuCmd.Process.Kill(), IsNil)
|
||||
time.Sleep(time.Millisecond * 1000)
|
||||
}
|
||||
|
||||
func (s *QemuSuite) RunQemu(additionalArgs ...string) error {
|
||||
runArgs := []string{
|
||||
"--qemu",
|
||||
"--no-rebuild",
|
||||
"--no-rm-usr",
|
||||
"--fresh",
|
||||
}
|
||||
runArgs = append(runArgs, additionalArgs...)
|
||||
|
||||
s.qemuCmd = exec.Command(s.runCommand, runArgs...)
|
||||
s.qemuCmd.Stdout = os.Stdout
|
||||
s.qemuCmd.Stderr = os.Stderr
|
||||
if err := s.qemuCmd.Start(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return s.WaitForSSH()
|
||||
}
|
||||
|
||||
func (s *QemuSuite) WaitForSSH() error {
|
||||
sshArgs := []string{
|
||||
"--qemu",
|
||||
"docker",
|
||||
"version",
|
||||
">/dev/null",
|
||||
"2>&1",
|
||||
}
|
||||
|
||||
var err error
|
||||
for i := 0; i < 300; i++ {
|
||||
cmd := exec.Command(s.sshCommand, sshArgs...)
|
||||
if err = cmd.Run(); err == nil {
|
||||
return nil
|
||||
}
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
}
|
||||
|
||||
return fmt.Errorf("Failed to connect to SSH: %v", err)
|
||||
}
|
||||
|
||||
func (s *QemuSuite) MakeCall(additionalArgs ...string) error {
|
||||
sshArgs := []string{
|
||||
"--qemu",
|
||||
}
|
||||
sshArgs = append(sshArgs, additionalArgs...)
|
||||
|
||||
cmd := exec.Command(s.sshCommand, sshArgs...)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
return cmd.Run()
|
||||
}
|
||||
|
||||
func (s *QemuSuite) CheckCall(c *C, additionalArgs ...string) {
|
||||
c.Assert(s.MakeCall(additionalArgs...), IsNil)
|
||||
}
|
||||
|
||||
func (s *QemuSuite) Reboot(c *C) {
|
||||
s.MakeCall("sudo reboot")
|
||||
time.Sleep(3000 * time.Millisecond)
|
||||
c.Assert(s.WaitForSSH(), IsNil)
|
||||
}
|
||||
|
||||
func (s *QemuSuite) LoadInstallerImage(c *C) {
|
||||
cmd := exec.Command("sh", "-c", fmt.Sprintf("docker save rancher/os:%s%s | ../scripts/ssh --qemu sudo system-docker load", Version, Suffix))
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
c.Assert(cmd.Run(), IsNil)
|
||||
}
|
||||
55
tests/consoles_test.go
Normal file
55
tests/consoles_test.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package integration
|
||||
|
||||
import . "gopkg.in/check.v1"
|
||||
|
||||
func (s *QemuSuite) TestCloudConfigConsole(c *C) {
|
||||
err := s.RunQemu("--cloud-config", "./tests/assets/test_03/cloud-config.yml")
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
s.CheckCall(c, "apt-get --version")
|
||||
s.CheckCall(c, `
|
||||
sudo ros console list | grep default | grep disabled
|
||||
sudo ros console list | grep debian | grep current`)
|
||||
}
|
||||
|
||||
func (s *QemuSuite) TestConsoleCommand(c *C) {
|
||||
err := s.RunQemu()
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
s.CheckCall(c, `
|
||||
sudo ros console list | grep default | grep current
|
||||
sudo ros console list | grep debian | grep disabled`)
|
||||
|
||||
s.MakeCall("sudo ros console switch -f debian")
|
||||
c.Assert(s.WaitForSSH(), IsNil)
|
||||
|
||||
s.CheckCall(c, "apt-get --version")
|
||||
s.CheckCall(c, `
|
||||
sudo ros console list | grep default | grep disabled
|
||||
sudo ros console list | grep debian | grep current`)
|
||||
|
||||
s.Reboot(c)
|
||||
|
||||
s.CheckCall(c, "apt-get --version")
|
||||
s.CheckCall(c, `
|
||||
sudo ros console list | grep default | grep disabled
|
||||
sudo ros console list | grep debian | grep current`)
|
||||
|
||||
s.MakeCall("sudo ros console switch -f default")
|
||||
c.Assert(s.WaitForSSH(), IsNil)
|
||||
|
||||
s.CheckCall(c, `
|
||||
sudo ros console list | grep default | grep current
|
||||
sudo ros console list | grep debian | grep disabled`)
|
||||
|
||||
s.CheckCall(c, "sudo ros console enable debian")
|
||||
|
||||
s.CheckCall(c, "sudo ros console list | grep default | grep current")
|
||||
s.CheckCall(c, "sudo ros console list | grep debian | grep enabled")
|
||||
|
||||
s.Reboot(c)
|
||||
|
||||
s.CheckCall(c, `
|
||||
sudo ros console list | grep default | grep disabled
|
||||
sudo ros console list | grep debian | grep current`)
|
||||
}
|
||||
67
tests/custom_docker_test.go
Normal file
67
tests/custom_docker_test.go
Normal file
@@ -0,0 +1,67 @@
|
||||
package integration
|
||||
|
||||
import . "gopkg.in/check.v1"
|
||||
|
||||
func (s *QemuSuite) TestCustomDocker(c *C) {
|
||||
err := s.RunQemu("--cloud-config", "./tests/assets/test_05/cloud-config.yml")
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
s.CheckCall(c, `
|
||||
set -ex
|
||||
|
||||
docker version | grep 1.10.3
|
||||
|
||||
sudo ros engine list | grep 1.10.3 | grep current
|
||||
docker run -d --restart=always nginx
|
||||
docker ps | grep nginx`)
|
||||
|
||||
s.CheckCall(c, `
|
||||
set -ex
|
||||
|
||||
sudo ros engine switch docker-1.11.2
|
||||
/usr/sbin/wait-for-docker
|
||||
docker version | grep 1.11.2
|
||||
sudo ros engine list | grep 1.11.2 | grep current
|
||||
docker ps | grep nginx`)
|
||||
|
||||
s.Reboot(c)
|
||||
|
||||
s.CheckCall(c, `
|
||||
set -ex
|
||||
|
||||
docker version | grep 1.11.2
|
||||
sudo ros engine list | grep 1.11.2 | grep current
|
||||
docker ps | grep nginx`)
|
||||
}
|
||||
|
||||
func (s *QemuSuite) TestCustomDockerInPersistentConsole(c *C) {
|
||||
err := s.RunQemu("--cloud-config", "./tests/assets/test_25/cloud-config.yml")
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
s.CheckCall(c, `
|
||||
set -ex
|
||||
|
||||
apt-get --version
|
||||
docker version | grep 1.10.3
|
||||
sudo ros engine list | grep 1.10.3 | grep current
|
||||
docker run -d --restart=always nginx
|
||||
docker ps | grep nginx`)
|
||||
|
||||
s.CheckCall(c, `
|
||||
set -ex
|
||||
|
||||
sudo ros engine switch docker-1.11.2
|
||||
/usr/sbin/wait-for-docker
|
||||
docker version | grep 1.11.2
|
||||
sudo ros engine list | grep 1.11.2 | grep current
|
||||
docker ps | grep nginx`)
|
||||
|
||||
s.Reboot(c)
|
||||
|
||||
s.CheckCall(c, `
|
||||
set -ex
|
||||
|
||||
docker version | grep 1.11.2
|
||||
sudo ros engine list | grep 1.11.2 | grep current
|
||||
docker ps | grep nginx`)
|
||||
}
|
||||
11
tests/dhcp_hostname_test.go
Normal file
11
tests/dhcp_hostname_test.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package integration
|
||||
|
||||
import . "gopkg.in/check.v1"
|
||||
|
||||
func (s *QemuSuite) TestDhcpHostname(c *C) {
|
||||
err := s.RunQemu("--cloud-config", "./tests/assets/test_12/cloud-config.yml")
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
s.CheckCall(c, "hostname | grep rancher-dev")
|
||||
s.CheckCall(c, "cat /etc/hosts | grep rancher-dev")
|
||||
}
|
||||
12
tests/environment_test.go
Normal file
12
tests/environment_test.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package integration
|
||||
|
||||
import . "gopkg.in/check.v1"
|
||||
|
||||
func (s *QemuSuite) TestEnvironment(c *C) {
|
||||
err := s.RunQemu("--cloud-config", "./tests/assets/test_11/cloud-config.yml")
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
s.CheckCall(c, "sudo system-docker inspect env | grep A=A")
|
||||
s.CheckCall(c, "sudo system-docker inspect env | grep BB=BB")
|
||||
s.CheckCall(c, "sudo system-docker inspect env | grep BC=BC")
|
||||
}
|
||||
32
tests/http_proxy_test.go
Normal file
32
tests/http_proxy_test.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package integration
|
||||
|
||||
import . "gopkg.in/check.v1"
|
||||
|
||||
func (s *QemuSuite) TestHttpProxy(c *C) {
|
||||
err := s.RunQemu("--cloud-config", "./tests/assets/test_17/cloud-config.yml")
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
s.CheckCall(c, `
|
||||
set -x -e
|
||||
|
||||
sudo system-docker inspect docker env | grep HTTP_PROXY=invalid
|
||||
sudo system-docker inspect docker env | grep HTTPS_PROXY=invalid
|
||||
sudo system-docker inspect docker env | grep NO_PROXY=invalid
|
||||
|
||||
if docker pull busybox; then
|
||||
exit 1
|
||||
else
|
||||
exit 0
|
||||
fi`)
|
||||
|
||||
s.Reboot(c)
|
||||
|
||||
s.CheckCall(c, `
|
||||
set -x -e
|
||||
|
||||
if sudo system-docker pull busybox; then
|
||||
exit 1
|
||||
else
|
||||
exit 0
|
||||
fi`)
|
||||
}
|
||||
18
tests/install_test.go
Normal file
18
tests/install_test.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package integration
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
. "gopkg.in/check.v1"
|
||||
)
|
||||
|
||||
func (s *QemuSuite) TestInstall(c *C) {
|
||||
err := s.RunQemu("--no-format")
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
s.LoadInstallerImage(c)
|
||||
|
||||
s.CheckCall(c, fmt.Sprintf(`
|
||||
sudo mkfs.ext4 /dev/vda
|
||||
sudo ros install -f --no-reboot -d /dev/vda -i rancher/os:%s%s`, Version, Suffix))
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
RancherOS Integration Tests
|
||||
@@ -1,27 +0,0 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEpAIBAAKCAQEA1JbFgC+UX9ForPwO5O05asdH2UutFcwmaz2WGz/8JC/eY79F
|
||||
8wsfG3da2R3sm25RzwzaTQ9wS7+Kj2OQ8UcnsReLHhrs3CSP6TrxlBo0KJ3XjD4A
|
||||
0xRKOcPd/YEnXk2XH180NMAFYc8A24B+Mz3zM23aKPAIrvY5CpY18PCBY7tIIfre
|
||||
oipBmQiIyk/aO882tbxn5KHYb4tld1cz3TTtvIGsWWkTbZgWFKFZxskep1zdUNwi
|
||||
WlboeaOhjwjqq4RzW2DhWSgaQ4h28T4VacR0A9vvMlEhkxu1lu+RX2Xj42ucvHdH
|
||||
PzuS9+2WMeAGQHdyoEGAwU9lwhCRkDWsDW36bQIDAQABAoIBAE9NGslxdji0BgcZ
|
||||
U3kEIPn68otVVnCeIeq5I4hwut7I2H1++VnrWSRGxqXdKsjkQzIoSjqauroW7loE
|
||||
uym18FF4RdXqF1cbcG+BJGKpz7EjCCfxbR9QH0wjC2koR4Y/DVOPkQroYlmU/W3k
|
||||
Ja95uYICxXGl8KdLhAW1+NMy9CE+KmEc0j+7hkpTrmK1yfv4zT/jc2VjcF7jEV7s
|
||||
sBN2OT6LwFixfJd4SWU8V50DWrzU64qhwKGCQtmCZX3Ym9vRd6KUoWd8jnwuN+KV
|
||||
RttuqFCSrLw86TaUfgqnlF8lt2Dno2NAz5eyP/yq6m8SQ7pK5nVz1CXPXp24M5DW
|
||||
9mWWa0UCgYEA65YecXBRTkgIvFo8yJj8DmmKQKVfe1OI6qKIVXzY2Dmzd+NE+WKJ
|
||||
h1AKajZBKEHMILnPEtEMB226A0Sl1VsTY+dhDSsk34sgsP7zpbFI3S2ZzJMEkwoh
|
||||
thQ9ihegzt+gn/hiHwaanYjuwELx0h+nIIinSph7aBA66yeisfPU/LsCgYEA5wKD
|
||||
VIHdE3dDSpCDhuZefZpRQvTsP13XGoYU7IL0cFrTKL00CVzCAEEG2QPzJGro1KM5
|
||||
+IRUf68G0C9z9MY+fPRY6/BLEKiV+S+sfPhlbxLg9IxJSO952advEpJWYYZHnh/d
|
||||
SuXfglSLjWra3VgLh6aho9/jQ7+7enrEru3JRvcCgYEAuo3484mmyN+gE0893PfQ
|
||||
ebU3prOOJcHjpTIp1dB0gt1GcgSFpRpTn9RROwRVmoRoGe4pvVPPO763U0k0LPzf
|
||||
IPij0OK+Y0rwC1kJJcd61LL8nJQ7Rhj60w26IbVOQSOzNZpiUQFQxLkfnx4kEmnA
|
||||
VbIBD8Ap0SExFvAfFN3qZmsCgYA8c53meW1e8LC9TH/+xz4m5EEromhIVMg7eqbz
|
||||
FXneBQaI/KonYQyrgFjIZY41E30GWAiNjiOGnkjMJf7UKSSlElRKucELBPLqGJ2s
|
||||
vlvc6zXPCP8MhQ5/9J7OX1kXgEoxiOkh9nG8617xjOrlTWsG/oYCGk6gpgXrkUDy
|
||||
/erUFQKBgQDY8h3pTIC3ZvFcy0+UpvVMceLWfaP9+/8dTpAr0HClNOjQC0Fuq6cV
|
||||
nazAREnDB62y4keGV5xcZdHQ9bZBR4dq4h1oFQUq7RJr5fsgaxN13JPJht2xf/ra
|
||||
hK3WKZN5oa/hrRu5m+z9rOwR4T7B863cBs/b1YNj3eKUIakHJEv5xw==
|
||||
-----END RSA PRIVATE KEY-----
|
||||
@@ -1,5 +0,0 @@
|
||||
#cloud-config
|
||||
rancher:
|
||||
console: debian
|
||||
ssh_authorized_keys:
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDUlsWAL5Rf0Wis/A7k7Tlqx0fZS60VzCZrPZYbP/wkL95jv0XzCx8bd1rZHeybblHPDNpND3BLv4qPY5DxRyexF4seGuzcJI/pOvGUGjQondeMPgDTFEo5w939gSdeTZcfXzQ0wAVhzwDbgH4zPfMzbdoo8Aiu9jkKljXw8IFju0gh+t6iKkGZCIjKT9o7zza1vGfkodhvi2V3VzPdNO28gaxZaRNtmBYUoVnGyR6nXN1Q3CJaVuh5o6GPCOqrhHNbYOFZKBpDiHbxPhVpxHQD2+8yUSGTG7WW75FfZePja5y8d0c/O5L37ZYx4AZAd3KgQYDBT2XCEJGQNawNbfpt
|
||||
@@ -1,5 +0,0 @@
|
||||
#cloud-config
|
||||
rancher:
|
||||
console: debian
|
||||
ssh_authorized_keys:
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDUlsWAL5Rf0Wis/A7k7Tlqx0fZS60VzCZrPZYbP/wkL95jv0XzCx8bd1rZHeybblHPDNpND3BLv4qPY5DxRyexF4seGuzcJI/pOvGUGjQondeMPgDTFEo5w939gSdeTZcfXzQ0wAVhzwDbgH4zPfMzbdoo8Aiu9jkKljXw8IFju0gh+t6iKkGZCIjKT9o7zza1vGfkodhvi2V3VzPdNO28gaxZaRNtmBYUoVnGyR6nXN1Q3CJaVuh5o6GPCOqrhHNbYOFZKBpDiHbxPhVpxHQD2+8yUSGTG7WW75FfZePja5y8d0c/O5L37ZYx4AZAd3KgQYDBT2XCEJGQNawNbfpt
|
||||
@@ -1,18 +0,0 @@
|
||||
#cloud-config
|
||||
rancher:
|
||||
environment:
|
||||
A: A
|
||||
BB: BB
|
||||
BC: BC
|
||||
services:
|
||||
env:
|
||||
image: busybox
|
||||
command: env
|
||||
labels:
|
||||
io.rancher.os.scope: system
|
||||
io.rancher.os.before: console
|
||||
environment:
|
||||
- A
|
||||
- B*
|
||||
ssh_authorized_keys:
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDUlsWAL5Rf0Wis/A7k7Tlqx0fZS60VzCZrPZYbP/wkL95jv0XzCx8bd1rZHeybblHPDNpND3BLv4qPY5DxRyexF4seGuzcJI/pOvGUGjQondeMPgDTFEo5w939gSdeTZcfXzQ0wAVhzwDbgH4zPfMzbdoo8Aiu9jkKljXw8IFju0gh+t6iKkGZCIjKT9o7zza1vGfkodhvi2V3VzPdNO28gaxZaRNtmBYUoVnGyR6nXN1Q3CJaVuh5o6GPCOqrhHNbYOFZKBpDiHbxPhVpxHQD2+8yUSGTG7WW75FfZePja5y8d0c/O5L37ZYx4AZAd3KgQYDBT2XCEJGQNawNbfpt
|
||||
@@ -1,3 +0,0 @@
|
||||
#cloud-config
|
||||
ssh_authorized_keys:
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDUlsWAL5Rf0Wis/A7k7Tlqx0fZS60VzCZrPZYbP/wkL95jv0XzCx8bd1rZHeybblHPDNpND3BLv4qPY5DxRyexF4seGuzcJI/pOvGUGjQondeMPgDTFEo5w939gSdeTZcfXzQ0wAVhzwDbgH4zPfMzbdoo8Aiu9jkKljXw8IFju0gh+t6iKkGZCIjKT9o7zza1vGfkodhvi2V3VzPdNO28gaxZaRNtmBYUoVnGyR6nXN1Q3CJaVuh5o6GPCOqrhHNbYOFZKBpDiHbxPhVpxHQD2+8yUSGTG7WW75FfZePja5y8d0c/O5L37ZYx4AZAd3KgQYDBT2XCEJGQNawNbfpt
|
||||
@@ -1,4 +0,0 @@
|
||||
#cloud-config
|
||||
hostname: rancher-test
|
||||
ssh_authorized_keys:
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDUlsWAL5Rf0Wis/A7k7Tlqx0fZS60VzCZrPZYbP/wkL95jv0XzCx8bd1rZHeybblHPDNpND3BLv4qPY5DxRyexF4seGuzcJI/pOvGUGjQondeMPgDTFEo5w939gSdeTZcfXzQ0wAVhzwDbgH4zPfMzbdoo8Aiu9jkKljXw8IFju0gh+t6iKkGZCIjKT9o7zza1vGfkodhvi2V3VzPdNO28gaxZaRNtmBYUoVnGyR6nXN1Q3CJaVuh5o6GPCOqrhHNbYOFZKBpDiHbxPhVpxHQD2+8yUSGTG7WW75FfZePja5y8d0c/O5L37ZYx4AZAd3KgQYDBT2XCEJGQNawNbfpt
|
||||
@@ -1,2 +0,0 @@
|
||||
PyYAML==3.11
|
||||
pytest==2.7.2
|
||||
@@ -1,13 +0,0 @@
|
||||
import subprocess
|
||||
|
||||
import os
|
||||
import pytest
|
||||
import rostest
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def chdir_to_project_root():
|
||||
os.chdir(os.path.join(os.path.dirname(rostest.__file__), '../../..'))
|
||||
print('\nChdir to project root dir: ' + subprocess.check_output('pwd'))
|
||||
os.chmod('./tests/integration/assets/test.key', 0o600)
|
||||
print('Also, `chmod 600 tests/integration/assets/test.key` to make ssh happy')
|
||||
@@ -1,49 +0,0 @@
|
||||
from __future__ import print_function
|
||||
|
||||
import subprocess
|
||||
|
||||
import pytest
|
||||
import rostest.util as u
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def qemu(request):
|
||||
return u.run_qemu(request)
|
||||
|
||||
|
||||
@pytest.mark.timeout(30)
|
||||
def test_system_boot(qemu):
|
||||
u.flush_out(qemu.stdout)
|
||||
|
||||
|
||||
busybox = {'amd64': 'busybox', 'arm': 'armhf/busybox', 'arm64': 'aarch64/busybox'}
|
||||
|
||||
|
||||
@pytest.mark.timeout(60)
|
||||
def test_run_system_container(qemu):
|
||||
u.wait_for_ssh(qemu)
|
||||
|
||||
ssh = subprocess.Popen(
|
||||
'./scripts/ssh --qemu sudo system-docker run --rm ' + busybox[u.arch] + ' /bin/true',
|
||||
shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
|
||||
|
||||
for ln in u.iter_lines(ssh.stdout):
|
||||
print(ln)
|
||||
ssh.wait()
|
||||
|
||||
assert ssh.returncode == 0
|
||||
|
||||
|
||||
@pytest.mark.timeout(60)
|
||||
def test_ros_dev(qemu):
|
||||
u.wait_for_ssh(qemu)
|
||||
|
||||
ssh = subprocess.Popen(
|
||||
'./scripts/ssh --qemu sudo ros dev',
|
||||
shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
|
||||
|
||||
for ln in u.iter_lines(ssh.stdout):
|
||||
print(ln)
|
||||
ssh.wait()
|
||||
|
||||
assert ssh.returncode == 0
|
||||
@@ -1,103 +0,0 @@
|
||||
import string
|
||||
|
||||
import pytest
|
||||
import rostest.util as u
|
||||
from rostest.util import SSH
|
||||
import yaml
|
||||
|
||||
ssh_command = ['./scripts/ssh', '--qemu', '--key', './tests/integration/assets/test.key']
|
||||
cloud_config_path = './tests/integration/assets/test_01/cloud-config.yml'
|
||||
|
||||
|
||||
net_args = {'amd64': ['-net', 'nic,vlan=1,model=virtio,macaddr=52:54:00:12:34:59',
|
||||
'-net', 'user,vlan=1,net=10.10.2.0/24'],
|
||||
'arm64': ['-netdev', 'user,id=net1,net=10.10.2.0/24',
|
||||
'-device', 'virtio-net-device,netdev=net1,mac=52:54:00:12:34:59']}
|
||||
net_args['arm'] = net_args['arm64']
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def qemu(request):
|
||||
q = u.run_qemu(request, ['--cloud-config', cloud_config_path] + net_args[u.arch])
|
||||
u.flush_out(q.stdout)
|
||||
return q
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def cloud_config():
|
||||
return yaml.load(open(cloud_config_path))
|
||||
|
||||
|
||||
@pytest.mark.timeout(40)
|
||||
def test_ssh_authorized_keys(qemu):
|
||||
u.wait_for_ssh(qemu, ssh_command)
|
||||
assert True
|
||||
|
||||
|
||||
@pytest.mark.timeout(40)
|
||||
def test_rancher_environment(qemu, cloud_config):
|
||||
v = SSH(qemu, ssh_command).check_output('''
|
||||
sudo ros env printenv FLANNEL_NETWORK
|
||||
'''.strip())
|
||||
|
||||
assert v.strip() == cloud_config['rancher']['environment']['FLANNEL_NETWORK']
|
||||
|
||||
|
||||
@pytest.mark.timeout(40)
|
||||
def test_docker_args(qemu, cloud_config):
|
||||
v = SSH(qemu, ssh_command).check_output('''
|
||||
ps -ef | grep docker
|
||||
'''.strip())
|
||||
|
||||
expected = string.join(cloud_config['rancher']['docker']['args'])
|
||||
|
||||
assert v.find(expected) != -1
|
||||
|
||||
|
||||
@pytest.mark.timeout(40)
|
||||
def test_dhcpcd(qemu, cloud_config):
|
||||
v = SSH(qemu, ssh_command).check_output('''
|
||||
ps -ef | grep dhcpcd
|
||||
'''.strip())
|
||||
|
||||
assert v.find('dhcpcd -M') != -1
|
||||
|
||||
|
||||
@pytest.mark.timeout(40)
|
||||
def test_services_include(qemu, cloud_config):
|
||||
u.wait_for_ssh(qemu, ssh_command, ['docker inspect kernel-headers >/dev/null 2>&1'])
|
||||
|
||||
|
||||
@pytest.mark.timeout(40)
|
||||
def test_docker_tls_args(qemu, cloud_config):
|
||||
SSH(qemu, ssh_command).check_call('''
|
||||
set -e -x
|
||||
sudo ros tls gen --server -H localhost
|
||||
sudo ros tls gen
|
||||
sudo ros c set rancher.docker.tls true
|
||||
sudo system-docker restart docker
|
||||
sleep 5
|
||||
docker --tlsverify version
|
||||
'''.strip())
|
||||
|
||||
|
||||
@pytest.mark.timeout(40)
|
||||
def test_rancher_network(qemu, cloud_config):
|
||||
v = SSH(qemu, ssh_command).check_output('''
|
||||
ip route get to 10.10.2.120
|
||||
'''.strip())
|
||||
|
||||
assert v.split(' ')[5] + '/24' == \
|
||||
cloud_config['rancher']['network']['interfaces']['mac=52:54:00:12:34:59']['address']
|
||||
|
||||
|
||||
def test_docker_pid_one(qemu):
|
||||
SSH(qemu, ssh_command).check_call('''
|
||||
set -e -x
|
||||
for i in $(pidof docker); do
|
||||
if [ $i = 1 ]; then
|
||||
found=true
|
||||
fi
|
||||
done
|
||||
[ "$found" = "true" ]
|
||||
'''.strip())
|
||||
@@ -1,22 +0,0 @@
|
||||
import pytest
|
||||
import rostest.util as u
|
||||
from rostest.util import SSH
|
||||
|
||||
ssh_command = ['./scripts/ssh', '--qemu', '--key', './tests/integration/assets/test.key']
|
||||
cloud_config_path = './tests/integration/assets/test_02/cloud-config.yml'
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def qemu(request):
|
||||
q = u.run_qemu(request, ['--cloud-config', cloud_config_path])
|
||||
u.flush_out(q.stdout)
|
||||
return q
|
||||
|
||||
|
||||
@pytest.mark.timeout(40)
|
||||
def test_docker_tls_args(qemu):
|
||||
SSH(qemu, ssh_command).check_call('''
|
||||
set -e -x
|
||||
sudo ros tls gen
|
||||
docker --tlsverify version
|
||||
'''.strip())
|
||||
@@ -1,38 +0,0 @@
|
||||
import time
|
||||
|
||||
import pytest
|
||||
import rostest.util as u
|
||||
from rostest.util import SSH
|
||||
|
||||
ssh_command = ['./scripts/ssh', '--qemu', '--key', './tests/integration/assets/test.key']
|
||||
cloud_config_path = './tests/integration/assets/test_03/cloud-config.yml'
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def qemu(request):
|
||||
q = u.run_qemu(request, ['--cloud-config', cloud_config_path])
|
||||
u.flush_out(q.stdout)
|
||||
return q
|
||||
|
||||
|
||||
nginx = {'amd64': 'nginx', 'arm': 'armhfbuild/nginx', 'arm64': 'armhfbuild/nginx'}
|
||||
|
||||
|
||||
@pytest.mark.timeout(40)
|
||||
def test_reboot_with_container_running(qemu):
|
||||
try:
|
||||
SSH(qemu, ssh_command).check_call('''
|
||||
set -ex
|
||||
docker run -d --restart=always %(image)s
|
||||
sudo reboot
|
||||
'''.strip() % {'image': nginx[u.arch]})
|
||||
except:
|
||||
pass
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
v = SSH(qemu, ssh_command).check_output('''
|
||||
docker ps -f status=running
|
||||
'''.strip())
|
||||
|
||||
assert v.find('nginx') != -1
|
||||
@@ -1,34 +0,0 @@
|
||||
import subprocess
|
||||
|
||||
import pytest
|
||||
import rostest.util as u
|
||||
from rostest.util import SSH
|
||||
|
||||
ssh_command = ['./scripts/ssh', '--qemu']
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def qemu(request):
|
||||
q = u.run_qemu(request, ['--no-format'])
|
||||
u.flush_out(q.stdout)
|
||||
return q
|
||||
|
||||
|
||||
@pytest.mark.timeout(40)
|
||||
def test_ros_install_on_formatted_disk(qemu):
|
||||
u.wait_for_ssh(qemu, ssh_command)
|
||||
|
||||
subprocess.check_call(
|
||||
['sh', '-c', 'docker save rancher/os:%s%s | ./scripts/ssh sudo system-docker load' % (u.version, u.suffix)],
|
||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
||||
|
||||
SSH(qemu, ssh_command).check_call('''
|
||||
set -e -x
|
||||
sudo mkfs.ext4 /dev/vda
|
||||
sudo ros install -f --no-reboot -d /dev/vda -i rancher/os:%s%s
|
||||
'''.strip() % (u.version, u.suffix))
|
||||
|
||||
subprocess.call(ssh_command + ['sudo', 'reboot'],
|
||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
||||
|
||||
u.wait_for_ssh(qemu, ssh_command)
|
||||
@@ -1,39 +0,0 @@
|
||||
import subprocess
|
||||
|
||||
import pytest
|
||||
import rostest.util as u
|
||||
|
||||
ssh_command = ['./scripts/ssh', '--qemu', '--key', './tests/integration/assets/test.key']
|
||||
cloud_config_path = './tests/integration/assets/test_05/cloud-config.yml'
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def qemu(request):
|
||||
q = u.run_qemu(request, ['--cloud-config', cloud_config_path])
|
||||
u.flush_out(q.stdout)
|
||||
return q
|
||||
|
||||
docker_url = {'amd64': 'https://experimental.docker.com/builds/Linux/x86_64/docker-1.10.0-dev',
|
||||
'arm': 'https://github.com/rancher/docker/releases/download/v1.10.3-arm/docker-1.10.3_arm',
|
||||
'arm64': 'https://github.com/rancher/docker/releases/download/v1.10.3-arm/docker-1.10.3_arm64'}
|
||||
|
||||
|
||||
@pytest.mark.timeout(40)
|
||||
def test_system_docker_survives_custom_docker_install(qemu):
|
||||
u.wait_for_ssh(qemu, ssh_command)
|
||||
subprocess.check_call(ssh_command + ['curl', '-Lfo', './docker', docker_url[u.arch]],
|
||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
||||
|
||||
subprocess.check_call(ssh_command + ['chmod', '+x', '/home/rancher/docker'],
|
||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
||||
|
||||
subprocess.check_call(ssh_command + ['sudo', 'ln', '-sf', '/home/rancher/docker', '/usr/bin/docker'],
|
||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
||||
|
||||
subprocess.check_call(ssh_command + ['sudo', 'system-docker', 'restart', 'docker'],
|
||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
||||
|
||||
subprocess.check_call(ssh_command + ['sudo', 'system-docker', 'version'],
|
||||
stderr=subprocess.STDOUT, universal_newlines=True)
|
||||
|
||||
u.wait_for_ssh(qemu, ssh_command)
|
||||
@@ -1,19 +0,0 @@
|
||||
import pytest
|
||||
import rostest.util as u
|
||||
from rostest.util import SSH
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def qemu(request):
|
||||
q = u.run_qemu(request, run_args=['--append', 'rancher.state.directory=ros_subdir'])
|
||||
u.flush_out(q.stdout)
|
||||
return q
|
||||
|
||||
|
||||
def test_system_docker_survives_custom_docker_install(qemu):
|
||||
SSH(qemu).check_call('''
|
||||
set -x -e
|
||||
mkdir x
|
||||
sudo mount $(sudo ros dev LABEL=RANCHER_STATE) x
|
||||
[ -d x/ros_subdir/home/rancher ]
|
||||
'''.strip())
|
||||
@@ -1,48 +0,0 @@
|
||||
import time
|
||||
import pytest
|
||||
import rostest.util as u
|
||||
from rostest.util import SSH
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def qemu(request):
|
||||
q = u.run_qemu(request, run_args=['--append', 'rancher.state.dev=x'])
|
||||
u.flush_out(q.stdout)
|
||||
return q
|
||||
|
||||
|
||||
def test_oem(qemu):
|
||||
try:
|
||||
SSH(qemu).check_call('''
|
||||
set -x
|
||||
set -e
|
||||
sudo mkfs.ext4 -L RANCHER_OEM /dev/vda
|
||||
sudo mount /dev/vda /mnt
|
||||
cat > /tmp/oem-config.yml << EOF
|
||||
#cloud-config
|
||||
rancher:
|
||||
upgrade:
|
||||
url: 'foo'
|
||||
EOF
|
||||
sudo cp /tmp/oem-config.yml /mnt
|
||||
sudo umount /mnt
|
||||
sudo reboot
|
||||
'''.strip())
|
||||
except:
|
||||
pass
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
SSH(qemu).check_call('''
|
||||
set -x
|
||||
if [ ! -e /usr/share/ros/oem/oem-config.yml ]; then
|
||||
echo Failed to find /usr/share/ros/oem/oem-config.yml
|
||||
exit 1
|
||||
fi
|
||||
|
||||
FOO="$(sudo ros config get rancher.upgrade.url)"
|
||||
if [ "$FOO" != "foo" ]; then
|
||||
echo rancher.upgrade.url is not foo
|
||||
exit 1
|
||||
fi
|
||||
'''.strip())
|
||||
@@ -1,50 +0,0 @@
|
||||
import pytest
|
||||
import rostest.util as u
|
||||
from rostest.util import SSH
|
||||
|
||||
pytestmark = pytest.mark.skipif(u.arch != 'amd64', reason='amd64 network setup impossible to replicate for arm64')
|
||||
|
||||
cloud_config_path = './tests/integration/assets/test_09/cloud-config.yml'
|
||||
|
||||
net_args_arch = {'amd64': ['-net', 'nic,vlan=0,model=virtio'],
|
||||
'arm64': ['-device', 'virtio-net-device']}
|
||||
net_args_arch['arm'] = net_args_arch['arm64']
|
||||
net_args = net_args_arch[u.arch]
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def qemu(request):
|
||||
q = u.run_qemu(request,
|
||||
run_args=['--cloud-config', cloud_config_path] +
|
||||
net_args + net_args + net_args + net_args + net_args + net_args + net_args)
|
||||
u.flush_out(q.stdout)
|
||||
return q
|
||||
|
||||
|
||||
def test_network_interfaces_conf(qemu):
|
||||
SSH(qemu).check_call('''cat > test-merge << "SCRIPT"
|
||||
set -x -e
|
||||
|
||||
ip link show dev br0
|
||||
ip link show dev br0.100 | grep br0.100@br0
|
||||
ip link show dev eth1.100 | grep 'master br0'
|
||||
ip link show dev eth6 | grep 'master bond0'
|
||||
ip link show dev eth7 | grep 'master bond0'
|
||||
[ "$(</sys/class/net/bond0/bonding/mode)" = "active-backup 1" ]
|
||||
|
||||
SCRIPT
|
||||
sudo bash test-merge
|
||||
'''.strip())
|
||||
|
||||
|
||||
def test_network_dns_conf(qemu):
|
||||
SSH(qemu).check_call('''cat > test-merge << "SCRIPT"
|
||||
set -x -e
|
||||
|
||||
cat /etc/resolv.conf | grep "search mydomain.com example.com"
|
||||
cat /etc/resolv.conf | grep "nameserver 208.67.222.123"
|
||||
cat /etc/resolv.conf | grep "nameserver 208.67.220.123"
|
||||
|
||||
SCRIPT
|
||||
sudo bash test-merge
|
||||
'''.strip())
|
||||
@@ -1,62 +0,0 @@
|
||||
import pytest
|
||||
import rostest.util as u
|
||||
from rostest.util import SSH
|
||||
|
||||
pytestmark = pytest.mark.skipif(u.arch != 'amd64', reason='amd64 network setup impossible to replicate for arm64')
|
||||
|
||||
cloud_config_path = './tests/integration/assets/test_10/cloud-config.yml'
|
||||
|
||||
net_args_arch = {'amd64': ['-net', 'nic,vlan=0,model=virtio'],
|
||||
'arm64': ['-device', 'virtio-net-device']}
|
||||
net_args_arch['arm'] = net_args_arch['arm64']
|
||||
net_args = net_args_arch[u.arch]
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def qemu(request):
|
||||
q = u.run_qemu(request,
|
||||
run_args=['--cloud-config', cloud_config_path] +
|
||||
net_args + net_args + net_args + net_args + net_args + net_args + net_args)
|
||||
u.flush_out(q.stdout)
|
||||
return q
|
||||
|
||||
|
||||
def test_network_interfaces_conf(qemu):
|
||||
SSH(qemu).check_call('''cat > test-merge << "SCRIPT"
|
||||
set -x -e
|
||||
|
||||
ip link show dev br0
|
||||
ip link show dev br0.100 | grep br0.100@br0
|
||||
ip link show dev eth1.100 | grep 'master br0'
|
||||
|
||||
SCRIPT
|
||||
sudo bash test-merge
|
||||
'''.strip())
|
||||
|
||||
|
||||
def test_network_dns_conf(qemu):
|
||||
SSH(qemu).check_call('''cat > test-merge << "SCRIPT"
|
||||
set -x -e
|
||||
|
||||
cat /etc/resolv.conf | grep "search mydomain.com example.com"
|
||||
cat /etc/resolv.conf | grep "nameserver 208.67.222.123"
|
||||
cat /etc/resolv.conf | grep "nameserver 208.67.220.123"
|
||||
|
||||
SCRIPT
|
||||
sudo bash test-merge
|
||||
'''.strip())
|
||||
|
||||
|
||||
def test_network_dns_ros_set(qemu):
|
||||
SSH(qemu).check_call('''
|
||||
set -x -e
|
||||
|
||||
sudo ros config set rancher.network.dns.search '[a,b]'
|
||||
if [ "$(sudo ros config get rancher.network.dns.search)" == "- a
|
||||
- b
|
||||
|
||||
" ]; then
|
||||
sudo ros config get rancher.network.dns.search
|
||||
exit 1
|
||||
fi
|
||||
'''.strip())
|
||||
@@ -1,24 +0,0 @@
|
||||
import pytest
|
||||
import rostest.util as u
|
||||
from rostest.util import SSH
|
||||
|
||||
ssh_command = ['./scripts/ssh', '--qemu', '--key', './tests/integration/assets/test.key']
|
||||
cloud_config_path = {'amd64': './tests/integration/assets/test_11/cloud-config.yml',
|
||||
'arm': './tests/integration/assets/test_11/cloud-config_arm.yml',
|
||||
'arm64': './tests/integration/assets/test_11/cloud-config_arm64.yml'}
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def qemu(request):
|
||||
q = u.run_qemu(request, ['--cloud-config', cloud_config_path[u.arch]])
|
||||
u.flush_out(q.stdout)
|
||||
return q
|
||||
|
||||
|
||||
@pytest.mark.timeout(40)
|
||||
def test_rancher_environment_in_system_service(qemu):
|
||||
SSH(qemu, ssh_command).check_call('''
|
||||
sudo system-docker logs env | grep A=A
|
||||
sudo system-docker logs env | grep BB=BB
|
||||
sudo system-docker logs env | grep BC=BC
|
||||
''')
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user