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 <kevin.carter@rackspace.com>
This commit is contained in:
parent
6066122116
commit
1f1ed79bb4
|
@ -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: "(?<!^{{ hostvars[item]['ansible_ssh_host'] }}) {{ item }}$"
|
||||
state: absent
|
||||
with_items:
|
||||
- "{{ groups['all_containers'] }}"
|
||||
- "{{ groups['hosts'] }}"
|
||||
tags:
|
||||
- openstack-host-hostfile
|
||||
|
||||
- name: Update hosts file from ansible inventory
|
||||
lineinfile:
|
||||
dest: /etc/hosts
|
||||
line: "{{ hostvars[item]['ansible_ssh_host'] }} {{ item }}"
|
||||
state: present
|
||||
with_items:
|
||||
- "{{ groups['all_containers'] }}"
|
||||
- "{{ groups['hosts'] }}"
|
||||
- name: Update hosts file
|
||||
command: "/usr/local/bin/openstack-host-hostfile-setup.sh"
|
||||
tags:
|
||||
- openstack-host-hostfile
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env bash
|
||||
# {{ ansible_managed }}
|
||||
|
||||
set -x
|
||||
|
||||
{% for item in groups['all'] %}
|
||||
sed -i '/^{{ hostvars[item]["ansible_ssh_host"] }}.*/d' /etc/hosts
|
||||
echo '{{ hostvars[item]["ansible_ssh_host"] }} {{ item }}' | tee -a /etc/hosts
|
||||
{% endfor %}
|
Loading…
Reference in New Issue