Skip to content

Instantly share code, notes, and snippets.

@covelus
Created March 29, 2020 10:27
Show Gist options
  • Select an option

  • Save covelus/67f92facc528e27002e8391ef2b449a2 to your computer and use it in GitHub Desktop.

Select an option

Save covelus/67f92facc528e27002e8391ef2b449a2 to your computer and use it in GitHub Desktop.
Puppet Intro Summary
https://www.digitalocean.com/community/tutorials/getting-started-with-puppet-code-manifests-and-modules
+ Resources
resource_type { 'resource_name'
attribute => value
...
}
user { 'mitchell':
ensure => present,
uid => '1000',
gid => '1000',
shell => '/bin/bash',
home => '/home/mitchell'
}
+ Manifests
programas
/etc/puppet/manifests/site.pp
+ Classes
class example_class {
...
code
...
}
+ Class Declaration
include example_class
node 'host2' {
class { 'apache': } # use apache module
apache::vhost { 'example.com': # define vhost resource
port => '80',
docroot => '/var/www/html'
}
}
+ Modules
Colección manifests e datos
sudo vi /etc/puppet/manifests/lamp.pp
# execute 'apt-get update'
exec { 'apt-update': # exec resource named 'apt-update'
command => '/usr/bin/apt-get update' # command this resource will run
}
# install apache2 package
package { 'apache2':
require => Exec['apt-update'], # require 'apt-update' before installing
ensure => installed,
}
# ensure apache2 service is running
service { 'apache2':
ensure => running,
}
# install mysql-server package
package { 'mysql-server':
require => Exec['apt-update'], # require 'apt-update' before installing
ensure => installed,
}
# ensure mysql service is running
service { 'mysql':
ensure => running,
}
# install php5 package
package { 'php5':
require => Exec['apt-update'], # require 'apt-update' before installing
ensure => installed,
}
# ensure info.php file exists
file { '/var/www/html/info.php':
ensure => file,
content => '<?php phpinfo(); ?>', # phpinfo code
require => Package['apache2'], # require 'apache2' package before creating
}
+ Apply Manifest
sudo puppet apply --test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment