-
It’s in pull mode
-
It is convenient to configure in text mode, which facilitates configuration versioning
-
There are too many plugins. What do you want to monitor
-
I basically have to relearn all three, so why don’t I learn one recommended by Google SRE?
-
Prometheus Server monitors data collection and storage
-
Prometheus Alert Manager generates alarms based on alarm rules and integrates multiple alarm channels
-
Node-exporter’s role [1] is to read indicators from the machine and expose an HTTP service from which Prometheus collects monitoring indicators. Of course Prometheus officially had a variety of exporters.
├── Environment / # Parent Directory for Our Environment-Specific directories│ │ ├─ dev/ # Contains all files directories To the dev environment│ ├─ group_vars/ # dev specific group_vars files│ │ ├─ all│ │ ├─ db│ │ ├─ web│ ├─ Hosts # Contains only the hosts in the dev environment│ │ ├─ prod/ # Contains all files specific to the PROd Environment │ ├── ├─ all│ ├─ db│ ├─ web│ ├─ └ # Contains only the hosts in the prod environment│ ├ ─ stage/ # Contains all files specific to the stage environment│ ├── all│ ├─ db│ ├─ web│ ├─ hosts # Contains only the hosts In the stage of environment │
Copy the code
---- hosts: all vars: jenkins_plugins: - blueocean - ghprb - greenballs - workflow-aggregator jenkins_plugin_timeout: 120 pre_tasks: - include_tasks: java-8.yml roles: - geerlingguy.java - ansible-role-jenkins
Copy the code
-
Interface Settings
-
A text file similar to a Dockerfile. Using a Jenkinsfile[7]
pipeline { agent any stages { stage('Build') { steps { sh './gradlew clean build' archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true } } }}
Copy the code
-
Install Ansible in Jenkins [8]
-
Execute in Jenkinsfile
withCredentials([sshUserPrivateKey(keyFileVariable:"deploy_private",credentialsId:"deploy"),file(credentialsId: 'vault_password', variable: 'vault_password')]) { ansiblePlaybook vaultCredentialsId: 'vault_password', inventory: "environments/prod", playbook: "playbook.yaml", extraVars:[ ansible_ssh_private_key_file: [value: "${deploy_private}", hidden: true], build_number: [value: "${params.build_number}", hidden: false] ]}
Copy the code
-
AnsiblePlaybook is a pipeline syntax provided by the Jenkins Ansible plugin, similar to manual execution: ansiblePlaybook.
-
WithCredentials is the syntax of the Credentials Binding[9] plug-in and is used to reference sensitive information, such as SSH keys and Ansible Vault passwords required for performing Ansible.
-
Some sensitive configuration variables are encrypted using Ansible Vault[10] technology.
-
Superbase monitoring
-
On Gitlab
-
Go to Jenkins and integrate with Gitlab
-
Use Jenkins to achieve automatic compilation and packaging
-
Use Jenkins to perform Ansible
-
CMDB construction: We use Ansible-CMDB [12] to automatically generate all current machines from inventory
-
Release management: You can customize each stage of a release on Jenkins. Publishing methods such as blue-green publishing can be implemented by modifying Ansible scripts and Inventory.
-
Automatic capacity expansion: This function is implemented by configuring Prometheus alarm rules and calling the corresponding Webhook
-
ChatOps: Actual ChatOps [13]
Related links:
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/