Rails 堆栈的 Puppet 设置示例? (nginx、varnish、thin、postgres、memcached、redis)

发布于 2024-11-03 14:07:47 字数 280 浏览 0 评论 0 原文

我刚刚开始使用 Puppet。示例演练和教程很好地帮助我理解 Puppet 的实用性和基本工具集,但我很难概念化完整的堆栈。即使是高级教程似乎也没有让我清楚地了解需要发生什么。

有没有我可以学习的 Rails 堆栈的完整示例?

I'm just getting started with Puppet. The example walkthroughs and tutorials were good at helping me understand Puppet's usefulness and the basic toolset, but I'm having a hard time conceptualizing a full stack. Even the advanced tutorial didn't seem to give me a clear picture of what needs to happen.

Are there any full examples of a rails stack somewhere that I could learn from?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凯凯我们等你回来 2024-11-10 14:07:47

完整堆栈的例子很难找到。但是,您应该能够找到管理其中一些特定示例的模块示例。一个问题是,创建一个抽象出所有特定于站点的假设并且真正跨平台的模块可能需要大量额外的工作。

http://forge.puppetlabs.com/ 是人们希望共享的模块的规范位置。通过快速扫描,我找到了 nginx清漆postgres >。

您需要从Puppet 最佳实践开始进行基本设置。

从那里,您将(至少)需要一个用于 nginx、varnish、thin、postgres、memcached、redis 的模块和一个站点模块(可能以您的站点命名)。

在您的nodes.pp 中,每个系统都会有一个相当简单的角色分配。 (“包含角色”)

在您的“站点”模块中,您需要为每个系统角色都有一个子类(我假设您将拥有多组服务器,并且在一组服务器中,它们旨在我还假设您可能包含以上其中一项以上)。您可能还需要一个 site::commonvariables 类(或类似的东西)来存储您在多个其他模块或类中可能需要的内容(例如角色中的服务器列表、密码等)。最佳实践似乎将这些 site::role 内容放在 /services 辅助模块区域中,其名称更像 s_role,因此您可能需要遵循该命名/放置方案。这些角色类将包括这些角色所需的实际组件的类、调用定义等。

对于您提到的 6 个组件中的每一个,您都将有一个模块。在该模块中,您可能想要拥有诸如“服务器”和“客户端”子类之类的东西。客户端和服务器可能包含第三个类,用于两者所需的东西(公共库等)。在服务器子类中,定义了设置特定实例(虚拟主机、数据库等)的定义。 (如果它绝对只是一个服务器,也许可以跳过该级别的子类化)。

例如:

  • postgres 模块(清单、文件、模板等)
    • postgres 类(在 init.pp 中):可能是空类,可能是客户端和服务器需要的东西
      • postgres::client 类:安装 postgres 客户端库
      • postgres::server 类:安装 postgres 服务器代码,确保 postgres 服务正在运行,配置它,设置备份等
        • postgres::server::database Define:在服务器类中,一个定义,它接受数据库名称、用户名、密码等参数,并创建数据库和用户,并授予用户对数据库的访问权限。也许这是两个或三个单独的定义,具体取决于您喜欢如何建模。

最好让组件模块保持相当独立(并且可重用),并且您的角色类是所有特定于站点的配置发生的地方,但如果您的组件模块包含一些特定于站点的内容,那也不是世界末日。

Examples of a full stack are hard to come by. You should be able to find examples of modules that manage some of those specific examples, however. One problem is that it can be a lot of extra work to create a module that has abstracted away all site-specific assumptions and that is truly cross-platform.

http://forge.puppetlabs.com/ is the canonical location for modules that people wish to share. With a quick scan I found modules for nginx, varnish, and postgres.

You'll want to start with the Puppet Best Practices for the basic setup.

From there, you're going to (at least), want a module for nginx, varnish, thin, postgres, memcached, redis, and a site module (probably named after your site).

In your nodes.pp, each system will have a fairly simple assignment to a role. ("include role")

In your "site" module, you'll want a sub-class for each system role (I'm assuming you'll have multiple sets of servers, and that within a set, they are intended to be basically identical to each other. I'm also assuming that you're likely to have more than one of the above included). You may also want a site::commonvariables class (or something like that) for things (such as lists of servers in a role, passwords, etc) that you may need across multiple other modules or classes. The best practices seem to have these site::role things in a /services secondary module area with names more like s_role, so you may want to follow that naming/placement scheme instead. These role classes will include the classes for the actual components that are needed on those roles, call defines, etc.

For each of the 6 components you mention, you'll have a module. Within that module, you're likely to want to have something like a "server" and "client" subclass. And possibly a third class included by client and server for things needed by both (common libraries, etc). And within the server subclass, a define that sets up specific instances (virtualhosts, databases, etc). (if it's absolutely only ever a server, maybe skip that level of subclassing).

So, for example:

  • postgres module (manifests, files, templates, etc)
    • postgres class (in init.pp): maybe empty class, maybe things needed by client and server
      • postgres::client class: install postgres client libraries
      • postgres::server class: install postgres server code, make sure postgres service is running, configure it, set up backups, etc
        • postgres::server::database define: inside the server class, a define that takes parameters such as database name, username, password, and creates the database and user and gives the user access to the DB. Maybe this is two or three separate defines, depending on how you prefer to model things.

It's best if the component modules are kept fairly independent (and reusable) and your role classes is where all the more site-specific configuration happens, but it's not the end of the world if your component modules include some site-specific stuff.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文