# -*- mode: ruby -*- # vi: set ft=ruby : # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! VAGRANTFILE_API_VERSION = "2" cloud_init = < KRATES_VAULT_KEY=<%= vault_secret %> KRATES_VAULT_IV=<%= vault_iv %> coreos: update: reboot-strategy: off units: - name: krates-server-mongo.service command: start enable: true content: | [Unit] Description=krates-server-mongo After=network-online.target After=docker.service Description=Krates Server MongoDB Documentation=https://github.com/appsters/krates Requires=network-online.target Requires=docker.service [Service] Restart=always RestartSec=5 TimeoutStartSec=0 ExecStartPre=/usr/bin/docker pull mongo:3.2 ExecStartPre=-/usr/bin/docker network create krates ExecStartPre=-/usr/bin/docker volume create krates-server-mongo ExecStartPre=-/usr/bin/docker stop krates-server-mongo ExecStartPre=-/usr/bin/docker rm krates-server-mongo ExecStart=/usr/bin/docker run --name=krates-server-mongo \ -v krates-server-mongo:/data/db \ --network krates \ mongo:3.2 ExecStop=/usr/bin/docker stop krates-server-mongo - name: krates-server-api.service command: start enable: true content: | [Unit] Description=krates-server-api After=network-online.target After=docker.service After=krates-server-mongo.service Description=Krates Master Documentation=https://github.io/appsters/krates/ Requires=network-online.target Requires=docker.service Requires=krates-server-mongo.service [Service] Restart=always RestartSec=5 TimeoutStartSec=0 EnvironmentFile=/etc/krates-server.env ExecStartPre=-/usr/bin/docker stop krates-server-api ExecStartPre=-/usr/bin/docker rm krates-server-api ExecStartPre=-/usr/bin/docker network create krates ExecStartPre=/usr/bin/docker pull krates/master:${KONTENA_VERSION} ExecStart=/usr/bin/docker run --name krates-server-api \ -e MONGODB_URI=mongodb://krates-server-mongo:27017/krates_server \ -e VAULT_KEY=${KRATES_VAULT_KEY} -e VAULT_IV=${KRATES_VAULT_IV} \ <% if server_name %>-e SERVER_NAME=<%= server_name %><% end %> \ <% if initial_admin_code %>-e INITIAL_ADMIN_CODE=<%= initial_admin_code %><% end %> \ --network krates \ -p 8080:9292 \ krates/master:${KONTENA_VERSION} ExecStop=/usr/bin/docker stop krates-server-api INIT cloud_init_file = Tempfile.new('krates-master') File.write(cloud_init_file.path, cloud_init) Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.provider :virtualbox do |v| v.check_guest_additions = false v.functional_vboxsf = false end if Vagrant.has_plugin?("vagrant-vbguest") then config.vbguest.auto_update = false end config.vm.define "<%= name %>" do |docker| docker.vm.box = "coreos-<%= coreos_channel %>" docker.vm.box_url = "http://stable.release.core-os.net/amd64-usr/current/coreos_production_vagrant.json" docker.vm.network "private_network", ip: "192.168.66.100" docker.vm.hostname = "<%= name %>" docker.vm.provider "virtualbox" do |vb| vb.name = "<%= name %>" vb.gui = false vb.memory = <%= memory %> vb.auto_nat_dns_proxy = false vb.customize ["modifyvm", :id, "--natdnsproxy1", "off" ] vb.customize ["modifyvm", :id, "--natdnshostresolver1", "off" ] end docker.vm.provision :file, :source => cloud_init_file.path, :destination => "/tmp/vagrantfile-user-data" docker.vm.provision :shell, :inline => "mv /tmp/vagrantfile-user-data /var/lib/coreos-vagrant/", :privileged => true end end