diff --git a/docker/docker-ce-edge/README.md b/docker/docker-ce-edge/README.md new file mode 100644 index 0000000..5ba8abf --- /dev/null +++ b/docker/docker-ce-edge/README.md @@ -0,0 +1,31 @@ +# Docker CE Edge on Ubuntu 16.04 + +These files were created to allow users to use Vagrant ([http://www.vagrantup.com](http://www.vagrantup.com)) quickly and relatively easily turn up a VM running the "Edge" channel of Docker CE (for testing the newest features of Docker). This was tested using Vagrant 1.9.1 with VirtualBox 5.1.20 on Fedora Linux, but it should work with any recent version of Vagrant with other virtualization providers as well. The `Vagrantfile` is already extended to support the Vagrant VMware provider. + +## Contents + +* **ansible.cfg**: This is an Ansible configuration file to support Vagrant. No edits to this file should be needed. + +* **machines.yml**: This YAML file contains a list of VM definitions. It is referenced by `Vagrantfile` when Vagrant instantiates the VMs. You will need to edit this file to provide the correct Vagrant box names. Other edits should not be necessary. + +* **provision.yml**: This is an Ansible playbook to automatically install Docker CE from the "Edge" channel. No edits to this file should be needed. + +* **README.md**: This file you're currently reading. + +* **Vagrantfile**: This file is used by Vagrant to spin up the virtual machines. This file is fairly extensively commented to help explain what's happening. You should be able to use this file unchanged; all the VM configuration options are stored outside this file. + +## Instructions + +These instructions assume you've already installed your virtualization provider (VMware Fusion/Workstation or VirtualBox), Vagrant, and any necessary plugins (such as the Vagrant VMware plugin). Please refer to the documentation for those products for more information on installation or configuration. + +1. Use `vagrant box add` to install an Ubuntu 16.04 Vagrant box. The "bento/ubuntu-16.04" box works well with both VirtualBox and VMware Fusion/Workstation. + +2. Place the files from the `docker/docker-ce-edge` directory of this GitHub repository into a directory on your local system. You can clone the entire "learning-tools" repository (using `git clone`) or just download the specific files from the the `docker/docker-ce-edge` folder. + +3. If you're _not_ using the "bento/ubuntu-16.04" Vagrant box, edit `machines.yml` to supply the correct box name. This file has separate lines for the VirtualBox and VMware providers; be sure to edit the correct line for your provider. + +4. Run `vagrant up` to instantiate the VM. Vagrant will create the VM, power it on, and automatically run an Ansible playbook against the VM. + +5. Once Vagrant is finished, use `vagrant ssh` to log into the VM. + +Enjoy! diff --git a/docker/docker-ce-edge/Vagrantfile b/docker/docker-ce-edge/Vagrantfile new file mode 100644 index 0000000..ce321e1 --- /dev/null +++ b/docker/docker-ce-edge/Vagrantfile @@ -0,0 +1,71 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Specify minimum Vagrant version and Vagrant API version +Vagrant.require_version '>= 1.6.0' +VAGRANTFILE_API_VERSION = '2' + +# Require 'yaml' module +require 'yaml' + +# Read YAML file with VM details (box, CPU, and RAM) +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 + + # Set machine's hostname + srv.vm.hostname = machine['name'] + + # Use VMware box by default + srv.vm.box = machine['box']['vmw'] + + # 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'] + + # Iterate through networks as per settings in machines.yml + machine['nics'].each do |net| + if net['ip_addr'] == 'dhcp' + srv.vm.network net['type'], type: net['ip_addr'] + else + srv.vm.network net['type'], ip: net['ip_addr'] + end # if net['ip_addr'] + end # machine['nics'].each + + # 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, override| + vb.memory = machine['ram'] + vb.cpus = machine['vcpu'] + override.vm.box = machine['box']['vb'] + end # srv.vm.provider 'virtualbox' + end # config.vm.define + + # Configure the VM using Ansible + config.vm.provision 'ansible' do |ansible| + ansible.playbook = 'provision.yml' + end # config.vm.provision + end # machines.each +end # Vagrant.configure diff --git a/docker/docker-ce-edge/ansible.cfg b/docker/docker-ce-edge/ansible.cfg new file mode 100644 index 0000000..9f96c92 --- /dev/null +++ b/docker/docker-ce-edge/ansible.cfg @@ -0,0 +1,5 @@ +[defaults] +inventory = ./.vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory +private_key_file = /Users/slowe/.vagrant.d/insecure_private_key +remote_user = vagrant +host_key_checking = False \ No newline at end of file diff --git a/docker/docker-ce-edge/machines.yml b/docker/docker-ce-edge/machines.yml new file mode 100644 index 0000000..1b00f71 --- /dev/null +++ b/docker/docker-ce-edge/machines.yml @@ -0,0 +1,12 @@ +--- +- box: + vmw: "bento/ubuntu-16.04" + vb: "bento/ubuntu-16.04" + name: "xenial" + nested: false + nics: + - type: "private_network" + ip_addr: "dhcp" + ram: "512" + sync_disabled: true + vcpu: "1" diff --git a/docker/docker-ce-edge/provision.yml b/docker/docker-ce-edge/provision.yml new file mode 100644 index 0000000..9c1b25b --- /dev/null +++ b/docker/docker-ce-edge/provision.yml @@ -0,0 +1,48 @@ +--- +- hosts: "all" + become: "yes" + remote_user: "ubuntu" + + tasks: + - name: "Install Pip" + apt: + name: "python-pip" + state: "present" + update_cache: "yes" + + - name: "Install some Python modules" + pip: + name: "{{ item }}" + state: "present" + with_items: + - "urllib3" + - "pyopenssl" + - "ndg-httpsclient" + - "pyasn1" + + - name: "Install Docker APT Key" + apt_key: + url: "https://download.docker.com/linux/ubuntu/gpg" + state: "present" + + - name: "Add Docker repository" + apt_repository: + repo: "deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial edge" + state: "present" + update_cache: "yes" + + - name: "Install Docker CE Edge" + package: + name: "docker-ce" + state: "present" + + - name: "Add user to Docker group" + user: + name: "{{ ansible_ssh_user }}" + group: "docker" + append: "yes" + + - name: "Restart Docker daemon" + systemd: + name: "docker" + state: "restarted"