# raycloud-ops-ansible **Repository Path**: wanglei_storage/raycloud-ops-ansible ## Basic Information - **Project Name**: raycloud-ops-ansible - **Description**: No description available - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-10-17 - **Last Updated**: 2024-10-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 主机分类说明 ```bash # 通过云平台 # 每个云平台下的所有主机列表 -i inventory/platform.yml # 通过业务线 # 每个业务线下的所有主机列表 -i inventory/business.yml # 通过使用方式-容器节点 # 所有容器集群中存在的主机列表 -i inventory/container.yml # 通过使用方式-tomcat节点 # 所有发布系统中部署了Tomcat记录主机列表。过滤关键字(部署成功|非过期|OPS中存在的|已知)数据之后的列表 -i inventory/tomcat.yml # 通过云平台+业务线(所有机器) -i inventory/platform.yml -i inventory/business.yml - hosts: jst:&kmls # 通过云平台+业务线(tomcat机器) -i inventory/platform.yml -i inventory/tomcat.yml - hosts: jst:&kmls # 通过云平台+业务线(容器机器) -i inventory/platform.yml -i inventory/container.yml - hosts: jst:&kmls ```
## 剧本分类说明 ```bash # 多平台管理hosts剧本 hosts.yml # 多平台管理 项目监控脚本/arthas/skywalking/agent 剧本 tomcat.yml # 任务测试剧本 testing.yml ```
## Usage #### 任务使用说明 ```bash $ ansible-playbook [剧本文件] -i [主机分组] [参数] $ ansible-playbook [playbooks] -i [inventory] [params] # 常见参数 --help # 查看帮助 --list-tags # 查看任务标签列表 --list-tasks # 查看任务jobs列表 --list-hosts # 查看任务主机列表 --syntax-check # 校验任务语法 --check # 不做任何变更,试着预测一些可能发生的变化 --diff # 显示差异化的变更数据 ``` #### 多平台-tomcat项目hosts下发 检测 /etc/hosts 保持所有节点一致性 ```bash # 查看标签 $ ansible-playbook playbooks/hosts.yml -i inventory/platform.yml --list-tags # 多平台 $ ansible-playbook playbooks/hosts.yml -i inventory/platform.yml # 单平台-抖店云 $ ansible-playbook playbooks/hosts.yml -i inventory/platform.yml --tags ddy # 单平台-阿里云 $ ansible-playbook playbooks/hosts.yml -i inventory/platform.yml --tags aly # 单平台-聚石塔 $ ansible-playbook playbooks/hosts.yml -i inventory/platform.yml --tags jst # 单平台-京东云 $ ansible-playbook playbooks/hosts.yml -i inventory/platform.yml --tags jdy ``` #### 多平台-tomcat项目配置下发 检测下面几个agent,保持所有节点的一致性 - agent monitor - agent arthas - agent skywalking ```bash # 查看标签 $ ansible-playbook playbooks/tomcat.yml -i inventory/platform.yml --list-tags # 多平台 $ ansible-playbook playbooks/tomcat.yml -i inventory/platform.yml # 单平台-抖店云 $ ansible-playbook playbooks/tomcat.yml -i inventory/platform.yml --tags ddy # 单平台-阿里云 $ ansible-playbook playbooks/tomcat.yml -i inventory/platform.yml --tags aly # 单平台-聚石塔 $ ansible-playbook playbooks/tomcat.yml -i inventory/platform.yml --tags jst # 单平台-京东云 $ ansible-playbook playbooks/tomcat.yml -i inventory/platform.yml --tags jdy ``` #### 系统初始化 ```bash # 初始化系统 $ ansible-playbook playbooks/init_system.yml -i inventory/platform.yml -e target_host=192.168.68.29 ``` #### JDK 安装 ```bash # 安装主机的jdk环境 $ ansible-playbook playbooks/init_jdk.yml -i inventory/platform.yml -e target_host=192.168.83.223 ``` #### kubelet 内存/磁盘配置下发 ```bash $ ansible-playbook playbooks/container.yml -i inventory/container.yml ``` #### filebeat nginx 日志收集 ```bash $ action: add(新增节点), update(更新配置), exclude(排除节点) $ ansible-playbook playbooks/qjj.yml -i inventory/qjj.yml -e action=update -e target=x.x.x.x ``` #### elasticsearch 集群管理 ```bash # 安装/新增集群 $ ansible-playbook playbooks/es_cluster_7.yml -i inventory/es_cluster_7/aly_erp_api $ ansible-playbook playbooks/es_cluster_7.yml -i inventory/es_cluster_7/aly_erp_log $ ansible-playbook playbooks/es_cluster_7.yml -i inventory/es_cluster_7/aly_erp_report $ ansible-playbook playbooks/es_cluster_7.yml -i inventory/es_cluster_7/aly_erp_supply $ ansible-playbook playbooks/es_cluster_7.yml -i inventory/es_cluster_7/aly_gdb_trade $ ansible-playbook playbooks/es_cluster_7.yml -i inventory/es_cluster_7/aly_gdb_log $ ansible-playbook playbooks/es_cluster_7.yml -i inventory/es_cluster_7/aly_kdzs $ ansible-playbook playbooks/es_cluster_7.yml -i inventory/es_cluster_7/aly_yunwei $ ansible-playbook playbooks/es_cluster_7.yml -i inventory/es_cluster_7/aly_zt $ ansible-playbook playbooks/es_cluster_7.yml -i inventory/es_cluster_7/ddy_erp_log $ ansible-playbook playbooks/es_cluster_7.yml -i inventory/es_cluster_7/ddy_gdb_trade # 更新配置 $ ansible-playbook playbooks/es_cluster_7.yml -i inventory/es_cluster_7/aly_kdzs -e action=update # 更新配置-只查看变更任务和变更内容,不做具体应用 $ ansible-playbook playbooks/es_cluster_7.yml -i inventory/es_cluster_7/aly_kdzs -e action=update -e target=all --check --diff # 下线节点 $ ansible-playbook playbooks/es_cluster -i inventory/es_cluster_7/aly_kdzs -e action=exclude ``` #### 王磊测试用 ```bash $ ansible-playbook playbooks/testing.yml -i inventory/platform.yml ```
## 常见问题 #### 对执行失败的主机重新执行任务 ```bash $ ansible-playbook playbooks/tomcat.yml -i inventory/platform.yml --tags ddy --limit @/root/ansible/.ansible-retry/tomcat.retry ```