main.yml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. ---
  2. - fail:
  3. msg: "SELinux is disabled, This deployment type requires that SELinux is enabled."
  4. when:
  5. - (not ansible_selinux or ansible_selinux.status != 'enabled') and deployment_type in ['enterprise', 'online', 'atomic-enterprise', 'openshift-enterprise']
  6. - not openshift_use_crio | default(false)
  7. - name: setup firewall
  8. include: firewall.yml
  9. static: yes
  10. #### Disable SWAP #####
  11. # https://docs.openshift.com/container-platform/3.4/admin_guide/overcommit.html#disabling-swap-memory
  12. - name: Check for swap usage
  13. command: grep "^[^#].*swap" /etc/fstab
  14. # grep: match any lines which don't begin with '#' and contain 'swap'
  15. changed_when: false
  16. failed_when: false
  17. register: swap_result
  18. - when:
  19. - swap_result.stdout_lines | length > 0
  20. - openshift_disable_swap | default(true) | bool
  21. block:
  22. - name: Disable swap
  23. command: swapoff --all
  24. - name: Remove swap entries from /etc/fstab
  25. replace:
  26. dest: /etc/fstab
  27. regexp: '(^[^#].*swap.*)'
  28. replace: '# \1'
  29. backup: yes
  30. - name: Add notice about disabling swap
  31. lineinfile:
  32. dest: /etc/fstab
  33. line: '# OpenShift-Ansible Installer disabled swap per overcommit guidelines'
  34. state: present
  35. #### End Disable Swap Block ####
  36. - name: include node installer
  37. include: install.yml
  38. - name: Restart cri-o
  39. systemd:
  40. name: cri-o
  41. enabled: yes
  42. state: restarted
  43. when: openshift_use_crio | default(false)
  44. - name: restart NetworkManager to ensure resolv.conf is present
  45. systemd:
  46. name: NetworkManager
  47. enabled: yes
  48. state: restarted
  49. when: openshift_node_bootstrap | bool
  50. # The atomic-openshift-node service will set this parameter on
  51. # startup, but if the network service is restarted this setting is
  52. # lost. Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1372388
  53. #
  54. # Use lineinfile w/ a handler for this task until
  55. # https://github.com/ansible/ansible/pull/24277 is included in an
  56. # ansible release and we can use the sysctl module.
  57. - name: Persist net.ipv4.ip_forward sysctl entry
  58. lineinfile: dest=/etc/sysctl.conf regexp='^net.ipv4.ip_forward' line='net.ipv4.ip_forward=1'
  59. notify:
  60. - reload sysctl.conf
  61. - name: include bootstrap node config
  62. include: bootstrap.yml
  63. when: openshift_node_bootstrap
  64. - name: include standard node config
  65. include: config.yml
  66. when: not openshift_node_bootstrap
  67. - name: Check for credentials file for registry auth
  68. stat:
  69. path: "{{oreg_auth_credentials_path }}"
  70. when:
  71. - oreg_auth_user is defined
  72. register: node_oreg_auth_credentials_stat
  73. - name: Create credentials for registry auth
  74. command: "docker --config={{ oreg_auth_credentials_path }} login -u {{ oreg_auth_user }} -p {{ oreg_auth_password }} {{ oreg_host }}"
  75. when:
  76. - oreg_auth_user is defined
  77. - (not node_oreg_auth_credentials_stat.stat.exists or oreg_auth_credentials_replace) | bool
  78. notify:
  79. - restart node
  80. - name: Configure AWS Cloud Provider Settings
  81. lineinfile:
  82. dest: /etc/sysconfig/{{ openshift.common.service_type }}-node
  83. regexp: "{{ item.regex }}"
  84. line: "{{ item.line }}"
  85. create: true
  86. with_items:
  87. - regex: '^AWS_ACCESS_KEY_ID='
  88. line: "AWS_ACCESS_KEY_ID={{ openshift_cloudprovider_aws_access_key | default('') }}"
  89. - regex: '^AWS_SECRET_ACCESS_KEY='
  90. line: "AWS_SECRET_ACCESS_KEY={{ openshift_cloudprovider_aws_secret_key | default('') }}"
  91. no_log: True
  92. when: openshift_cloudprovider_kind is defined and openshift_cloudprovider_kind == 'aws' and openshift_cloudprovider_aws_access_key is defined and openshift_cloudprovider_aws_secret_key is defined
  93. notify:
  94. - restart node
  95. #### Storage class plugins here ####
  96. - name: NFS storage plugin configuration
  97. include: storage_plugins/nfs.yml
  98. tags:
  99. - nfs
  100. - name: GlusterFS storage plugin configuration
  101. include: storage_plugins/glusterfs.yml
  102. when: "'glusterfs' in openshift.node.storage_plugin_deps"
  103. - name: Ceph storage plugin configuration
  104. include: storage_plugins/ceph.yml
  105. when: "'ceph' in openshift.node.storage_plugin_deps"
  106. - name: iSCSI storage plugin configuration
  107. include: storage_plugins/iscsi.yml
  108. when: "'iscsi' in openshift.node.storage_plugin_deps"
  109. ##### END Storage #####
  110. - include: config/workaround-bz1331590-ovs-oom-fix.yml
  111. when: openshift_node_use_openshift_sdn | default(true) | bool