Skip to content

Instantly share code, notes, and snippets.

@baldwinsung
Created March 31, 2017 04:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baldwinsung/f6c78ff0196b180df3cfd1e700f483fe to your computer and use it in GitHub Desktop.
Save baldwinsung/f6c78ff0196b180df3cfd1e700f483fe to your computer and use it in GitHub Desktop.
Simple Installation & Configuration of Puppet
ansible digitalocean-all -m yum -a “name=https://yum.puppetlabs.com/puppetlabs-release-pc1-el-6.noarch.rpm state=present”
ansible droplet1-west -m yum -a "name=puppetserver state=latest"
ansible digitalocean-all -m yum -a "name=puppet state=latest"
ansible droplet1-west -m service -a "name=puppetserver enabled=yes state=restarted"
ansible digitalocean-all -m yum -a "name=puppet state=latest"
ansible digitalocean-all -m service -a "name=puppet enabled=yes state=restarted"
ansible droplet1-west -m shell -a "/opt/puppetlabs/bin/puppet cert list --all"
ansible droplet1-west -m shell -a "/opt/puppetlabs/bin/puppet cert sign --all"
Create files on Puppet Master:
# production main mainifest file
touch /etc/puppetlabs/code/environments/production/manifests/site.pp
cat >> /etc/puppetlabs/code/environments/production/manifests/site.pp << EOF_SITE
file {'/tmp/example-ip': # resource type file and filename
ensure => present, # make sure it exists
mode => '0644', # file permissions
content => "Here is my Public IP Address: ${ipaddress_eth0}.\n", # note the ipaddress_eth0 fact
file {'/etc/motd':
ensure => present,
mode => '0644',
content => "\nUptime: ${uptime} || OS: ${operatingsystem} ${operatingsystemrelease} || CPUs: ${physicalprocessorcount} || Memory: ${memoryfree} / ${memorysize}\n",
}
file {'/etc/resolv.conf':
ensure => present,
mode => '0644',
content => "#Managed by Puppet\nnameserver 8.8.4.4\nnameserver 8.8.8.8\nnameserver 209.244.0.3\n",
}
### node specific
node 'droplet1-asia', 'droplet1-east' { # applies to ns1 and ns2 nodes
file {'/tmp/dns': # resource type file and filename
ensure => present, # make sure it exists
mode => '0644',
content => "Only DNS servers get this file.\n",
}
}
### last line
node default {} # applies to nodes that aren't explicitly defined}
EOF_SITE
Execute Puppet Agents:
ansible digitalocean-all -m shell -a "ls -ltrah /tmp/example-ip; ls -ltrah /tmp/dns"
ansible digitalocean-all -m shell -a "puppet agent --configprint runinterval"
ansible digitalocean-all -m shell -a "puppet agent --test"
ansible digitalocean-all -m shell -a "ls -ltrah /tmp/example-ip; ls -ltrah /tmp/dns"
Deploy Puppet Module:
ansible droplet1-west -m shell -a "/opt/puppetlabs/bin/puppet module install puppetlabs-apache"
##### add to node specific section...
node 'droplet1-eu' {
class { 'apache': } # use apache module
apache::vhost { 'example.com': # define vhost resource
port => '80',
docroot => '/var/www/html'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment