2019-06-02 00:04:33 +08:00
|
|
|
# to clean 'lb' service
|
|
|
|
- block:
|
2021-02-04 13:54:14 +08:00
|
|
|
- name: get service info
|
2021-04-09 08:35:12 +08:00
|
|
|
shell: 'systemctl list-units --type=service |grep -E "l4lb|keepalived|ssh"'
|
2021-02-04 13:54:14 +08:00
|
|
|
register: service_info
|
|
|
|
|
2021-04-09 08:35:12 +08:00
|
|
|
- name: remove service l4lb
|
|
|
|
service: name=l4lb state=stopped enabled=no
|
|
|
|
when: '"l4lb" in service_info.stdout'
|
2021-02-04 13:54:14 +08:00
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
- name: remove service keepalived
|
|
|
|
service: name=keepalived state=stopped enabled=no
|
|
|
|
when: '"keepalived" in service_info.stdout'
|
2019-06-02 00:04:33 +08:00
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
- name: remove files and dirs
|
|
|
|
file: name={{ item }} state=absent
|
|
|
|
with_items:
|
2021-04-09 08:35:12 +08:00
|
|
|
- "/etc/l4lb"
|
2019-06-02 00:04:33 +08:00
|
|
|
- "/etc/keepalived"
|
2021-04-09 08:35:12 +08:00
|
|
|
- "/etc/systemd/system/l4lb.service"
|
|
|
|
- "/etc/systemd/system/keepalived.service"
|
|
|
|
- "/usr/local/sbin/keepalived"
|
|
|
|
when: "inventory_hostname in groups['ex_lb']"
|