Created
May 20, 2015 06:29
-
-
Save Ara4Sh/74727e29964384fcfd22 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
LB_name = 'HA_Servers' | |
LB_user = 'root' | |
LB_hosts = ['node1','node2'] | |
LB_mapping = { | |
'node1': ('172.20.4.40'), | |
'node2': ('172.20.4.49') | |
} | |
HA_maxconn = '20000' | |
HA_bind_ip = '172.20.4.50:80' | |
HA_balance_type = 'roundrobin' #leastconn | |
HA_cvip = '172.20.4.50' | |
HA_domain_name = 'www1.arash.com' | |
HA_servers = { | |
'www1': ('172.20.4.46:80'), | |
'www2': ('172.20.4.47:80'), | |
'www3': ('172.20.4.48:80') | |
} | |
HA_stats_status = 'enable' | |
HA_stats_auth = 'arash:arashshams' | |
KA_notif_email = 'ara4sh@hotmail.com' | |
KA_notif_email_from = 'araxshams@gmail.com' | |
KA_router_id = 'haproxy' | |
KA_interfaces = 'eth0' | |
KA_priority = { | |
'node1': ('101'), | |
'node2': ('102') | |
} | |
KA_auth_pass = 'arashshams123' |
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
haproxy_cfg = global | |
log /dev/log local0 | |
log /dev/log local1 notice | |
chroot /var/lib/haproxy | |
user haproxy | |
group haproxy | |
daemon | |
maxconn %{HA_maxconn} | |
defaults | |
log global | |
mode http | |
option httplog | |
option dontlognull | |
option forwardfor | |
option http-server-close | |
contimeout 5000 | |
clitimeout 50000 | |
srvtimeout 50000 | |
retries 3 | |
option redispatch | |
errorfile 400 /etc/haproxy/errors/400.http | |
errorfile 403 /etc/haproxy/errors/403.http | |
errorfile 408 /etc/haproxy/errors/408.http | |
errorfile 500 /etc/haproxy/errors/500.http | |
errorfile 502 /etc/haproxy/errors/502.http | |
errorfile 503 /etc/haproxy/errors/503.http | |
errorfile 504 /etc/haproxy/errors/504.http | |
frontend http-in | |
bind %{HA_bind_ip} | |
mode http | |
# default_backend host_httpd-in | |
acl host_http-in hdr(host) -i %{HA_domain_name} | |
use_backend host_httpd-in if host_http-in |
f = open('1.txt', 'r')
value = {'maxconn':None, 'bind':None, 'acl':None}
for line in f:
data = line.strip().split()
try:
if data[0] in value:
value[data[0]] = data[-1]
except:
pass
f.close()
print value
ممنون الان تست میکنم
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
خوب به نظرم این راه ساده و بیدردسره:
از format استفاده کن و توی فایل دوم جاهایی که میخوای نوشته بشن رو مثل همین الان با {} مشخص کن (البته بدون %) . بعد توی فایل اول هم یه دی
که dict_of_placeholders_and_values باید یه همچین چیزی باشه