Merge "Improve deployment performance on large clusters"

This commit is contained in:
Jenkins
2016-05-06 14:36:50 +00:00
committed by Gerrit Code Review
2 changed files with 16 additions and 27 deletions

View File

@@ -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

View File

@@ -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 %}