From d25f50f81fe15165088f2e0cb1521b880718aac3 Mon Sep 17 00:00:00 2001 From: Scott Lowe Date: Sun, 27 Mar 2016 13:33:38 -0600 Subject: [PATCH] Commit initial set of files for containerd-runc environment Commit Vagrantfile, external YAML data file, Ansible configuration file, and Ansible playbook for containerd-runc environment. Environment is functional at a basic level. --- containerd-runc/Vagrantfile | 60 +++++++++++++++++++++++++++++ containerd-runc/ansible.cfg | 5 +++ containerd-runc/containerd-runc.yml | 45 ++++++++++++++++++++++ containerd-runc/machines.yml | 6 +++ 4 files changed, 116 insertions(+) create mode 100644 containerd-runc/Vagrantfile create mode 100644 containerd-runc/ansible.cfg create mode 100644 containerd-runc/containerd-runc.yml create mode 100644 containerd-runc/machines.yml diff --git a/containerd-runc/Vagrantfile b/containerd-runc/Vagrantfile new file mode 100644 index 0000000..a2cb636 --- /dev/null +++ b/containerd-runc/Vagrantfile @@ -0,0 +1,60 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Specify Vagrant version, Vagrant API version, and desired clone location +Vagrant.require_version '>= 1.8.0' +VAGRANTFILE_API_VERSION = '2' +ENV['VAGRANT_DEFAULT_PROVIDER'] = 'vmware_fusion' +ENV['VAGRANT_VMWARE_CLONE_DIRECTORY'] = '~/.vagrant' +#ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox' + +# Require 'yaml' module +require 'yaml' + +# Read YAML file with VM details (box, CPU, RAM, IP addresses) +machines = YAML.load_file(File.join(File.dirname(__FILE__), 'machines.yml')) + +# Create and configure the VMs +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + + # Always use Vagrant's default insecure key + config.ssh.insert_key = false + + # Iterate through entries in YAML file to create VMs + machines.each do |machine| + config.vm.define machine['name'] do |srv| + + # Don't check for box updates + srv.vm.box_check_update = false + srv.vm.hostname = machine['name'] + srv.vm.box = machine['box'] + + # Configure default synced folder (disable by default) + if machine['sync_disabled'] != nil + srv.vm.synced_folder '.', '/vagrant', disabled: machine['sync_disabled'] + else + srv.vm.synced_folder '.', '/vagrant', disabled: true + end #if machine['sync_disabled'] + + # Configure CPU & RAM per settings in machines.yml (Fusion) + srv.vm.provider :vmware_fusion do |vmw| + vmw.vmx['memsize'] = machine['ram'] + vmw.vmx['numvcpus'] = machine['vcpu'] + if machine['nested'] == true + vmw.vmx['vhv.enable'] = 'TRUE' + end #if machine['nested'] + end # srv.vm.provider vmware_fusion + + # Configure CPU & RAM per settings in machines.yml (VirtualBox) + srv.vm.provider :virtualbox do |vb| + vb.memory = machine['ram'] + vb.cpus = machine['vcpu'] + end # srv.vm.provider virtualbox + + # Provision Docker on appropriate VMs + if machine['provision'] != nil + srv.vm.provision 'ansible', playbook: machine['provision'] + end # if machine['provision'] + end # config.vm.define + end # machines.each +end # Vagrant.configure diff --git a/containerd-runc/ansible.cfg b/containerd-runc/ansible.cfg new file mode 100644 index 0000000..b3a4567 --- /dev/null +++ b/containerd-runc/ansible.cfg @@ -0,0 +1,5 @@ +[defaults] +inventory = ./.vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory +private_key_file = ~/.vagrant.d/insecure_private_key +remote_user = vagrant +host_key_checking = False \ No newline at end of file diff --git a/containerd-runc/containerd-runc.yml b/containerd-runc/containerd-runc.yml new file mode 100644 index 0000000..e5d5ec3 --- /dev/null +++ b/containerd-runc/containerd-runc.yml @@ -0,0 +1,45 @@ +--- +- hosts: "all" + sudo: "yes" + remote_user: "vagrant" + gather_facts: false + + tasks: + - name: "Bootstrap node" + raw: "apt-get install -y python python2.7" + + - name: "Download containerd" + get_url: + url: "https://github.com/docker/containerd/releases/download/0.0.5/containerd" + dest: "/usr/local/bin/containerd" + mode: "0755" + + - name: "Download containerd-shim" + get_url: + url: "https://github.com/docker/containerd/releases/download/0.0.5/containerd-shim" + dest: "/usr/local/bin/containerd-shim" + mode: "0755" + + - name: "Download runc" + get_url: + url: "https://github.com/docker/containerd/releases/download/0.0.5/runc" + dest: "/usr/local/bin/runc" + mode: "0755" + + - name: "Download ctr" + get_url: + url: "https://github.com/docker/containerd/releases/download/0.0.5/ctr" + dest: "/usr/local/bin/ctr" + mode: "0755" + + - name: "Set properties for downloaded files" + file: + path: "{{ item }}" + owner: "root" + group: "root" + mode: "0755" + with_items: + - /usr/local/bin/containerd + - /usr/local/bin/runc + - /usr/local/bin/ctr + - /usr/local/bin/containerd-shim diff --git a/containerd-runc/machines.yml b/containerd-runc/machines.yml new file mode 100644 index 0000000..b622267 --- /dev/null +++ b/containerd-runc/machines.yml @@ -0,0 +1,6 @@ +--- +- name: runc-01 + box: slowe/ubuntu-15.10-server-amd64 + ram: 1024 + vcpu: 1 + provision: containerd-runc.yml