diff --git a/README.md b/README.md index 7824697..1e889f2 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,10 @@ apt_repository: deb https://apt.dockerproject.org/repo {{ ansible_lsb.id|lower } # -H tcp://0.0.0.0:2375 # --log-level=debug docker_opts: "" +# List of users to be added to 'docker' system group (disabled by default) +# SECURITY WARNING:  +# Be aware that granted users can easily get full root access on the docker host system! +docker_group_members: [] # configurable proxies: a reasonable default is to re-use the proxy from ansible_env: # docker_http_proxy: "{{ ansible_env.http_proxy|default('') }}" @@ -86,15 +90,13 @@ docker_opts: "" docker_http_proxy: docker_https_proxy: -# List of users to be added to 'docker' system group (disabled by default) -# SECURITY WARNING:  -# Be aware that granted users can easily get full root access on the docker host system! -docker_group_members: [] # Flags for whether to install pip packages pip_install_pip: true pip_install_setuptools: true pip_install_docker_py: true pip_install_docker_compose: true +install_docker_py_on_1604: false + # Versions for the python packages that are installed pip_version_pip: latest pip_version_setuptools: latest @@ -110,6 +112,7 @@ update_docker_package: no # Change these to 'present' if you're running Ubuntu 12.04-13.10 and are fine with less-than-latest packages kernel_pkg_state: latest cgroup_lite_pkg_state: latest +dmsetup_pkg_state: latest # Force an install of the kernel extras, in case you're suffering from some issue related to the # static binary provided by upstream Docker. For example, see this GitHub Issue in Docker: # https://github.com/docker/docker/issues/12750 @@ -120,7 +123,6 @@ install_kernel_extras: false # where an X/Unit desktop is actively being used. If you're not using an X/Unity on 12.04, you # won't need to enable this. install_xorg_pkgs: false - ``` Dependencies diff --git a/Vagrantfile b/Vagrantfile index 7a0acb7..6ad02de 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -20,10 +20,17 @@ boxes = [ :cpu => "33", :ram => "256" }, + { + :name => "ubuntu-1604", + :box => "ubuntu/xenial64", + :ip => '10.0.77.13', + :cpu => "33", + :ram => "512" + }, { :name => "debian-jessie", :box => "debian/jessie64", - :ip => '10.0.77.13', + :ip => '10.0.77.14', :cpu => "33", :ram => "256" }, @@ -34,7 +41,6 @@ Vagrant.configure("2") do |config| config.vm.define box[:name] do |vms| vms.vm.box = box[:box] vms.vm.box_url = box[:url] - vms.vm.hostname = "ansible-#{role}-#{box[:name]}" vms.vm.provider "virtualbox" do |v| v.customize ["modifyvm", :id, "--cpuexecutioncap", box[:cpu]] @@ -43,6 +49,11 @@ Vagrant.configure("2") do |config| vms.vm.network :private_network, ip: box[:ip] + # neccessary for ubuntu 16.04 and harmless for the rest + vms.vm.provision :shell do |shell| + shell.inline = "DEBIAN_FRONTEND=noninteractive apt-get -y install python-simplejson" + end + vms.vm.provision :ansible do |ansible| ansible.playbook = "tests/vagrant.yml" ansible.verbose = "vv" diff --git a/defaults/main.yml b/defaults/main.yml index f9cd41e..d1a7563 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -39,6 +39,8 @@ pip_install_pip: true pip_install_setuptools: true pip_install_docker_py: true pip_install_docker_compose: true +install_docker_py_on_1604: false + # Versions for the python packages that are installed pip_version_pip: latest pip_version_setuptools: latest @@ -51,6 +53,7 @@ kernel_update_and_reboot_permitted: no # Set to 'yes' or 'true' to enable updates (sets 'latest' in apt module) update_docker_package: no + # Change these to 'present' if you're running Ubuntu 12.04-13.10 and are fine with less-than-latest packages kernel_pkg_state: latest cgroup_lite_pkg_state: latest diff --git a/tasks/kernel_check_and_update.yml b/tasks/kernel_check_and_update.yml index 7ebbf03..cdf3460 100644 --- a/tasks/kernel_check_and_update.yml +++ b/tasks/kernel_check_and_update.yml @@ -8,7 +8,7 @@ - linux-image-generic-lts-trusty - linux-headers-generic-lts-trusty register: kernel_result - when: "ansible_distribution_version|version_compare(12.04, '=')" + when: "ansible_distribution_version|version_compare('12.04', '=')" - name: Install Xorg packages for backported kernels (very optional) apt: @@ -31,8 +31,8 @@ with_items: - "linux-image-extra-{{ ansible_kernel }}" - linux-image-extra-virtual - when: "ansible_distribution_version|version_compare(13.04, '=') - or ansible_distribution_version|version_compare(13.10, '=') + when: "ansible_distribution_version|version_compare('13.04', '=') + or ansible_distribution_version|version_compare('13.10', '=') or install_kernel_extras" # Fix for https://github.com/dotcloud/docker/issues/4568 @@ -43,13 +43,13 @@ update_cache: yes cache_valid_time: 600 register: cgroup_lite_result - when: "ansible_distribution_version|version_compare(13.10, '=')" + when: "ansible_distribution_version|version_compare('13.10', '=')" - name: Reboot instance command: /sbin/shutdown -r now register: reboot_result - when: "(ansible_distribution_version|version_compare(12.04, '=') and kernel_result|changed) - or (ansible_distribution_version|version_compare(13.10, '=') and cgroup_lite_result|changed) + when: "(ansible_distribution_version|version_compare('12.04', '=') and kernel_result|changed) + or (ansible_distribution_version|version_compare('13.10', '=') and cgroup_lite_result|changed) or xorg_pkg_result|changed" - name: Wait for instance to come online (10 minute timeout) @@ -61,5 +61,5 @@ delay: 30 timeout: 600 state: started - when: "(ansible_distribution_version|version_compare(12.04, '=') and reboot_result|changed) - or (ansible_distribution_version|version_compare(13.10, '=') and cgroup_lite_result|changed)" + when: "(ansible_distribution_version|version_compare('12.04', '=') and reboot_result|changed) + or (ansible_distribution_version|version_compare('13.10', '=') and cgroup_lite_result|changed)" diff --git a/tasks/main.yml b/tasks/main.yml index a4e0630..e6b0df6 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -20,7 +20,7 @@ pkg: dmsetup state: "{{ dmsetup_pkg_state }}" update_cache: "{{ 'yes' if dmsetup_pkg_state=='latest' else 'no' }}" - cache_valid_time: 600 + cache_valid_time: "{{ docker_apt_cache_valid_time }}" register: dmsetup_result when: ansible_distribution_version|version_compare('16.04', '=') @@ -172,11 +172,19 @@ state: "{{ 'latest' if item.version=='latest' else 'present' }}" version: "{{ item.version if item.version!='latest' else omit }}" with_items: - - { name: pip, version: "{{ pip_version_pip }}", install: "{{ pip_install_pip }}" } - - { name: setuptools, version: "{{ pip_version_setuptools }}", install: "{{ pip_install_setuptools }}" } - - { name: docker-py, version: "{{ pip_version_docker_py }}", install: "{{ pip_install_docker_py }}" } - - { name: docker-compose, version: "{{ _pip_version_docker_compose }}", install: "{{ pip_install_docker_compose }}" } - when: item.install + - name: pip + version: "{{ pip_version_pip }}" + install: "{{ pip_install_pip }}" + - name: setuptools + version: "{{ pip_version_setuptools }}" + install: "{{ pip_install_setuptools }}" + - name: docker-py + version: "{{ pip_version_docker_py }}" + install: "{{ pip_install_docker_py and (install_docker_py_on_1604 or not ansible_distribution_version|version_compare('16.04', '>=')) }}" + - name: docker-compose + version: "{{ _pip_version_docker_compose }}" + install: "{{ pip_install_docker_compose }}" + when: item.install|bool - name: Check if /etc/updatedb.conf exists stat: @@ -248,5 +256,6 @@ when: docker_group_members is defined - name: update facts if docker0 is not defined - action: setup filter="ansible_docker0" + setup: + filter: "ansible_docker0" when: ansible_docker0 is not defined diff --git a/tests/vagrant.yml b/tests/vagrant.yml index 694da6b..6054a9b 100644 --- a/tests/vagrant.yml +++ b/tests/vagrant.yml @@ -2,9 +2,9 @@ # test file for docker.ubuntu role on vagrant - hosts: all become: yes - vars: - docker_group_members: [ '{{ ansible_ssh_user }}' ] - + docker_group_members: + - "{{ ansible_ssh_user }}" roles: - - docker.ubuntu + - role: docker.ubuntu + kernel_update_and_reboot_permitted: yes