summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2017-03-16 17:17:10 +0100
committerGiuseppe Scrivano <gscrivan@redhat.com>2017-05-03 13:01:50 +0200
commit28c75e6e5c02ee0c796d378846c2ad8f7a3a8c22 (patch)
tree7d4ad768458e9636b35c15976414c69631af2524
parentba5c6594ade6679d055aaecc7c38836444f0f791 (diff)
downloadopenshift-28c75e6e5c02ee0c796d378846c2ad8f7a3a8c22.tar.gz
openshift-28c75e6e5c02ee0c796d378846c2ad8f7a3a8c22.tar.bz2
openshift-28c75e6e5c02ee0c796d378846c2ad8f7a3a8c22.tar.xz
openshift-28c75e6e5c02ee0c796d378846c2ad8f7a3a8c22.zip
installer: support running as a system container
Example: atomic install --system --set INVENTORY_FILE=$(pwd)/hosts.inventory \ --set SSH_ROOT=/root/.ssh \ --set PLAYBOOK_FILE=./playbooks/byo/config.yml openshift-ansible Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
-rw-r--r--Dockerfile3
-rw-r--r--Dockerfile.rhel73
-rw-r--r--system-container/root/exports/config.json.template213
-rw-r--r--system-container/root/exports/manifest.json10
-rw-r--r--system-container/root/exports/service.template6
-rw-r--r--system-container/root/exports/tmpfiles.template1
-rwxr-xr-xsystem-container/root/usr/local/bin/run-system-container.sh3
7 files changed, 239 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile
index eecf3630b..33ca69e1f 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -39,4 +39,7 @@ ADD . /tmp/src
# as per the INSTALL_OC environment setting above
RUN /usr/libexec/s2i/assemble
+# Add files for running as a system container
+COPY system-container/root /
+
CMD [ "/usr/libexec/s2i/run" ]
diff --git a/Dockerfile.rhel7 b/Dockerfile.rhel7
index c5a95f586..00841e660 100644
--- a/Dockerfile.rhel7
+++ b/Dockerfile.rhel7
@@ -39,4 +39,7 @@ ENV PLAYBOOK_FILE=playbooks/byo/openshift_facts.yml \
WORK_DIR=/usr/share/ansible/openshift-ansible \
OPTS="-v"
+# Add files for running as a system container
+COPY system-container/root /
+
CMD [ "/usr/libexec/s2i/run" ]
diff --git a/system-container/root/exports/config.json.template b/system-container/root/exports/config.json.template
new file mode 100644
index 000000000..ede2414c1
--- /dev/null
+++ b/system-container/root/exports/config.json.template
@@ -0,0 +1,213 @@
+{
+ "ociVersion": "1.0.0",
+ "platform": {
+ "os": "linux",
+ "arch": "amd64"
+ },
+ "process": {
+ "terminal": false,
+ "consoleSize": {
+ "height": 0,
+ "width": 0
+ },
+ "user": {
+ "uid": 0,
+ "gid": 0
+ },
+ "args": [
+ "/usr/local/bin/run-system-container.sh"
+ ],
+ "env": [
+ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
+ "TERM=xterm",
+ "OPTS=$OPTS",
+ "PLAYBOOK_FILE=$PLAYBOOK_FILE"
+ ],
+ "cwd": "/opt/app-root/src/",
+ "rlimits": [
+ {
+ "type": "RLIMIT_NOFILE",
+ "hard": 1024,
+ "soft": 1024
+ }
+ ],
+ "noNewPrivileges": true
+ },
+ "root": {
+ "path": "rootfs",
+ "readonly": true
+ },
+ "mounts": [
+ {
+ "destination": "/proc",
+ "type": "proc",
+ "source": "proc"
+ },
+ {
+ "destination": "/dev",
+ "type": "tmpfs",
+ "source": "tmpfs",
+ "options": [
+ "nosuid",
+ "strictatime",
+ "mode=755",
+ "size=65536k"
+ ]
+ },
+ {
+ "destination": "/dev/pts",
+ "type": "devpts",
+ "source": "devpts",
+ "options": [
+ "nosuid",
+ "noexec",
+ "newinstance",
+ "ptmxmode=0666",
+ "mode=0620",
+ "gid=5"
+ ]
+ },
+ {
+ "destination": "/dev/shm",
+ "type": "tmpfs",
+ "source": "shm",
+ "options": [
+ "nosuid",
+ "noexec",
+ "nodev",
+ "mode=1777",
+ "size=65536k"
+ ]
+ },
+ {
+ "destination": "/dev/mqueue",
+ "type": "mqueue",
+ "source": "mqueue",
+ "options": [
+ "nosuid",
+ "noexec",
+ "nodev"
+ ]
+ },
+ {
+ "destination": "/sys",
+ "type": "sysfs",
+ "source": "sysfs",
+ "options": [
+ "nosuid",
+ "noexec",
+ "nodev",
+ "ro"
+ ]
+ },
+ {
+ "type": "bind",
+ "source": "$SSH_ROOT",
+ "destination": "/opt/app-root/src/.ssh",
+ "options": [
+ "bind",
+ "rw",
+ "mode=755"
+ ]
+ },
+ {
+ "type": "bind",
+ "source": "$SSH_ROOT",
+ "destination": "/root/.ssh",
+ "options": [
+ "bind",
+ "rw",
+ "mode=755"
+ ]
+ },
+ {
+ "type": "bind",
+ "source": "$VAR_LIB_OPENSHIFT_INSTALLER",
+ "destination": "/var/lib/openshift-installer",
+ "options": [
+ "bind",
+ "rw",
+ "mode=755"
+ ]
+ },
+ {
+ "destination": "/root/.ansible",
+ "type": "tmpfs",
+ "source": "tmpfs",
+ "options": [
+ "nosuid",
+ "strictatime",
+ "mode=755"
+ ]
+ },
+ {
+ "destination": "/tmp",
+ "type": "tmpfs",
+ "source": "tmpfs",
+ "options": [
+ "nosuid",
+ "strictatime",
+ "mode=755"
+ ]
+ },
+ {
+ "type": "bind",
+ "source": "$INVENTORY_FILE",
+ "destination": "/etc/ansible/hosts",
+ "options": [
+ "bind",
+ "rw",
+ "mode=755"
+ ]
+ },
+ {
+ "destination": "/sys/fs/cgroup",
+ "type": "cgroup",
+ "source": "cgroup",
+ "options": [
+ "nosuid",
+ "noexec",
+ "nodev",
+ "relatime",
+ "ro"
+ ]
+ }
+ ],
+ "hooks": {
+
+ },
+ "linux": {
+ "resources": {
+ "devices": [
+ {
+ "allow": false,
+ "access": "rwm"
+ }
+ ]
+ },
+ "namespaces": [
+ {
+ "type": "pid"
+ },
+ {
+ "type": "mount"
+ }
+ ],
+ "maskedPaths": [
+ "/proc/kcore",
+ "/proc/latency_stats",
+ "/proc/timer_list",
+ "/proc/timer_stats",
+ "/proc/sched_debug",
+ "/sys/firmware"
+ ],
+ "readonlyPaths": [
+ "/proc/asound",
+ "/proc/bus",
+ "/proc/fs",
+ "/proc/irq",
+ "/proc/sys",
+ "/proc/sysrq-trigger"
+ ]
+ }
+}
diff --git a/system-container/root/exports/manifest.json b/system-container/root/exports/manifest.json
new file mode 100644
index 000000000..615b53261
--- /dev/null
+++ b/system-container/root/exports/manifest.json
@@ -0,0 +1,10 @@
+{
+ "version": "1.0",
+ "defaultValues": {
+ "OPTS": "",
+ "VAR_LIB_OPENSHIFT_INSTALLER" : "/var/lib/openshift-installer",
+ "PLAYBOOK_FILE": "/usr/share/ansible/openshift-ansible/playbooks/byo/config.yml",
+ "SSH_ROOT": "/root/.ssh",
+ "INVENTORY_FILE": "/dev/null"
+ }
+}
diff --git a/system-container/root/exports/service.template b/system-container/root/exports/service.template
new file mode 100644
index 000000000..bf5316af6
--- /dev/null
+++ b/system-container/root/exports/service.template
@@ -0,0 +1,6 @@
+[Service]
+ExecStart=$EXEC_START
+ExecStop=-$EXEC_STOP
+Restart=no
+WorkingDirectory=$DESTDIR
+Type=oneshot
diff --git a/system-container/root/exports/tmpfiles.template b/system-container/root/exports/tmpfiles.template
new file mode 100644
index 000000000..327e6f45d
--- /dev/null
+++ b/system-container/root/exports/tmpfiles.template
@@ -0,0 +1 @@
+d $VAR_LIB_OPENSHIFT_INSTALLER - - - - -
diff --git a/system-container/root/usr/local/bin/run-system-container.sh b/system-container/root/usr/local/bin/run-system-container.sh
new file mode 100755
index 000000000..75dbfde03
--- /dev/null
+++ b/system-container/root/usr/local/bin/run-system-container.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exec ansible-playbook -i /etc/ansible/hosts ${OPTS} ${PLAYBOOK_FILE}