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.

111 lines
3.4 KiB

  1. ---
  2. - name: Gather host facts to get ansible_distribution_version ansible_distribution_major_version
  3. setup:
  4. gather_subset: '!all'
  5. filter: ansible_distribution_*version
  6. - name: Add proxy to yum.conf or dnf.conf if http_proxy is defined
  7. ini_file:
  8. path: "{{ ( (ansible_distribution_major_version | int) < 8) | ternary('/etc/yum.conf','/etc/dnf/dnf.conf') }}"
  9. section: main
  10. option: proxy
  11. value: "{{ http_proxy | default(omit) }}"
  12. state: "{{ http_proxy | default(False) | ternary('present', 'absent') }}"
  13. no_extra_spaces: true
  14. become: true
  15. when: not skip_http_proxy_on_os_packages
  16. - name: Check RHEL subscription-manager status
  17. command: /sbin/subscription-manager status
  18. register: rh_subscription_status
  19. changed_when: "rh_subscription_status != 0"
  20. ignore_errors: true
  21. become: true
  22. - name: RHEL subscription Organization ID/Activation Key registration
  23. redhat_subscription:
  24. state: present
  25. org_id: "{{ rh_subscription_org_id }}"
  26. activationkey: "{{ rh_subscription_activation_key }}"
  27. auto_attach: true
  28. force_register: true
  29. syspurpose:
  30. usage: "{{ rh_subscription_usage }}"
  31. role: "{{ rh_subscription_role }}"
  32. service_level_agreement: "{{ rh_subscription_sla }}"
  33. sync: true
  34. notify: RHEL auto-attach subscription
  35. ignore_errors: true
  36. become: true
  37. when:
  38. - rh_subscription_org_id is defined
  39. - rh_subscription_status.changed
  40. - name: RHEL subscription Username/Password registration
  41. redhat_subscription:
  42. state: present
  43. username: "{{ rh_subscription_username }}"
  44. password: "{{ rh_subscription_password }}"
  45. auto_attach: true
  46. force_register: true
  47. syspurpose:
  48. usage: "{{ rh_subscription_usage }}"
  49. role: "{{ rh_subscription_role }}"
  50. service_level_agreement: "{{ rh_subscription_sla }}"
  51. sync: true
  52. notify: RHEL auto-attach subscription
  53. ignore_errors: true
  54. become: true
  55. when:
  56. - rh_subscription_username is defined
  57. - rh_subscription_status.changed
  58. # container-selinux is in extras repo
  59. - name: Enable RHEL 7 repos
  60. rhsm_repository:
  61. name:
  62. - "rhel-7-server-rpms"
  63. - "rhel-7-server-extras-rpms"
  64. state: enabled
  65. when:
  66. - rhel_enable_repos | default(True)
  67. - ansible_distribution_major_version == "7"
  68. # container-selinux is in appstream repo
  69. - name: Enable RHEL 8 repos
  70. rhsm_repository:
  71. name:
  72. - "rhel-8-for-*-baseos-rpms"
  73. - "rhel-8-for-*-appstream-rpms"
  74. state: enabled
  75. when:
  76. - rhel_enable_repos | default(True)
  77. - ansible_distribution_major_version == "8"
  78. - name: Check presence of fastestmirror.conf
  79. stat:
  80. path: /etc/yum/pluginconf.d/fastestmirror.conf
  81. get_attributes: no
  82. get_checksum: no
  83. get_mime: no
  84. register: fastestmirror
  85. # the fastestmirror plugin can actually slow down Ansible deployments
  86. - name: Disable fastestmirror plugin if requested
  87. lineinfile:
  88. dest: /etc/yum/pluginconf.d/fastestmirror.conf
  89. regexp: "^enabled=.*"
  90. line: "enabled=0"
  91. state: present
  92. become: true
  93. when:
  94. - fastestmirror.stat.exists
  95. - not centos_fastestmirror_enabled
  96. # libselinux-python is required on SELinux enabled hosts
  97. # See https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#managed-node-requirements
  98. - name: Install libselinux python package
  99. package:
  100. name: "{{ ( (ansible_distribution_major_version | int) < 8) | ternary('libselinux-python','python3-libselinux') }}"
  101. state: present
  102. become: true