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.

68 lines
1.9KB

  1. ---
  2. - name: 'Copy Docker GPG key'
  3. copy:
  4. src: 'docker_centos_gpg'
  5. dest: '/tmp/docker_centos_gpg'
  6. owner: 'root'
  7. group: 'root'
  8. - name: 'Add Docker GPG key'
  9. rpm_key:
  10. key: '/tmp/docker_centos_gpg'
  11. state: 'present'
  12. - name: 'Add Docker repository'
  13. get_url:
  14. url: "{{ docker_yum_repo_url }}"
  15. dest: '/etc/yum.repos.d/docker-{{ docker_edition }}.repo'
  16. owner: root
  17. group: root
  18. mode: 0644
  19. when: not docker_repo_workaround
  20. - name: 'replace repo file'
  21. copy:
  22. src: docker-ce.repo
  23. dest: '/etc/yum.repos.d/docker-{{ docker_edition }}.repo'
  24. owner: root
  25. group: root
  26. mode: 0644
  27. when: docker_repo_workaround
  28. - name: 'Configure Docker Test repo'
  29. ini_file:
  30. dest: '/etc/yum.repos.d/docker-{{ docker_edition }}.repo'
  31. section: 'docker-{{ docker_edition }}-test'
  32. option: 'enabled'
  33. value: '{{ docker_yum_repo_enable_test }}'
  34. #when: not docker_repo_workaround
  35. # To install docker-ce, we need container-selinux available from an extras repo.
  36. # The repository name depends of the environment (AWS RHEL AMI has a specific naming).
  37. - name: 'Find extra repos'
  38. shell:
  39. cmd: |
  40. set -o pipefail;
  41. yum repolist all | egrep -e '^[!*]?rhui-REGION-rhel-server-extras' -e '^[!*]?rhel-7-server-extras-rpms' -e '^[!*]?(rhui-)?rhel-7-server-rhui-extras-rpms' | sed -r 's#^[!*]?([^/]*)/.*#\1#'
  42. args:
  43. warn: 'no'
  44. register: 'redhat_extrarepo'
  45. changed_when: False
  46. when: ansible_distribution == "RedHat"
  47. - name: 'Install Docker'
  48. package:
  49. name: "{{ docker_package }}"
  50. state: "{{ docker_package_state }}"
  51. notify: 'restart docker'
  52. when: ansible_distribution != "RedHat"
  53. - name: 'Install Docker'
  54. yum:
  55. name: "{{ docker_package }}"
  56. state: "{{ docker_package_state }}"
  57. enablerepo: "{{ redhat_extrarepo.stdout }}"
  58. notify: 'restart docker'
  59. when: ansible_distribution == "RedHat"