Environments usage in puppet

[root@server ~]# puppet module list
/etc/puppetlabs/code/environments/production/modules
├── bashtoni-timezone (v1.0.0)
├── fschaer-omd (v1.0.3)
├── puppetlabs-apache (v1.8.1)
├── puppetlabs-apt (v2.4.0)
├── puppetlabs-concat (v2.2.1)
├── puppetlabs-firewall (v1.9.0)
├── puppetlabs-inifile (v1.6.0)
├── puppetlabs-ntp (v6.2.0)
├── puppetlabs-postgresql (v4.9.0)
├── puppetlabs-puppetdb (v5.1.2)
├── puppetlabs-stdlib (v4.17.1)
├── puppetlabs-xinetd (v2.0.0)
├── saz-ssh (v3.0.1)
├── saz-sudo (v4.2.0)
└── users (???)
/etc/puppetlabs/code/modules (no modules installed)
/opt/puppetlabs/puppet/modules (no modules installed)

[root@server ~]# mkdir /etc/puppetlabs/code/environments/testing/

[root@server ~]# puppet module install stahnma-epel –version 1.2.2 –environment testing
Notice: Preparing to install into /etc/puppetlabs/code/environments/testing/modules …
Notice: Created target directory /etc/puppetlabs/code/environments/testing/modules
Notice: Downloading from https://forgeapi.puppet.com
Notice: Installing — do not interrupt …
/etc/puppetlabs/code/environments/testing/modules
└─┬ stahnma-epel (v1.2.2)
└── puppetlabs-stdlib (v4.18.0)

[root@server ~]# puppet module list –environment testing
/etc/puppetlabs/code/environments/testing/modules
├── puppetlabs-stdlib (v4.18.0)
└── stahnma-epel (v1.2.2)
/etc/puppetlabs/code/modules (no modules installed)
/opt/puppetlabs/puppet/modules (no modules installed)

[root@server ~]# puppet module uninstall stahnma-epel –environment testing
Notice: Preparing to uninstall ‘stahnma-epel’ …
Removed ‘stahnma-epel’ (v1.2.2) from /etc/puppetlabs/code/environments/testing/modules

[root@server ~]# puppet module install puppetlabs-apache –version 1.6.0 –environment testing
Notice: Preparing to install into /etc/puppetlabs/code/environments/testing/modules …
Notice: Downloading from https://forgeapi.puppet.com
Notice: Installing — do not interrupt …
/etc/puppetlabs/code/environments/testing/modules
└─┬ puppetlabs-apache (v1.6.0)
├── puppetlabs-concat (v1.2.5)
└── puppetlabs-stdlib (v4.18.0)

[root@server ~]# mkdir /etc/puppetlabs/code/environments/testing/manifests
[root@server ~]# touch /etc/puppetlabs/code/environments/testing/manifests/site.pp

puppet agent –environment=test

[root@server ~]# puppet module install puppetlabs-firewall –version 1.9.0 –environment testing

[root@server ~]# mkdir -p /etc/puppetlabs/code/environments/testing/hieradata/roles

[root@server ~]# touch /etc/puppetlabs/code/environments/testing/hieradata/common.yaml

[root@server ~]# mkdir -p /etc/puppetlabs/code/environments/testing/modules/{role,profile,my_fw,users}/manifests

[root@server ~]# touch /etc/puppetlabs/code/environments/testing/modules/{role,profile}/manifests/init.pp

[root@server ~]# touch /etc/puppetlabs/code/environments/testing/modules/my_fw/manifests/{pre,post,init,http}.pp

[root@server ~]# echo “alias prod=’cd /etc/puppetlabs/code/environments/production'” >> ~/.bashrc

[root@server ~]# echo “alias test=’cd /etc/puppetlabs/code/environments/testing'” >> ~/.bashrc

[root@server ~]# test
[root@server testing]# prod
[root@server production]#

[root@server ~]# puppet module list –environment testing
/etc/puppetlabs/code/environments/testing/modules
├── my_fw (???)
├── profile (???)
├── puppetlabs-apache (v1.6.0)
├── puppetlabs-concat (v1.2.5)
├── puppetlabs-firewall (v1.9.0)
├── puppetlabs-stdlib (v4.18.0)
├── role (???)
└── users (???)

[root@server ~]# test
[root@server testing]# vim manifests/site.pp
node default {
package{‘nmap’:
ensure => present
}
}

 

agent side

vim /etc/puppetlabs/puppet/puppet.conf

server = server.example.com
environment = testing

[root@spire ~]# puppet agent -t
Info: Using configured environment ‘testing
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for spire.example.com
Info: Applying configuration version ‘1503010899’
Notice: /Stage[main]/Main/Node[default]/Package[nmap]/ensure: created
Notice: Applied catalog in 2.70 seconds

 

 

Leave a comment