Name Last Update
inventories Loading commit data...
playbooks Loading commit data...
roles Loading commit data...
scripts Loading commit data...
.gitmodules Loading commit data...
ansible.cfg Loading commit data...
mysql_failover.sh Loading commit data...
readme.md Loading commit data...
requirements.yml Loading commit data...
site.yml Loading commit data...
switch.md Loading commit data...

YOHO ANSIBLE ROLES


更新代码


# 第一次 clone
git clone --recursive 

# 更新 submodule
git submodule foreach git pull origin master
git add .
git commit -m "update submodule"
git push

准备ansible的环境

1.安装ansible

2.yoho_server copy 到 ~/.ssh/

3.git clone --recursive 本项目即可

playbook介绍

playbook 说明
authkey copy 公钥到目标机器sshauthorized_keys中。 -- 建立信任关系
vault-test 测试hashicorp vault的集成。-- 避免将敏感信息写入到配置中
java.health_check 通过http接口检查java服务的健康情况
lb-manager 修改qcloud 负载均衡器的权重
java-loglevel 修改java服务的日志级别
java-nginx 同步java nginx的配置
java-restart-service 重启java服务
ping ping, 测试用
java-resolv 修改目标机器的/etc/resolv文件
cobar.reload 刷新cobar server的配置
yoho.dns 刷新dns server (bind9)的配置
yoho.dns.mysql_read_to_master MySQL数据库读切换到主库。Note: 切换后需要reload cobar
java-rsyslog 同步java服务的rsyslog客户端配置
java.inner.switch 修改api.yoho.cn 流量部分到aws
wechat.cert.sync 同步微信支付证书
crm-nginx.yml 同步CRM,线下店 nginx
platform-nginx.yml 同步platform nginx

hashicorp vault 配置

Why: credentials 信息统一管理

服务器地址: 10.66.107.2

如何运行

jump to server: root@10.66.233.9

目录: /root/ansible/yoho-ansible-roles

# run playbooks
ansible-playbook  -i inventories/az3/hosts  playbooks/ping.yml

# run command
ansible all -m shell -a "cat /etc/resolv.conf"  -i inventories/az3/hosts

#remove service
ansible-playbook -i inventories/test/remove_az1.ini   playbooks/java.remove_service.yml  --extra-vars "service=order"

# check the last 2 line logs
ansible gateway -i inventories/test/remove_az1.ini -m shell -a "tail -n 2 /Data/logs/gateway/debug.log"

#filebeat for java nginx
ansible-playbook -i inventories/az1/hosts   playbooks/java-filebeat.yml  --extra-vars "groups=java-nginx config_group=java-nginx"


# check and diff
ansible-playbook playbooks/yoho.dns.yml  -i inventories/az1/hosts  --diff --check --extra-vars "@inventories/az1/group_vars/all.yml"