|
345 | 345 | group: haproxy
|
346 | 346 | register: haproxy_conf_result
|
347 | 347 |
|
| 348 | + - name: haproxy | prepare haproxy.cfg conf file (replace "bind") |
| 349 | + lineinfile: |
| 350 | + path: /etc/haproxy/haproxy.cfg |
| 351 | + regexp: '{{ item.regexp }}' |
| 352 | + line: '{{ item.line }}' |
| 353 | + backrefs: yes |
| 354 | + loop: |
| 355 | + - { regexp: '^.*bind.*:7000$', line: ' bind {{ hostvars[inventory_hostname].inventory_hostname }}:7000' } |
| 356 | + - { regexp: '^.*bind.*:5000$', line: ' bind {{ hostvars[inventory_hostname].inventory_hostname }}:5000' } |
| 357 | + - { regexp: '^.*bind.*:5001$', line: ' bind {{ hostvars[inventory_hostname].inventory_hostname }}:5001' } |
| 358 | + - { regexp: '^.*bind.*:5002$', line: ' bind {{ hostvars[inventory_hostname].inventory_hostname }}:5002' } |
| 359 | + - { regexp: '^.*bind.*:5003$', line: ' bind {{ hostvars[inventory_hostname].inventory_hostname }}:5003' } |
| 360 | + loop_control: |
| 361 | + label: "{{ item.line }}" |
| 362 | + when: cluster_vip is not defined or cluster_vip | length < 1 |
| 363 | + |
348 | 364 | - name: haproxy | prepare haproxy.cfg conf file (replace "bind" for stats)
|
349 | 365 | lineinfile:
|
350 | 366 | path: /etc/haproxy/haproxy.cfg
|
|
353 | 369 | backrefs: yes
|
354 | 370 | loop:
|
355 | 371 | - { regexp: '^.*bind.*:7000$', line: ' bind {{ hostvars[inventory_hostname].inventory_hostname }}:7000' }
|
| 372 | + - { regexp: '^.*bind.*:5000$', line: ' bind {{ cluster_vip }}:5000' } |
| 373 | + - { regexp: '^.*bind.*:5001$', line: ' bind {{ cluster_vip }}:5001' } |
| 374 | + - { regexp: '^.*bind.*:5002$', line: ' bind {{ cluster_vip }}:5002' } |
| 375 | + - { regexp: '^.*bind.*:5003$', line: ' bind {{ cluster_vip }}:5003' } |
356 | 376 | loop_control:
|
357 | 377 | label: "{{ item.line }}"
|
358 |
| - register: haproxy_conf_prepare_result |
| 378 | + when: cluster_vip is defined and cluster_vip | length > 0 |
359 | 379 | when: add_balancer is defined and add_balancer|bool
|
360 | 380 | tags: [ haproxy, haproxy_conf ]
|
361 | 381 |
|
|
437 | 457 |
|
438 | 458 | # virtual ip address (and haproxy health checking)
|
439 | 459 | - import_tasks: ../tasks/keepalived.yml
|
| 460 | + when: cluster_vip is defined and cluster_vip | length > 0 |
440 | 461 | tags: keepalived
|
0 commit comments