2013年2月25日星期一

Puppet Labs : Module of the Week: java_ks – Build Java Keystores From Existing Keys and Certificates

Puppet Labs : Module of the Week: java_ks – Build Java Keystores From Existing Keys and Certificates:
Purpose Build Java keystores form existing keys and certificates.
Module puppet/java_ks
Puppet Version 2.7+
Platforms OpenJDK 6, OpenJDK 7
This module attempts to ease and shorten the workflow associated with Java applications.
  • When building a Java keystore outside of the Java tool chain, you have to go through a process that spans a couple different tools and intermediary formats before you have a valid keystore. The java_ks module attempts to relieve this by giving you one interface: Puppet. Puppet handles the conversion and intermediary formats for you.
  • This module contains no manifests, only a composite namevar type and its supporting provider.
  • This module allows for keystores to be provisioned along with your Puppet deployed Java application servers.
The reason this module came to life was my frustration over the workflow needed to get a SSL protected ActiveMQ broker set up. When I wanted to integrate the Java keystore build workflow into the rest of ActiveMQ’s setup using a Puppet manifest… well, it got ugly. Converting a string of shell commands into Puppet exec resources eventually led me to a dark dark place. Personally I find that if you are running into a need for a lot of exec resources, especially when they are using the same command or operating on the same file, it is time to grab a copy of Puppet Types and Providers and get your hands dirty with some Ruby. You’ll usually notice a speed increase of your agent runs after a conversion to a type/provider to replace all the exec resources and always end up with easier to maintain manifests.


Installing the module

Complexity Easy
Installation Time 10 minutes
Installation is straightforward thanks to the Puppet Forge.
  • Make sure Java is installed on your Java application nodes by installing the “puppetlabs/java” module.


    root@pm01:~# puppet module install puppetlabs/java
    Notice: Preparing to install into /etc/puppet/modules ...
    Notice: Downloading from https://forge.puppetlabs.com ...
    Notice: Installing -- do not interrupt ...
    /etc/puppet/modules
    └─┬ puppetlabs-java (v0.2.0)
      └── puppetlabs-stdlib (v3.2.0)
  • Classify your Java application node (this is probably highly dependent on your organization).


    class { 'java': distribution => 'jre' }
  • Install the java_ks module from the Puppet Forge


    root@pm01:~# puppet module install puppetlabs/java_ks
    Notice: Preparing to install into /etc/puppet/modules ...
    Notice: Downloading from https://forge.puppetlabs.com ...
    Notice: Installing -- do not interrupt ...
    /etc/puppet/modules
    └── puppetlabs-java_ks (v0.0.6)
  • Make sure pluginsync is set to true on your puppet master and agents.

Resource Overview

Java_ks is special in that it uses an uncommonly used feature of Puppet’s resource api, the composite namevar. A composite namevar allows you to construct unique resource definitions from more than one resource parameter. This is employed to overcome the possible need to install the same certificate into multiple keystores from within the same catalog.
Example 1: Defining the resource with an arbitrary title.
java_ks { 'accounting_dev_broker':
  ensure       => latest,
  name         => 'accounting.dev.example.com',
  certificate  => '/etc/ssl/certs/accounting.dev.example.com.crt',
  private_key  => '/etc/ssl/private/accounting.dev.example.com.key',
  target       => '/etc/activemq/broker.jks',
  password     => 'not_so_secret',
}

Example 2: Defining a resource where title maps to name AND target parameters. You’ll notice that “:” is between the fqdn of the cert, which I am using as the name of this resource and the path to the broker.ks file. The “:” is the namevar separator I chose for this type.
java_ks { 'accounting.dev.example.com:/etc/activemq/broker.jks':
  ensure       => latest,
  certificate  => '/etc/ssl/certs/accounting.dev.example.com.crt',
  private_key  => '/etc/ssl/private/accounting.dev.example.com.key',
  password     => 'not_so_secret',
}

Example 3: Build two keystores, one for our activemq broker and another for a Java web application.
java_ks { 'accounting_dev_broker':
  ensure       => latest,
  name         => 'accounting.dev.example.com',
  certificate  => '/etc/ssl/certs/accounting.dev.example.com.crt',
  private_key  => '/etc/ssl/private/accounting.dev.example.com.key',
  target       => '/etc/activemq/broker.jks',
  password     => 'not_so_secret',
}

java_ks { 'accounting_dev_app':
  ensure       => latest,
  name         => 'accounting.dev.example.com',
  certificate  => '/etc/ssl/certs/accounting.dev.example.com.crt',
  private_key  => '/etc/ssl/private/accounting.dev.example.com.key',
  target       => '/etc/tomcat/application.jks',
  password     => 'not_so_secret',
}

Testing the module

Because this module is 100% Ruby, it ships with a set of rspec unit tests.
  • Running tests:
    • Install your operating system’s Ruby Development package.

    • gem install puppetlabs_spec_helper

    • cd /etc/puppet/modules/java_ks
    • rspec spec
  • If tests fail…

Configuring the module

Complexity N/A
Installation Time N/A
This module being just a type and provider means there is not further configuration beyond installation.

