Merge "Improve deployment performance on large clusters"
This commit is contained in:
@@ -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
|
||||
|
||||
9
templates/openstack-host-hostfile-setup.sh.j2
Normal file
9
templates/openstack-host-hostfile-setup.sh.j2
Normal 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 %}
|
||||
Reference in New Issue
Block a user