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.

114 lines
3.6 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. mode: 0644
  15. become: true
  16. when: not skip_http_proxy_on_os_packages
  17. - name: Check RHEL subscription-manager status
  18. command: /sbin/subscription-manager status
  19. register: rh_subscription_status
  20. changed_when: "rh_subscription_status != 0"
  21. ignore_errors: true # noqa ignore-errors
  22. become: true
  23. - name: RHEL subscription Organization ID/Activation Key registration
  24. redhat_subscription:
  25. state: present
  26. org_id: "{{ rh_subscription_org_id }}"
  27. activationkey: "{{ rh_subscription_activation_key }}"
  28. auto_attach: true
  29. force_register: true
  30. syspurpose:
  31. usage: "{{ rh_subscription_usage }}"
  32. role: "{{ rh_subscription_role }}"
  33. service_level_agreement: "{{ rh_subscription_sla }}"
  34. sync: true
  35. notify: RHEL auto-attach subscription
  36. ignore_errors: true # noqa ignore-errors
  37. become: true
  38. when:
  39. - rh_subscription_org_id is defined
  40. - rh_subscription_status.changed
  41. # this task has no_log set to prevent logging security sensitive information such as subscription passwords
  42. - name: RHEL subscription Username/Password registration
  43. redhat_subscription:
  44. state: present
  45. username: "{{ rh_subscription_username }}"
  46. password: "{{ rh_subscription_password }}"
  47. auto_attach: true
  48. force_register: true
  49. syspurpose:
  50. usage: "{{ rh_subscription_usage }}"
  51. role: "{{ rh_subscription_role }}"
  52. service_level_agreement: "{{ rh_subscription_sla }}"
  53. sync: true
  54. notify: RHEL auto-attach subscription
  55. ignore_errors: true # noqa ignore-errors
  56. become: true
  57. no_log: true
  58. when:
  59. - rh_subscription_username is defined
  60. - rh_subscription_status.changed
  61. # container-selinux is in extras repo
  62. - name: Enable RHEL 7 repos
  63. rhsm_repository:
  64. name:
  65. - "rhel-7-server-rpms"
  66. - "rhel-7-server-extras-rpms"
  67. state: enabled
  68. when:
  69. - rhel_enable_repos | default(True)
  70. - ansible_distribution_major_version == "7"
  71. # container-selinux is in appstream repo
  72. - name: Enable RHEL 8 repos
  73. rhsm_repository:
  74. name:
  75. - "rhel-8-for-*-baseos-rpms"
  76. - "rhel-8-for-*-appstream-rpms"
  77. state: enabled
  78. when:
  79. - rhel_enable_repos | default(True)
  80. - ansible_distribution_major_version == "8"
  81. - name: Check presence of fastestmirror.conf
  82. stat:
  83. path: /etc/yum/pluginconf.d/fastestmirror.conf
  84. get_attributes: no
  85. get_checksum: no
  86. get_mime: no
  87. register: fastestmirror
  88. # the fastestmirror plugin can actually slow down Ansible deployments
  89. - name: Disable fastestmirror plugin if requested
  90. lineinfile:
  91. dest: /etc/yum/pluginconf.d/fastestmirror.conf
  92. regexp: "^enabled=.*"
  93. line: "enabled=0"
  94. state: present
  95. become: true
  96. when:
  97. - fastestmirror.stat.exists
  98. - not centos_fastestmirror_enabled
  99. # libselinux-python is required on SELinux enabled hosts
  100. # See https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#managed-node-requirements
  101. - name: Install libselinux python package
  102. package:
  103. name: "{{ ( (ansible_distribution_major_version | int) < 8) | ternary('libselinux-python','python3-libselinux') }}"
  104. state: present
  105. become: true