官术网_书友最值得收藏!

Profiles

First, let's take a step back and consider what we want to achieve with profiles.

The overarching exercise is to produce usable chunks of technology that can be fitted together, in a building-brick fashion, to compose what we call in the industry these days technology stacks or solution stacks. The most well-known example of a stack would be the LAMP stack (Linux, Apache, MySQL, PHP), and more recently, Ruby or Python have sometimes superseded PHP as the primary scripting language. Node.js is being rapidly adopted across the industry, too.

Considering the LAMP stack, what we want to do is create chunks of technology for the Apache, MySQL, and PHP components. Profiles are, therefore, these smaller chunks of technology that will eventually comprise these full solution stacks. Profiles are the three building bricks that we piece together, as follows:

Let's look at this LAMP stack with some fully functional Puppet domain specific language (DSL) code:

# LAMP stack profiles


# apache profile
class profile::web::apache (
String $directory = '/var/www',
String $vhost,
) {
include apache
apache::vhost { $vhost:
port => '80',
docroot => "/var/www/${vhost}",
}
}


# mysql profile
class profile::db::mysql (
String $username = '/var/www',
String $password,
) {


include mysql::server
mysql::db{ 'mysqldb':
user => $username,
password => $password,
grant => 'ALL',
}
}


# php profile
class profile::programming::php
{
class { '::php':
ensure => latest,
manage_repos => true,
fpm => true,
dev => true,
composer => true,
pear => true,
phpunit => false,
settings => {
'PHP/max_execution_time' => '90',
'PHP/max_input_time' => '300',
'PHP/memory_limit' => '64M',
'PHP/post_max_size' => '32M',
'PHP/upload_max_filesize' => '32M',
'Date/date.timezone' => 'Europe/Berlin',
},
}
}

As you can see, in these classes, we are producing an abstraction for the remaining, AMP section of the LAMP stack and encapsulating the functionality of the underlying component modules. Linux is already installed, of course!

主站蜘蛛池模板: 靖边县| 乃东县| 铜川市| 黄龙县| 钦州市| 娄烦县| 江口县| 扎兰屯市| 内江市| 勃利县| 梧州市| 万州区| 苍山县| 瑞安市| 红河县| 嘉善县| 自治县| 固安县| 芦溪县| 鲁甸县| 禄丰县| 家居| 湘西| 山东| 子洲县| 贡嘎县| 梓潼县| 江川县| 卓资县| 汝州市| 黎平县| 祁连县| 合江县| 普格县| 定陶县| 法库县| 西盟| 连山| 三穗县| 平度市| 汪清县|