First, let's recall that roles contain class {'configuration':} declaration. This tiny module allows us to keep a current copy of the apps configuration on the target nodes.
Module's file tree looks as follow:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
. | |
├── files | |
│ ├── ci | |
│ │ ├── enterprise_app_1 | |
│ │ │ ├── dir.1 | |
│ │ │ │ └── file.1 | |
│ │ │ ├── file.1 | |
│ │ │ └── file.2 | |
│ │ └── web_app_1 | |
│ │ ├── dir.1 | |
│ │ │ └── file.1 | |
│ │ ├── file.1 | |
│ │ └── file.2 | |
│ └── qa | |
│ ├── enterprise_app_1 | |
│ │ ├── dir.1 | |
│ │ │ └── file.1 | |
│ │ ├── file.1 | |
│ │ └── file.2 | |
│ └── web_app_1 | |
│ ├── dir.1 | |
│ │ └── file.1 | |
│ ├── file.1 | |
│ └── file.2 | |
└── manifests | |
└── init.pp |
The manifest file itself (init.pp) is as follows:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# file /biz/puppet/modules/configuration/manifests/init.pp | |
class configuration ($application, $env){ | |
# creating directory structure first | |
file { ['/biz', '/biz/configuration']: | |
ensure => directory, | |
mode => 0640, | |
} | |
file { "/biz/configuration/${application}": | |
ensure => directory, # so make this a directory | |
recurse => true, # enable recursive directory management | |
purge => true, # purge all unmanaged junk | |
force => true, # also purge subdirs and links etc. | |
mode => 0640, | |
source => "puppet:///modules/configuration/${env}/${application}", | |
} | |
} |
It can be summarized as procedure that base on ${environment} name and ${application} name copies configuration files from /biz/puppet/hieradata/${environment}/${application} on Puppet Master to /biz/configuration/${application} on Puppet Agent node.
It is important that destination point has no reference of the ${environment}. This later allows Jenkins to perform configuration update in a complete agnostic way - with only ${application} name being required.
Consider the file tree under files folder. It is grouped by environment and application name. Should you like to add a new application, let's say HelloWorld to the CI env, you would have to:
- Make sure that folder /biz/puppet/hieradata/ci exist
- Create new subfolder /biz/puppet/hieradata/ci/HelloWorld
- Place HelloWorld configuration files into /biz/puppet/hieradata/ci/HelloWorld
- Create/update Jenkins script to take the application configuration files from /biz/configuration/${application}
- Create/update a role to reference the HelloWorld:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class role::hello_world_server inherits role { | |
# ... | |
class { 'configuration' : | |
env => "${environment}", | |
application => 'HelloWorld', | |
} | |
} |
The flow can be illustrated as:
![]() |
Fig 1: Deployment process |
Last, but not least - let's describe development process on Puppet+Hiera+Jenkins govern cluster:
![]() |
Fig 2: Development process |
Cheers!
No comments:
Post a Comment