Last active
January 8, 2022 17:07
-
-
Save cloudnull/02805f70edf00d80ff90 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# Copyright 2015, Jean-Philippe Evrard <jean-philippe@evrard.me> | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
master_keepalived_sync_groups: | |
haproxy: | |
instances: | |
- external | |
- internal | |
notify_script: /etc/keepalived/haproxy_notify.sh | |
##if a src_*_script is defined, it will be uploaded from src_*_script on the deploy host to the *_script location. Make sure *_script is a location in that case. | |
#src_notify_script: /opt/os-ansible-deployment/playbooks/vars/configs/keepalived_haproxy_notifications.sh | |
src_notify_script: vars/configs/keepalived_haproxy_notifications.sh | |
master_keepalived_scripts: | |
haproxy_check_script: | |
check_script: "killall -0 haproxy" | |
pingable_check_script: | |
check_script: "ping -c 1 193.0.14.129 1>&2" | |
interval: 10 | |
fall: 2 | |
rise: 4 | |
master_keepalived_instances: | |
external: | |
interface: "{{ haproxy_keepalived_external_interface | default(management_bridge) }}" | |
state: MASTER | |
virtual_router_id: "{{ haproxy_keepalived_external_virtual_router_id | default ('10') }}" | |
priority: "{{ haproxy_keepalived_priority_master | default('100') }}" | |
authentication_password: "{{ haproxy_keepalived_authentication_password }}" | |
vips: | |
- "{{haproxy_keepalived_external_vip_cidr}} dev {{haproxy_keepalived_external_interface | default(management_bridge)}}" | |
track_scripts: | |
- haproxy_check_script | |
- pingable_check_script | |
internal: | |
interface: "{{ haproxy_keepalived_internal_interface | default(management_bridge) }}" | |
state: MASTER | |
virtual_router_id: "{{ haproxy_keepalived_internal_virtual_router_id | default ('11') }}" | |
priority: "{{ haproxy_keepalived_priority_master | default('100') }}" | |
authentication_password: "{{ haproxy_keepalived_authentication_password }}" | |
track_scripts: | |
- haproxy_check_script | |
- pingable_check_script | |
vips: | |
- "{{haproxy_keepalived_internal_vip_cidr}} dev {{haproxy_keepalived_internal_interface | default(management_bridge)}}" | |
backup_keepalived_sync_groups: | |
haproxy: | |
instances: | |
- external | |
- internal | |
notify_script: /etc/keepalived/haproxy_notify.sh | |
##if a src_*_script is defined, it will be uploaded from src_*_script on the deploy host to the *_script location. Make sure *_script is a location in that case. | |
#src_notify_script: /opt/os-ansible-deployment/playbooks/vars/configs/keepalived_haproxy_notifications.sh | |
src_notify_script: vars/configs/keepalived_haproxy_notifications.sh | |
backup_keepalived_scripts: | |
haproxy_check_script: | |
check_script: "killall -0 haproxy" | |
pingable_check_script: | |
check_script: "ping -c 1 193.0.14.129 1>&2" | |
interval: 10 | |
fall: 2 | |
rise: 4 | |
backup_keepalived_instances: | |
external: | |
interface: "{{ haproxy_keepalived_external_interface | default(management_bridge) }}" | |
state: BACKUP | |
virtual_router_id: "{{ haproxy_keepalived_external_virtual_router_id | default ('10') }}" | |
priority: "{{ haproxy_keepalived_priority_backup | default('20') }}" | |
authentication_password: "{{ haproxy_keepalived_authentication_password }}" | |
vips: | |
- "{{haproxy_keepalived_external_vip_cidr}} dev {{haproxy_keepalived_external_interface | default(management_bridge)}}" | |
track_scripts: | |
- haproxy_check_script | |
- pingable_check_script | |
internal: | |
interface: "{{ haproxy_keepalived_internal_interface | default(management_bridge) }}" | |
state: BACKUP | |
virtual_router_id: "{{ haproxy_keepalived_internal_virtual_router_id | default ('11') }}" | |
priority: "{{ haproxy_keepalived_priority_backup | default('20') }}" | |
authentication_password: "{{ haproxy_keepalived_authentication_password }}" | |
track_scripts: | |
- haproxy_check_script | |
- pingable_check_script | |
vips: | |
- "{{haproxy_keepalived_internal_vip_cidr}} dev {{haproxy_keepalived_internal_interface | default(management_bridge)}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/playbooks/haproxy-install.yml b/playbooks/haproxy-install.yml | |
index 0813ff7..8b6be09 100644 | |
--- a/playbooks/haproxy-install.yml | |
+++ b/playbooks/haproxy-install.yml | |
@@ -13,17 +13,24 @@ | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
-- hosts: haproxy_hosts[0] | |
- vars_files: | |
- - "{{ haproxy_keepalived_master_vars_file | default('vars/configs/keepalived_haproxy_master.yml')}}" | |
+- hosts: haproxy_hosts | |
roles: | |
- - { role: "keepalived", when: haproxy_use_keepalived|bool } | |
- | |
-- hosts: haproxy_hosts:!haproxy_hosts[0] | |
+ - role: "keepalived" | |
+ keepalived_sync_groups: "{{ master_keepalived_sync_groups }}" | |
+ keepalived_scripts: "{{ master_keepalived_scripts }}" | |
+ keepalived_instances: "{{ master_keepalived_instances }}" | |
+ when: | |
+ - haproxy_use_keepalived|bool | |
+ - inventory_hostname == haproxy_hosts[0] | |
+ - role: "keepalived" | |
+ keepalived_sync_groups: "{{ backup_keepalived_sync_groups }}" | |
+ keepalived_scripts: "{{ backup_keepalived_scripts }}" | |
+ keepalived_instances: "{{ backup_keepalived_instances }}" | |
+ when: | |
+ - haproxy_use_keepalived|bool | |
+ - inventory_hostname != haproxy_hosts[0] | |
vars_files: | |
- - "{{ haproxy_keepalived_backup_vars_file | default('vars/configs/keepalived_haproxy_backup.yml')}}" | |
- roles: | |
- - { role: "keepalived", when: haproxy_use_keepalived|bool } | |
+ - "vars/configs/keepalived_haproxy.yml" | |
- name: Install haproxy | |
hosts: haproxy_hosts | |
diff --git a/playbooks/vars/configs/keepalived_haproxy_backup.yml b/playbooks/vars/configs/keepalived_haproxy_backup.yml | |
deleted file mode 100644 | |
index 735a2ed..0000000 | |
--- a/playbooks/vars/configs/keepalived_haproxy_backup.yml | |
+++ /dev/null | |
@@ -1,56 +0,0 @@ | |
---- | |
-# Copyright 2015, Jean-Philippe Evrard <jean-philippe@evrard.me> | |
-# | |
-# Licensed under the Apache License, Version 2.0 (the "License"); | |
-# you may not use this file except in compliance with the License. | |
-# You may obtain a copy of the License at | |
-# | |
-# http://www.apache.org/licenses/LICENSE-2.0 | |
-# | |
-# Unless required by applicable law or agreed to in writing, software | |
-# distributed under the License is distributed on an "AS IS" BASIS, | |
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
-# See the License for the specific language governing permissions and | |
-# limitations under the License. | |
- | |
-keepalived_sync_groups: | |
- haproxy: | |
- instances: | |
- - external | |
- - internal | |
- notify_script: /etc/keepalived/haproxy_notify.sh | |
- ##if a src_*_script is defined, it will be uploaded from src_*_script on the deploy host to the *_script location. Make sure *_script is a location in that case. | |
- #src_notify_script: /opt/os-ansible-deployment/playbooks/vars/configs/keepalived_haproxy_notifications.sh | |
- src_notify_script: vars/configs/keepalived_haproxy_notifications.sh | |
- | |
-keepalived_scripts: | |
- haproxy_check_script: | |
- check_script: "killall -0 haproxy" | |
- pingable_check_script: | |
- check_script: "ping -c 1 193.0.14.129 1>&2" | |
- interval: 10 | |
- fall: 2 | |
- rise: 4 | |
-keepalived_instances: | |
- external: | |
- interface: "{{ haproxy_keepalived_external_interface | default(management_bridge) }}" | |
- state: BACKUP | |
- virtual_router_id: "{{ haproxy_keepalived_external_virtual_router_id | default ('10') }}" | |
- priority: "{{ haproxy_keepalived_priority_backup | default('20') }}" | |
- authentication_password: "{{ haproxy_keepalived_authentication_password }}" | |
- vips: | |
- - "{{haproxy_keepalived_external_vip_cidr}} dev {{haproxy_keepalived_external_interface | default(management_bridge)}}" | |
- track_scripts: | |
- - haproxy_check_script | |
- - pingable_check_script | |
- internal: | |
- interface: "{{ haproxy_keepalived_internal_interface | default(management_bridge) }}" | |
- state: BACKUP | |
- virtual_router_id: "{{ haproxy_keepalived_internal_virtual_router_id | default ('11') }}" | |
- priority: "{{ haproxy_keepalived_priority_backup | default('20') }}" | |
- authentication_password: "{{ haproxy_keepalived_authentication_password }}" | |
- track_scripts: | |
- - haproxy_check_script | |
- - pingable_check_script | |
- vips: | |
- - "{{haproxy_keepalived_internal_vip_cidr}} dev {{haproxy_keepalived_internal_interface | default(management_bridge)}}" | |
diff --git a/playbooks/vars/configs/keepalived_haproxy_master.yml b/playbooks/vars/configs/keepalived_haproxy_master.yml | |
deleted file mode 100644 | |
index 9bcedb9..0000000 | |
--- a/playbooks/vars/configs/keepalived_haproxy_master.yml | |
+++ /dev/null | |
@@ -1,57 +0,0 @@ | |
---- | |
-# Copyright 2015, Jean-Philippe Evrard <jean-philippe@evrard.me> | |
-# | |
-# Licensed under the Apache License, Version 2.0 (the "License"); | |
-# you may not use this file except in compliance with the License. | |
-# You may obtain a copy of the License at | |
-# | |
-# http://www.apache.org/licenses/LICENSE-2.0 | |
-# | |
-# Unless required by applicable law or agreed to in writing, software | |
-# distributed under the License is distributed on an "AS IS" BASIS, | |
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
-# See the License for the specific language governing permissions and | |
-# limitations under the License. | |
- | |
-keepalived_sync_groups: | |
- haproxy: | |
- instances: | |
- - external | |
- - internal | |
- notify_script: /etc/keepalived/haproxy_notify.sh | |
- ##if a src_*_script is defined, it will be uploaded from src_*_script on the deploy host to the *_script location. Make sure *_script is a location in that case. | |
- #src_notify_script: /opt/os-ansible-deployment/playbooks/vars/configs/keepalived_haproxy_notifications.sh | |
- src_notify_script: vars/configs/keepalived_haproxy_notifications.sh | |
- | |
-keepalived_scripts: | |
- haproxy_check_script: | |
- check_script: "killall -0 haproxy" | |
- pingable_check_script: | |
- check_script: "ping -c 1 193.0.14.129 1>&2" | |
- interval: 10 | |
- fall: 2 | |
- rise: 4 | |
- | |
-keepalived_instances: | |
- external: | |
- interface: "{{ haproxy_keepalived_external_interface | default(management_bridge) }}" | |
- state: MASTER | |
- virtual_router_id: "{{ haproxy_keepalived_external_virtual_router_id | default ('10') }}" | |
- priority: "{{ haproxy_keepalived_priority_master | default('100') }}" | |
- authentication_password: "{{ haproxy_keepalived_authentication_password }}" | |
- vips: | |
- - "{{haproxy_keepalived_external_vip_cidr}} dev {{haproxy_keepalived_external_interface | default(management_bridge)}}" | |
- track_scripts: | |
- - haproxy_check_script | |
- - pingable_check_script | |
- internal: | |
- interface: "{{ haproxy_keepalived_internal_interface | default(management_bridge) }}" | |
- state: MASTER | |
- virtual_router_id: "{{ haproxy_keepalived_internal_virtual_router_id | default ('11') }}" | |
- priority: "{{ haproxy_keepalived_priority_master | default('100') }}" | |
- authentication_password: "{{ haproxy_keepalived_authentication_password }}" | |
- track_scripts: | |
- - haproxy_check_script | |
- - pingable_check_script | |
- vips: | |
- - "{{haproxy_keepalived_internal_vip_cidr}} dev {{haproxy_keepalived_internal_interface | default(management_bridge)}}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment