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.

87 lines
3.1 KiB

9 years ago
8 years ago
8 years ago
8 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. tags: facts
  16. - include: set_facts_dns.yml
  17. when: dns_mode != 'none' and resolvconf_mode == 'docker_dns'
  18. tags: facts
  19. - name: check for minimum kernel version
  20. fail:
  21. msg: >
  22. docker requires a minimum kernel version of
  23. {{ docker_kernel_min_version }} on
  24. {{ ansible_distribution }}-{{ ansible_distribution_version }}
  25. when: (not ansible_os_family in ["CoreOS", "Container Linux by CoreOS"]) and (ansible_kernel|version_compare(docker_kernel_min_version, "<"))
  26. tags: facts
  27. - name: ensure docker repository public key is installed
  28. action: "{{ docker_repo_key_info.pkg_key }}"
  29. args:
  30. id: "{{item}}"
  31. keyserver: "{{docker_repo_key_info.keyserver}}"
  32. state: present
  33. register: keyserver_task_result
  34. until: keyserver_task_result|succeeded
  35. retries: 4
  36. delay: "{{ retry_stagger | random + 3 }}"
  37. with_items: "{{ docker_repo_key_info.repo_keys }}"
  38. when: not (ansible_os_family in ["CoreOS", "Container Linux by CoreOS"] or is_atomic)
  39. - name: ensure docker repository is enabled
  40. action: "{{ docker_repo_info.pkg_repo }}"
  41. args:
  42. repo: "{{item}}"
  43. state: present
  44. with_items: "{{ docker_repo_info.repos }}"
  45. when: not (ansible_os_family in ["CoreOS", "Container Linux by CoreOS"] or is_atomic) and (docker_repo_info.repos|length > 0)
  46. - name: Configure docker repository on RedHat/CentOS
  47. template:
  48. src: "rh_docker.repo.j2"
  49. dest: "/etc/yum.repos.d/docker.repo"
  50. when: ansible_distribution in ["CentOS","RedHat"] and not is_atomic
  51. - name: ensure docker packages are installed
  52. action: "{{ docker_package_info.pkg_mgr }}"
  53. args:
  54. pkg: "{{item.name}}"
  55. force: "{{item.force|default(omit)}}"
  56. state: present
  57. register: docker_task_result
  58. until: docker_task_result|succeeded
  59. retries: 4
  60. delay: "{{ retry_stagger | random + 3 }}"
  61. with_items: "{{ docker_package_info.pkgs }}"
  62. notify: restart docker
  63. when: not (ansible_os_family in ["CoreOS", "Container Linux by CoreOS"] or is_atomic) and (docker_package_info.pkgs|length > 0)
  64. - name: check minimum docker version for docker_dns mode. You need at least docker version >= 1.12 for resolvconf_mode=docker_dns
  65. command: "docker version -f '{{ '{{' }}.Client.Version{{ '}}' }}'"
  66. register: docker_version
  67. failed_when: docker_version.stdout|version_compare('1.12', '<')
  68. changed_when: false
  69. when: dns_mode != 'none' and resolvconf_mode == 'docker_dns'
  70. - name: Set docker systemd config
  71. include: systemd.yml
  72. - name: ensure docker service is started and enabled
  73. service:
  74. name: "{{ item }}"
  75. enabled: yes
  76. state: started
  77. with_items:
  78. - docker