From 1f1ed79bb43aa6309e05bd7e9707a3d152b1314d Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Tue, 3 May 2016 13:52:12 -0500 Subject: [PATCH] Improve deployment performance on large clusters This change makes the host file prep and setup a lot faster especially when deploying against very large clusters. The change moves away from the lineinfile module and instead generates a script with the same capabilities and then executes the script. The generated script is stored in locally on the remote host at "/usr/local/bin/openstack-host-hostfile-setup.sh" and can be executed at any time to fix and or clean up host file problems. Change-Id: Idca583deb403fce2b15a3dbc6255bb3bf92d9446 Signed-off-by: Kevin Carter --- tasks/openstack_update_hosts_file.yml | 34 ++++--------------- templates/openstack-host-hostfile-setup.sh.j2 | 9 +++++ 2 files changed, 16 insertions(+), 27 deletions(-) create mode 100644 templates/openstack-host-hostfile-setup.sh.j2 diff --git a/tasks/openstack_update_hosts_file.yml b/tasks/openstack_update_hosts_file.yml index cffdb262..7023d627 100644 --- a/tasks/openstack_update_hosts_file.yml +++ b/tasks/openstack_update_hosts_file.yml @@ -13,35 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Update hosts file remove stale IP entries - lineinfile: - dest: /etc/hosts - regexp: "^{{ hostvars[item]['ansible_ssh_host'] }} (?!{{ item }}$)" - state: absent - with_items: - - "{{ groups['all_containers'] }}" - - "{{ groups['hosts'] }}" +- name: Drop hosts file entries script + template: + src: "openstack-host-hostfile-setup.sh.j2" + dest: "/usr/local/bin/openstack-host-hostfile-setup.sh" + mode: "0755" tags: - openstack-host-hostfile -- name: Update hosts file remove stale Host entries - lineinfile: - dest: /etc/hosts - regexp: "(?