ansible代码发布工具
I recently discovered Opbeat. It seems to be a simple (and free/cheap) alternative to Newrelic, at least if you’re using Django.
我最近发现了Opbeat 。 至少在使用Django的情况下,它似乎是Newrelic的一种简单(免费/便宜)的替代方案。
Ansible配置 (Ansible Configuration)
If you use Ansible for deployment, you can implement the release tracking with a handler for the git checkout module.
如果使用Ansible进行部署,则可以使用git checkout模块的处理程序来实现发布跟踪。
First of all, define some useful Ansible variables:
首先,定义一些有用的Ansible变量:
git_targetgit_target : : 'master'
'master'
opbeat_org_idopbeat_org_id : : '...'
'...'
opbeat_app_idopbeat_app_id : : '...'
'...'
opbeat_secret_tokenopbeat_secret_token : : '...'
'...'
Then, change your git checkout command to look similar to this:
然后,将您的git checkout命令更改为类似于以下内容:
There are three important things to note:
有三件事要注意:
- The git version is specified as a variable. That variable can then be used in the handler as well. Usually this is the master branch.
- The return value by this command is registered in the git_status variable.
- The register opbeat release handler is called when changes are pulled from your git repository server.
- git版本被指定为变量。 然后,该变量也可以在处理程序中使用。 通常这是主分支。
- 该命令的返回值注册在git_status变量中。
- 从git存储库服务器中提取更改时,将调用register opbeat release处理程序。
The handler looks like this:
该处理程序如下所示:
- - namename : : register opbeat release
register opbeat release
uriuri :
:
urlurl : : 'https://intake.opbeat.com/api/v1/organizations/{{'https://intake.opbeat.com/api/v1/organizations/{{ opbeat_org_idopbeat_org_id }}/apps/{{}}/apps/{{ opbeat_app_idopbeat_app_id }}/releases/'
}}/releases/'
methodmethod : : POST
POST
status_codestatus_code : : 202
202
HEADER_AuthorizationHEADER_Authorization : : 'Bearer'Bearer {{{{ opbeat_secret_tokenopbeat_secret_token }}'
}}'
HEADER_Content-TypeHEADER_Content-Type : : 'application/x-www-form-urlencoded'
'application/x-www-form-urlencoded'
bodybody : : 'rev={{'rev={{ git_status.aftergit_status.after }}&branch={{}}&branch={{ git_targetgit_target }}&status=completed'
}}&status=completed'
That’s it, all deployments should now be registered as a new release.
就是这样,所有部署现在都应该注册为新版本。
翻译自: https://www.pybloggers.com/2015/03/opbeat-release-tracking-with-ansible/
ansible代码发布工具