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

  • Mastering Puppet 5
  • Ryan Russell Yates Jason Southgate
  • 307字
  • 2021-07-16 17:46:11

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!

主站蜘蛛池模板: 苗栗市| 开原市| 潞西市| 彭阳县| 桃江县| 临西县| 安化县| 海阳市| 广汉市| 彭水| 永城市| 施甸县| 新和县| 夏河县| 岳普湖县| 页游| 昌黎县| 武安市| 托里县| 旬邑县| 五家渠市| 温宿县| 惠安县| 新巴尔虎左旗| 灵台县| 独山县| 许昌县| 远安县| 凤台县| 涞源县| 龙山县| 文成县| 财经| 绥棱县| 金沙县| 长乐市| 稻城县| 泸定县| 交城县| 潮安县| 康保县|