小团队如何从零搭建一个自动化运维体系?
类似这样:
但是,怎么用呢?我们会在打包阶段将 Ansible 目录进行 zip 打包,到真正部署时,再解压执行里面的 playbook。 快速为所有的项目生成 Ansible 脚本及Jenkinsfile 上面,我们将一个项目进行 Jenkins 化和 Ansible 化,但是我们还有很多项目需要进行同样的动作。 考虑到这是体力活,而且以后我们还会经常做这样事,所以我决定使用 cookiecutter[11] 技术自动生成 Jenkinsfile 及 Ansible 脚本,创建一个项目,像这样:
小结 总结下来,我们小团队的自动化运维实施的顺序大概为: 上基础监控 上 Gitlab 上 Jenkins,并集成 Gitlab 使用 Jenkins 实现自动编译打包 使用 Jenkins 执行 Ansible 以上只是一个架子,基于这个“架子”,就可以向那些大厂高大上的架构进行演进了,比如: CMDB 的建设:我们使用 ansible-cmdb[12] 根据 inventory 自动生成当前所有机器的情况。 发布管理:Jenkins 上可以对发布的每个阶段进行定制。蓝绿发布等发布方式可以通过修改 Ansible 脚本和 Inventory 实现。 自动扩缩容:通过配置 Prometheus 告警规则,调用相应 webhook 就可以实现。 ChatOps:ChatOps 实战[13]。 以上就是我关于自动化运维的一些实践,但是还在演进的路上,希望能与大家交流。 相关链接: [1]https://github.com/prometheus/node_exporter [2]https://github.com/ernestas-poskus/ansible-prometheus [3]https://github.com/timonwong/prometheus-webhook-dingtalk [4]https://www.digitalocean.com/community/tutorials/how-to-manage-multistage-environments-with-ansible [5]http://docs.ansible.com/ansible/latest/modules/consul_module.html [6]https://github.com/geerlingguy/ansible-role-jenkins [7]https://jenkins.io/doc/book/pipeline/jenkinsfile/ [8]https://wiki.jenkins.io/display/JENKINS/Ansible+Plugin [9]https://jenkins.io/doc/pipeline/steps/credentials-binding/ [10]http://docs.ansible.com/ansible/2.5/user_guide/vault.html [11]https://github.com/audreyr/cookiecutter [12]https://github.com/fboender/ansible-cmdb [13]https://showme.codes/2017-10-08/chatops-in-action/ (编辑:网站开发网_马鞍山站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |