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.

99 lines
3.4 KiB

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