en4adw
Last Updated: October 29, 2016
·
137
· argent-smith
1032204 100x100

ruby dev machine config example for mac/docker-machine/coreos

Assuming:
a) you have exported /users via /etc/exports and turned nfsd on
b) you have VirtualBox as a vm runner

Then, you need a config-drive yaml like the following to configure your dev vm

#cloud-config
---
hostname: dev

ssh_authorized_keys:
  - ssh-rsa <some key>

write_files:
  - path: "/etc/docker/certs.d/registry.ag.local:5000/ca.crt"
    permissions: "0644"
    owner: "root"
    content: |
      -----BEGIN CERTIFICATE-----
      CA cert of a local registry goes here
      -----END CERTIFICATE-----

coreos:
  update:
    group: stable
    reboot-strategy: best-effort
  units:
    - name: update-engine.service
      command: start
      enable: true

    - name: docker.service
      command: start
      enable: true
      drop-ins:
        - name: 10-wait-docker.conf
          content: |
            [Unit]
            After=Users.mount
            Requires=Users.mount

    - name: swapon.service
      command: start
      content: |
        [Unit]
        Description=Turn on swap
        [Service]
        Type=oneshot
        Environment="SWAPFILE=/4GiB.swap"
        RemainAfterExit=true
        ExecStartPre=/usr/bin/touch ${SWAPFILE}
        ExecStartPre=/usr/bin/chattr +C ${SWAPFILE}
        ExecStartPre=/usr/bin/fallocate -l 4096m ${SWAPFILE}
        ExecStartPre=/usr/bin/chmod 600 ${SWAPFILE}
        ExecStartPre=/usr/sbin/mkswap ${SWAPFILE}
        ExecStartPre=/usr/sbin/losetup -f ${SWAPFILE}
        ExecStart=/usr/bin/sh -c "/sbin/swapon $(/usr/sbin/losetup -j ${SWAPFILE} | /usr/bin/cut -d : -f 1)"
        ExecStop=/usr/bin/sh -c "/sbin/swapoff $(/usr/sbin/losetup -j ${SWAPFILE} | /usr/bin/cut -d : -f 1)"
        ExecStopPost=/usr/bin/sh -c "/usr/sbin/losetup -d $(/usr/sbin/losetup -j ${SWAPFILE} | /usr/bin/cut -d : -f 1)"
        [Install]
        WantedBy=multi-user.target

    - name: Users.mount
      command: start
      content: |
        [Unit]
        After=syslog.target network.target
        Before=docker.service
        [Mount]
        What=192.168.99.1:/Users
        Where=/Users
        Type=nfs
        Options=async,noacl,fsc
        TimeoutSec=300
        [Install]
        RequiredBy=docker.service
        WantedBy=docker.service

Highlights:

  • It handles the local docker registry with the corresponding CA cert
  • It handles NFS mount of a host directory tree containing the source
  • It makes a swapfile just in case…
Say Thanks
Respond
Filed Under