From c54f2293e6e42b57d238bb1c3c4ce99def0af786 Mon Sep 17 00:00:00 2001 From: gjmzj Date: Thu, 7 Feb 2019 15:23:59 +0800 Subject: [PATCH] minor changes in lb installing --- roles/lb/tasks/main.yml | 18 ++++-------------- roles/lb/templates/keepalived-master.conf.j2 | 2 +- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/roles/lb/tasks/main.yml b/roles/lb/tasks/main.yml index 0363570..b585ff7 100644 --- a/roles/lb/tasks/main.yml +++ b/roles/lb/tasks/main.yml @@ -10,13 +10,8 @@ apt: update_cache=yes cache_valid_time=72000 when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int >= 16 -- name: apt安装 haproxy - apt: name=haproxy state=latest - when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int >= 16 - -- name: yum安装 haproxy - yum: name=haproxy state=latest - when: (ansible_distribution == "CentOS" or ansible_distribution == "RedHat") and ansible_distribution_major_version == "7" +- name: 安装 haproxy + package: name=haproxy state=latest - name: 创建haproxy配置目录 file: name=/etc/haproxy state=directory @@ -30,13 +25,8 @@ template: src=haproxy.cfg.j2 dest=/etc/haproxy/haproxy.cfg tags: restart_lb -- name: apt安装 keepalived - apt: name=keepalived state=latest - when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int >= 16 - -- name: yum安装 keepalived - yum: name=keepalived state=latest - when: (ansible_distribution == "CentOS" or ansible_distribution == "RedHat") and ansible_distribution_major_version == "7" +- name: 安装 keepalived + package: name=keepalived state=latest - name: 创建keepalived配置目录 file: name=/etc/keepalived state=directory diff --git a/roles/lb/templates/keepalived-master.conf.j2 b/roles/lb/templates/keepalived-master.conf.j2 index d3adb4c..ec43ef1 100644 --- a/roles/lb/templates/keepalived-master.conf.j2 +++ b/roles/lb/templates/keepalived-master.conf.j2 @@ -1,5 +1,5 @@ global_defs { - router_id lb-master + router_id lb-master-{{ inventory_hostname }} } vrrp_script check-haproxy {