You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.8 KiB

9 years ago
9 years ago
9 years ago
9 years ago
  1. ---
  2. - name: gather os specific variables
  3. include_vars: "{{ item }}"
  4. with_first_found:
  5. - files:
  6. - "{{ ansible_distribution|lower }}-{{ ansible_distribution_version|lower|replace('/', '_') }}.yml"
  7. - "{{ ansible_distribution|lower }}-{{ ansible_distribution_release }}.yml"
  8. - "{{ ansible_distribution|lower }}-{{ ansible_distribution_major_version|lower|replace('/', '_') }}.yml"
  9. - "{{ ansible_distribution|lower }}.yml"
  10. - "{{ ansible_os_family|lower }}.yml"
  11. - defaults.yml
  12. paths:
  13. - ../vars
  14. skip: true
  15. - name: check for minimum kernel version
  16. fail:
  17. msg: >
  18. docker requires a minimum kernel version of
  19. {{ docker_kernel_min_version }} on
  20. {{ ansible_distribution }}-{{ ansible_distribution_version }}
  21. when: (ansible_os_family != "CoreOS") and (ansible_kernel|version_compare(docker_kernel_min_version, "<"))
  22. - name: ensure docker repository public key is installed
  23. action: "{{ docker_repo_key_info.pkg_key }}"
  24. args:
  25. id: "{{item}}"
  26. keyserver: "{{docker_repo_key_info.keyserver}}"
  27. state: present
  28. register: keyserver_task_result
  29. until: keyserver_task_result|success
  30. retries: 4
  31. delay: "{{ retry_stagger | random + 3 }}"
  32. with_items: "{{ docker_repo_key_info.repo_keys }}"
  33. when: ansible_os_family != "CoreOS"
  34. - name: ensure docker repository is enabled
  35. action: "{{ docker_repo_info.pkg_repo }}"
  36. args:
  37. repo: "{{item}}"
  38. state: present
  39. with_items: "{{ docker_repo_info.repos }}"
  40. when: (ansible_os_family != "CoreOS") and (docker_repo_info.repos|length > 0)
  41. - name: Configure docker repository on RedHat/CentOS
  42. copy:
  43. src: "rh_docker.repo"
  44. dest: "/etc/yum.repos.d/docker.repo"
  45. when: ansible_distribution in ["CentOS","RedHat"] and
  46. ansible_distribution_major_version >= 7
  47. - name: ensure docker packages are installed
  48. action: "{{ docker_package_info.pkg_mgr }}"
  49. args:
  50. pkg: "{{item.name}}"
  51. force: "{{item.force|default(omit)}}"
  52. state: present
  53. register: docker_task_result
  54. until: docker_task_result|success
  55. retries: 4
  56. delay: "{{ retry_stagger | random + 3 }}"
  57. with_items: "{{ docker_package_info.pkgs }}"
  58. when: (ansible_os_family != "CoreOS") and (docker_package_info.pkgs|length > 0)
  59. - name: allow for proxies on systems using systemd
  60. include: systemd-proxies.yml
  61. when: ansible_service_mgr == "systemd" and
  62. (http_proxy is defined or https_proxy is defined or no_proxy is defined)
  63. - name: Write docker.service systemd file
  64. template:
  65. src: systemd-docker.service.j2
  66. dest: /etc/systemd/system/docker.service
  67. register: docker_service_file
  68. notify: restart docker
  69. when: ansible_service_mgr == "systemd" and ansible_os_family != "CoreOS"
  70. - meta: flush_handlers
  71. - name: ensure docker service is started and enabled
  72. service:
  73. name: "{{ item }}"
  74. enabled: yes
  75. state: started
  76. with_items:
  77. - docker