Saltstack Configuration Management-Business reference keepalived

Source: Internet
Author: User
Tags haproxy saltstack

Configuration file for ================>keepalived

[Email protected] cluster]# cat/srv/salt/prod/cluster/files/haproxy-outside-keepalived.conf

! Configuration File for Keepalived

Global_defs {

Notification_email {

[Email protected]

}

Notification_email_from [email protected]

Smtp_server 127.0.0.1

Smtp_connect_timeout 30

router_id {{Routeid}}

}


Vrrp_instance Haproxy_ha {

State {{Stateid}}

Interface eth0

VIRTUAL_ROUTER_ID 36

Priority {{Priorityid}}

Advert_int 1

Authentication {

Auth_type PASS

Auth_pass 1111

}

virtual_ipaddress {

10.0.0.11

}

}


=========> Service Management Module

[Email protected] cluster]# Cat/srv/salt/prod/cluster/haproxy-outside-keepalives.sls

Include

-Keepalived.install


Keepalived-service:

File.managed:

-Name:/etc/keepalived/keepalived.conf

-Source:salt://cluster/files/haproxy-outside-keepalived.conf

-User:root

-Group:root

-mode:644

-Template:jinja

{% if grains[' fqdn '] = = ' linux-node1.example.com '%}

-Routeid:haproxy_ha

-Stateid:master

-priorityid:150

{% elif grains[' FQDN '] = = ' linux-node2.example.com '%}

-Routeid:haproxy_ha

-Stateid:backup

-priorityid:100

{% ENDIF%}

Service.running:

-Name:keepalived

-Enable:true

-Watch:

-File:keepalived-service


To perform a general state:

[[email protected] cluster]# Salt ' * ' State.sls cluster.haproxy-outside-keepalived Env=prod

Linux-node2.example.com:

.............

Summary

-------------

Succeeded:15 (changed=2)

failed:0

-------------

Total states run:15

Linux-node1.example.com:

............

Summary

-------------

Succeeded:15 (changed=2)

failed:0

-------------

Total states run:15




===============top file files for advanced state execution

[Email protected] cluster]# Cat/srv/salt/base/top.sls

Base

‘*‘:

-Init.env_init


Prod

' Linux-node1.example.com ':

-Cluster.haproxy-outside

-Cluster.haproxy-outside-keepalived

' Linux-node2.example.com ':

-Cluster.haproxy-outside

-Cluster.haproxy-outside-keepalived


Perform advanced Status:

[[email protected] cluster]# Salt ' * ' state.highstate

Linux-node2.example.com:

................

Summary

-------------

Succeeded:29

failed:0

-------------

Total states run:29

Linux-node1.example.com:

................

Summary

-------------

Succeeded:29

failed:0

-------------

Total states run:29


Then view the virtual IP status from the command:

[[Email protected] cluster]# IP ad li

2:eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> MTU Qdisc pfifo_fast State up Qlen 1000

Link/ether 00:0c:29:5c:e0:13 BRD FF:FF:FF:FF:FF:FF

inet 10.0.0.7/24 BRD 10.0.0.255 Scope Global eth0

inet 10.0.0.11/32 Scope Global eth0 ===============> Here is the virtual IP

Inet6 FE80::20C:29FF:FE5C:E013/64 Scope link

Valid_lft Forever Preferred_lft Forever


[[Email protected] ~]# IP ad li

2:eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> MTU Qdisc pfifo_fast State up Qlen 1000

Link/ether 00:0c:29:38:4b:e3 BRD FF:FF:FF:FF:FF:FF

inet 10.0.0.8/24 BRD 10.0.0.255 Scope Global eth0

Inet6 FE80::20C:29FF:FE38:4BE3/64 Scope link

Valid_lft Forever Preferred_lft Forever


Stop the keepalived service above Linux-node1 and then view the status:

[[email protected] cluster]#/etc/init.d/keepalived stop

Stop keepalived: [OK]

Then view the virtual IP status again by command:

[[Email protected] cluster]# IP ad li

2:eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> MTU Qdisc pfifo_fast State up Qlen 1000

Link/ether 00:0c:29:5c:e0:13 BRD FF:FF:FF:FF:FF:FF

inet 10.0.0.7/24 BRD 10.0.0.255 Scope Global eth0

Inet6 FE80::20C:29FF:FE5C:E013/64 Scope link

Valid_lft Forever Preferred_lft Forever


[[Email protected] ~]# IP ad li

2:eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> MTU Qdisc pfifo_fast State up Qlen 1000

Link/ether 00:0c:29:38:4b:e3 BRD FF:FF:FF:FF:FF:FF

inet 10.0.0.8/24 BRD 10.0.0.255 Scope Global eth0

inet 10.0.0.11/32 Scope Global eth0 ==================> virtual IP has drifted above linux-node2

Inet6 FE80::20C:29FF:FE38:4BE3/64 Scope link

Valid_lft Forever Preferred_lft Forever


Old boy Website: http://www.etiantian.org

qq:406564728

Welcome to Exchange

This article is from the "Linux" blog, so be sure to keep this source http://chenjisong.blog.51cto.com/7858025/1714335

Saltstack Configuration Management-Business reference keepalived

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.