使用Fabric部署和管理Propertyshelf Plone应用程序。
项目描述
propertyshelf.fabfile.plone
该项目包含我们在Propertyshelf使用的fabric命令,用于部署和维护我们的Plone CMS系统。
要求
propertyshelf.fabfile.plone目前使用knife与Rackspace服务器通信。请确保您的系统已成功安装并配置了knife。
安装
您可以使用PIP安装propertyshelf.fabfile.plone
pip install propertyshelf.fabfile.plone
所有必需的依赖项将自动安装。
用法
首先,我们需要一个可工作的 knife.rb 文件来与我们的 Chef 服务器和 Rackspace 云生态系统交互。下面是一个示例 knife.rb 文件,它从环境变量中获取所有所需信息。这样,您可以将此 knife.rb 文件添加到您的项目中的 .chef 目录,并安全地将其置于版本控制之下
# Logging. log_level :info log_location STDOUT # Chef server configuration. chef_server_url "#{ENV['KNIFE_CHEF_SERVER']}" client_key "#{ENV['KNIFE_CLIENT_KEY']}" node_name "#{ENV['KNIFE_NODE_NAME']}" validation_client_name "#{ENV['KNIFE_VALIDATION_CLIENT_NAME']}" validation_key "#{ENV['KNIFE_VALIDATION_CLIENT_KEY']}" encrypted_data_bag_secret "#{ENV['ENCRYPTED_DATA_BAG_SECRET_FILE']}" # Rackspace API configuration. knife[:rackspace_api_key] = "#{ENV['RACKSPACE_API_KEY']}" knife[:rackspace_api_username] = "#{ENV['RACKSPACE_USERNAME']}" knife[:rackspace_endpoint] = "#{ENV['RACKSPACE_ENDPOINT']}" knife[:rackspace_version] = "#{ENV['RACKSPACE_VERSION']}"
接下来,我们需要一个 fabfile.py 文件。我们只需要导入 propertyshelf.fabfile.plone 来使 fabric 命令可用,并且我们可以从 propertyshelf.fabfile.common 中使用的工作环境。
# -*- coding: utf-8 -*- """Sample application deployment script.""" from fabric import api from propertyshelf.fabfile.common.environments import * from propertyshelf.fabfile.plone import * # Definition of role names to be used. api.env.role_base = 'plone_01' api.env.role_database = '%s_database' % api.env.role_base api.env.role_frontend = '%s_frontend' % api.env.role_base api.env.role_worker = '%s_worker' % api.env.role_base # Definition of used Rackspace flavors (server sized) for our servers. api.env.flavor_database = '4' api.env.flavor_frontend = '2' api.env.flavor_worker = '2' # Definition of node names to be used. BASE_NODENAME = 'plone-01' api.env.nodename_database = '%s-database' % BASE_NODENAME api.env.nodename_frontend = '%s-frontend' % BASE_NODENAME api.env.nodename_worker = '%s-worker' % BASE_NODENAME api.env.nodename_development = BASE_NODENAME # The Rackspace server image we use. This is a Debian 6.0.6. api.env.os_image = '695ca76e-fc0d-4e36-82e0-8ed66480a999' api.env.domain = 'example.com' api.env.vhost_databag = 'virtual_hosts_plone_01' api.env.plone_version = '4.3.2'
现在,您可以使用 fabric 来管理您的 Plone 应用程序
$ fab -l Sample application deployment script. Available commands: development Work locally with vagrant. production Work with the production environment. staging Work with the staging environment. bootstrap.database Bootstrap a new standalone database server. bootstrap.frontend Bootstrap a new standalone frontend server. bootstrap.plone_m Bootstrap a new 'Plone M' bundle. bootstrap.staging Bootstrap a staging system. bootstrap.worker Bootstrap a new standalone application worker. client.rebuild Rebuild the application using buildout. client.remove Remove an existing MLS application client. client.restart Restart the application client component. client.update Update the client packages. database.download_blobs Download blob part of Zope's data from the server. database.download_data Download the database files from the server. database.download_zodb Download ZODB part of Zope's data from the server. database.restart Restart the database component. database.upload_blob Upload blob part of Zope's data to the server. database.upload_data Upload the database files to the server. database.upload_zodb Upload ZODB part of Zope's data to the server. frontend.restart Restart the frontend components. frontend.restart_haproxy Restart the HA-Proxy load balancer component. frontend.restart_nginx Restart the NginX web server component. frontend.restart_varnish Restart the Varnish caching proxy component. roles.check Check if the required roles are available. roles.create_missing Create missing roles on the chef server. roles.list_nodes List all available nodes with given roles.
在我们开始之前,检查我们定义的所有角色是否都可在 chef 服务器上可用是个好主意
$ fab roles.check Role plone_01 NOT available. Role plone_01_database NOT available. Role plone_01_frontend NOT available. Role plone_01_worker NOT available. Done.
为了根据我们的配置创建缺少的角色,我们只需执行以下操作
$ fab roles.create_missing Created role plone_01 Created role plone_01_database Created role plone_01_frontend Created role plone_01_worker Done.
现在,您可以管理单个组件
$ fab production frontend.restart [x.x.x.x] Executing task 'frontend.restart' [x.x.x.x] sudo: /etc/init.d/haproxy restart [x.x.x.x] out: sudo password: [x.x.x.x] out: Restarting haproxy: haproxy. [x.x.x.x] out: [x.x.x.x] sudo: /etc/init.d/varnish restart [x.x.x.x] out: sudo password: [x.x.x.x] out: Stopping HTTP accelerator: varnishd. [x.x.x.x] out: Starting HTTP accelerator: varnishd. [x.x.x.x] out: [x.x.x.x] sudo: /etc/init.d/nginx restart [x.x.x.x] out: sudo password: [x.x.x.x] out: Restarting nginx: nginx. [x.x.x.x] out: Done. Disconnecting from x.x.x.x... done.
我们还支持下载数据库文件以进行本地测试
$ fab production database.download_data [x.x.x.x] Executing task 'database.download_data' This will overwrite your local Data.fs. Are you sure you want to continue? [Y/n] [localhost] local: mkdir -p var/filestorage [localhost] local: mv var/filestorage/Data.fs var/filestorage/Data.fs.bak [x.x.x.x] out: sudo password: [x.x.x.x] sudo: rsync -a var/filestorage/Data.fs /tmp/Data.fs [x.x.x.x] out: sudo password: [x.x.x.x] out: [x.x.x.x] download: /Volumes/Work/Propertyshelf/Plone/Provisioning/var/filestorage/Data.fs <- /tmp/Data.fs This will overwrite your local blob files. Are you sure you want to continue? [Y/n] [localhost] local: rm -rf var/blobstorage_bak [localhost] local: mv var/blobstorage var/blobstorage_bak [x.x.x.x] sudo: rsync -a ./var/blobstorage /tmp/ [x.x.x.x] out: sudo password: [x.x.x.x] out: [x.x.x.x] sudo: tar czf blobstorage.tgz blobstorage [x.x.x.x] out: sudo password: [x.x.x.x] out: [x.x.x.x] download: /Volumes/Work/Propertyshelf/Plone/Provisioning/var/blobstorage.tgz <- /tmp/blobstorage.tgz Warning: Local file /Volumes/Work/Propertyshelf/Plone/Provisioning/var/blobstorage.tgz already exists and is being overwritten. [localhost] local: tar xzf blobstorage.tgz Done. Disconnecting from x.x.x.x... done.
贡献者
Thomas Massmann,作者
变更日志
0.1 (2013-12-20)
添加了 Plone 应用的基本部署和管理命令。
项目详情
关闭
propertyshelf.fabfile.plone-0.1.tar.gz 的散列值
算法 | 散列摘要 | |
---|---|---|
SHA256 | ffb4e47a85e31e878c27e93cd14f224f4507160e5ac9272b46dea36784c4fc9e |
|
MD5 | f30c9874d0c9a494800c1a0de650a224 |
|
BLAKE2b-256 | b6606eb1d1dbbface6f466edfdd3d7de4f8d188678de30cbd11b26418e2f850f |