# -*- 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 = < KONTENA_VAULT_KEY=<%= vault_secret %> KONTENA_VAULT_IV=<%= vault_iv %> coreos: update: reboot-strategy: off units: - name: kontena-server-mongo.service command: start enable: true content: | [Unit] Description=kontena-server-mongo After=network-online.target After=docker.service Description=Kontena Server MongoDB Documentation=http://www.mongodb.org/ 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 kontena ExecStartPre=-/usr/bin/docker volume create kontena-server-mongo ExecStartPre=-/usr/bin/docker stop kontena-server-mongo ExecStartPre=-/usr/bin/docker rm kontena-server-mongo ExecStart=/usr/bin/docker run --name=kontena-server-mongo \ -v kontena-server-mongo:/data/db \ --network kontena \ mongo:3.2 ExecStop=/usr/bin/docker stop kontena-server-mongo - name: kontena-server-api.service command: start enable: true content: | [Unit] Description=kontena-server-api After=network-online.target After=docker.service After=kontena-server-mongo.service Description=Kontena Master Documentation=http://www.kontena.io/ Requires=network-online.target Requires=docker.service Requires=kontena-server-mongo.service [Service] Restart=always RestartSec=5 TimeoutStartSec=0 EnvironmentFile=/etc/kontena-server.env ExecStartPre=-/usr/bin/docker stop kontena-server-api ExecStartPre=-/usr/bin/docker rm kontena-server-api ExecStartPre=-/usr/bin/docker network create kontena ExecStartPre=/usr/bin/docker pull kontena/server:${KONTENA_VERSION} ExecStart=/usr/bin/docker run --name kontena-server-api \ -e MONGODB_URI=mongodb://kontena-server-mongo:27017/kontena_server \ -e VAULT_KEY=${KONTENA_VAULT_KEY} -e VAULT_IV=${KONTENA_VAULT_IV} \ <% if server_name %>-e SERVER_NAME=<%= server_name %><% end %> \ <% if initial_admin_code %>-e INITIAL_ADMIN_CODE=<%= initial_admin_code %><% end %> \ --network kontena \ -p 8080:9292 \ kontena/server:${KONTENA_VERSION} ExecStop=/usr/bin/docker stop kontena-server-api INIT cloud_init_file = Tempfile.new('kontena-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