From 4e34803b1ed2bdb2b2d3cc4f03b4a3763624c1fc Mon Sep 17 00:00:00 2001
From: Alexander Block <ablock84@gmail.com>
Date: Wed, 7 Dec 2016 17:16:06 +0100
Subject: [PATCH] Disable fastestmirror on CentOS

It actually slows down things dramatically when used in combination
with Ansible.
---
 inventory/group_vars/all.yml                  |  2 +-
 roles/bootstrap-os/tasks/bootstrap-centos.yml | 14 ++++++++++++++
 roles/bootstrap-os/tasks/main.yml             |  5 ++++-
 3 files changed, 19 insertions(+), 2 deletions(-)
 create mode 100644 roles/bootstrap-os/tasks/bootstrap-centos.yml

diff --git a/inventory/group_vars/all.yml b/inventory/group_vars/all.yml
index 06561e78f..65b65fe39 100644
--- a/inventory/group_vars/all.yml
+++ b/inventory/group_vars/all.yml
@@ -1,4 +1,4 @@
-# Valid bootstrap options (required): ubuntu, coreos, none
+# Valid bootstrap options (required): ubuntu, coreos, centos, none
 bootstrap_os: none
 
 # Directory where the binaries will be installed
diff --git a/roles/bootstrap-os/tasks/bootstrap-centos.yml b/roles/bootstrap-os/tasks/bootstrap-centos.yml
new file mode 100644
index 000000000..9c41ae84c
--- /dev/null
+++ b/roles/bootstrap-os/tasks/bootstrap-centos.yml
@@ -0,0 +1,14 @@
+---
+
+- 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:
+    dest: /etc/yum/pluginconf.d/fastestmirror.conf
+    regexp: "^enabled=.*"
+    line: "enabled=0"
+    state: present
+  when: fastestmirror.stat.exists
diff --git a/roles/bootstrap-os/tasks/main.yml b/roles/bootstrap-os/tasks/main.yml
index a3ebeb8f2..7f1355577 100644
--- a/roles/bootstrap-os/tasks/main.yml
+++ b/roles/bootstrap-os/tasks/main.yml
@@ -5,4 +5,7 @@
 - include: bootstrap-coreos.yml
   when: bootstrap_os == "coreos"
 
-- include: setup-pipelining.yml
+- include: bootstrap-centos.yml
+  when: bootstrap_os == "centos"
+
+- include: setup-pipelining.yml
\ No newline at end of file
-- 
GitLab