Update Servers & Workflows/Linux/Automation/Puppet/Puppet Deployment.md
This commit is contained in:
@ -163,5 +163,55 @@ chmod 600 /root/.git-credentials
|
|||||||
|
|
||||||
# Cleanup After Ourselves
|
# Cleanup After Ourselves
|
||||||
rm -rf /tmp/PuppetTest
|
rm -rf /tmp/PuppetTest
|
||||||
|
```
|
||||||
|
|
||||||
|
Finally we validate that everything is working by pulling down the Puppet environments using r10k on the Puppet Server:
|
||||||
|
``` sh
|
||||||
|
sudo /usr/local/bin/r10k deploy environment -p
|
||||||
|
```
|
||||||
|
|
||||||
|
!!! success "Successful Puppet Environment Deployment
|
||||||
|
If you got no errors about Puppetfile formatting or Gitea permissions errors, then you are good to move onto the next step.
|
||||||
|
|
||||||
|
## External Node Classifier (ENC)
|
||||||
|
An ENC allows you to define node-specific data, including the environment, on the Puppet Server. The agent requests its configuration, and the Puppet Server provides the environment and classes to apply.
|
||||||
|
|
||||||
|
**Advantages**:
|
||||||
|
|
||||||
|
- **Centralized Control**: Environments and classifications are managed from the server.
|
||||||
|
- **Security**: Agents cannot override their assigned environment.
|
||||||
|
- **Scalability**: Suitable for managing environments for hundreds or thousands of nodes.
|
||||||
|
|
||||||
|
### Create an ENC Script
|
||||||
|
```ruby title="/opt/puppetlabs/server/data/puppetserver/scripts/enc.rb"
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
# enc.rb
|
||||||
|
|
||||||
|
require 'yaml'
|
||||||
|
|
||||||
|
node_name = ARGV[0]
|
||||||
|
|
||||||
|
# Define environment assignments
|
||||||
|
node_environments = {
|
||||||
|
'fedora.bunny-lab.io' => 'development',
|
||||||
|
# Add more nodes and their environments as needed
|
||||||
|
}
|
||||||
|
|
||||||
|
environment = node_environments[node_name] || 'production'
|
||||||
|
|
||||||
|
# Define classes to include per node (optional)
|
||||||
|
node_classes = {
|
||||||
|
'fedora.bunny-lab.io' => ['neofetch'],
|
||||||
|
# Add more nodes and their classes as needed
|
||||||
|
}
|
||||||
|
|
||||||
|
classes = node_classes[node_name] || []
|
||||||
|
|
||||||
|
# Output the YAML document
|
||||||
|
output = {
|
||||||
|
'environment' => environment,
|
||||||
|
'classes' => classes
|
||||||
|
}
|
||||||
|
|
||||||
|
puts output.to_yaml
|
||||||
|
```
|
Reference in New Issue
Block a user