Example usage

I illustrated some example usage while we were reviewing the resources earlier. To see this type actually used in the wild, you can take a look at the puppetlabs-operations fork of the puppetlabs-activemq module, which unfortunately isn’t Puppet Forge ready.

Conclusion

This type reduced the number of resources I needed to configure my Java keystore from six to two, one to create the store and then a simple file resource to manage permissions. It also helped readability enormously. Anyone that has ever used an exec resource knows that reading inline bash can be eye straining.
  • Possible improvements
    • The unit tests currently stub the return on some commands and methods more frequently than they should. This reduces the validity of the tests when applied to a real world environment.
    • Passwords for private keys and keystores are currently set to the same thing. This means you need to either know the password to the private key and use it when you create the keystore or you need to strip the password from the private key.

Learn More

2013年2月21日星期四

How Quantum Computers (will) work [Tech]

How Quantum Computers (will) work [Tech]: I enclosed "will" in parenthesis simply because quantum computers are already here - They are just still not a commercial product (unless you're...[Read more]

2013年2月19日星期二

Canonical 发布 Ubuntu 平板操作系统,支持多任务和语音控制,本周四将放出 Nexus 可用 ROM

Canonical 发布 Ubuntu 平板操作系统,支持多任务和语音控制,本周四将放出 Nexus 可用 ROM:
没有太多悬念,Ubuntu 官方网站的倒计时宣告发布的正是 Ubuntu 平板操作系统,功能界面和体验上基本和 Ubuntu 手机版的操作系统一致,均是内容为王的概念,整个系统的特色是基本看不到所谓的操作界面。Ubuntu 的移动设备系统本周四即可下载 ROM 刷机体验,感兴趣的读者请稍后留意。

Ubuntu 平板的几个特色功能,我们一起来看看吧!(转到页面底部看介绍视频

多任务运行 “Side Stage” ,类似于 Windows 8 应用程序的停靠功能

Ubuntu 平板系统能很好地支持多任务功能,支持 Side Stage 的应用程序可以拖动停靠到屏幕右侧显示,此时桌面可同时使用两个应用,就像分屏操作一样,应用程序之间的复制粘贴也变得更便捷,不需要来回跳转:



访客模式 “Safer sharing”,和桌面电脑一样,可以共享使用。

平板电脑是很好的大屏幕娱乐设备,但像 iPad 那样,通常还会加上密码锁,不能很放心地借给他人使用。Ubuntu 平板电脑和它的手机版一样,没有锁屏概念,只有欢迎屏幕!直接使用访客模式登入使用即可。除了访客帐号,还支持多帐号登入,每个帐号下的文件是加密存储的,以保证信息安全。

语音控制 HUD

Ubuntu HUD 是一项语音控制功能,将设备停靠在 Dock 上使用操作依然流畅。



强大的搜索和丰富的线上内容

“Savvy search” 能够整合线上线下多个数据源,提供最为满意的搜索结果;同时主屏的内容也整合了数百个线上资源,可方便定制和展示最重要的信息,所有内容都触手可及,不需要在单独应用内容分开查找。Ubuntu 平板可用原生应用程序一下子还不会很多,整合大量网络资源是其很大的卖点。



社会化分享和云服务集成

Ubuntu 平板系统集成主流的社交平台分享功能,可将便捷分享给家人朋友和同事;同时还可以整合了云存储,付费流媒体内容和企业及定制厂商云服务。



边缘滑动操作

Ubuntu 平板的系统界面布局有点“混血”的感觉,操作学习上成本不高,因为很多地方都有似曾相识,左侧滑入呼出是应用启动栏,就像 Mac 的 Dock 类似;顶部下滑调出系统通知,几乎所有手机操作系统支持这个操作;底部滑动是应用操作控件,和 Windows 的任务栏一样。

运行桌面应用程序,甚至是虚拟机运行其他操作系统

Ubuntu 平板系统支持 ARM 和 X86 硬件构架,后者能运行所有 Ubuntu 桌面系统的应用程序,包括虚拟化软件,在视频演示中也提到了这一点。

硬件方面,Ubtuntu 平板系统支持最高 450 PPI 的 6 寸到 20 寸的屏幕,支持外接屏幕和键盘。

Ubuntu 平板系统介绍视频


除非注明,本站文章均为原创或编译,转载请注明: 文章来自 36氪

36氪官方iOS应用正式上线,支持『一键下载36氪报道的移动App』和『离线阅读』 立即下载!

在 PMML 中表现预言性解决方案

在 PMML 中表现预言性解决方案: PMML,即 Predictive Model Markup Language,是用于表现无数预言性建模技术的事实标准,这些技术包括 Association Rules、Cluster Models、Neural Networks
和 Decision Trees。通过这些技术,全球公司能够从数据中发现隐藏的模式,并使用它们预报行为。在本文中,我们首先介绍这个标准直接支持的预言性建模技术。然而,由于预言性解决方案远不止于它所依赖的统计技术,所以我们接着通过阐述用于表现完整预言性解决方案的数据预处理和 PMML
建模的使用方法来深入分析语言,并介绍其用于处理数据的转换与功能。