---
- name: Check presence of fastestmirror.conf
  stat:
    path: /etc/yum/pluginconf.d/fastestmirror.conf
  register: fastestmirror

# fastestmirror plugin actually slows down Ansible deployments
- name: Disable fastestmirror plugin
  lineinfile:
    path: /etc/yum/pluginconf.d/fastestmirror.conf
    regexp: "^enabled=.*"
    line: "enabled=0"
    state: present
  when: fastestmirror.stat.exists

- name: Modprode Kernel Module for IPVS
  modprobe:
    name: "{{ item }}"
    state: present
  with_items:
  - ip_vs
  - ip_vs_rr
  - ip_vs_wrr
  - ip_vs_sh
  - nf_conntrack_ipv4
  when: kube_proxy_mode == 'ipvs'

- name: Persist ip_vs modules
  copy:
    dest: /etc/modules-load.d/kube_proxy-ipvs.conf
    content: |
      ip_vs
      ip_vs_rr
      ip_vs_wrr
      ip_vs_sh
      nf_conntrack_ipv4
  when: kube_proxy_mode == 'ipvs'

- name: Assign node name to unconfigured hostnames
  hostname:
    name: "{{ node_name }}"
  when: ansible_os_family == 'RedHat'

- name: Change bash custom prompt to display the fully qualified hostname
  lineinfile:
    path: "/etc/bashrc"
    line: 'PS1="[\u@\H \W]\\$ "'
