*Resources in Puppet "puppet resource"*
Understanding Resources is fundamental to understanding how Puppet
works. Resources are like building blocks. They can be
combined to model the expected state of the systems you manage.
For more information about the resources in puppet you can fire "puppet resource -h" on CLI.
This command transforms the current system state into puppet code also it has the ability to modify the current state of the system.
Syntax:
resource_type { 'resource_name'
attribute => value
...
}
Below are the few examples:
- To see all the users in the machine.
- [root@puppet ~]# puppet resource user
- To see a particular user in the machine.
- [root@puppet ~]# puppet resource user sunny
user { 'sunny':
ensure => 'present',
comment => 'Sunny_B',
gid => '501',
home => '/home/sunny',
password => '!!',
password_max_age => '99999',
password_min_age => '0',
shell => '/bin/bash',
uid => '501',
}
[root@puppet ~]#
- To see all the host entries in /etc/hosts.
- [root@puppet ~]# puppet resource host
- To see a particular host entry.
- [root@puppet ~]# puppet resource host kubuntu
host { 'kubuntu':
ensure => 'present',
host_aliases => ['kubuntu14.sunny.com'],
ip => '192.168.122.179',
target => '/etc/hosts',
}
[root@puppet ~]#
- To see all the packages installed in the machine.
- [root@puppet ~]# puppet resource package
- To see information about a particular package.
- [root@puppet ~]# puppet resource package httpd
package { 'httpd':
ensure => '2.2.15-15.el6',
}
[root@puppet ~]#
- To see status of all the services in the machine.
- [root@puppet ~]# puppet resource service
- To see status of a particular service in the machine suppose httpd.
- [root@puppet ~]# puppet resource service httpd
service { 'httpd':
ensure => 'running',
enable => 'true',
}
- To see all the mount points.
- [root@puppet ~]# puppet resource mount
- To see a particular mount point suppose / [where / is mounted].
- [root@puppet ~]# puppet resource mount /
mount { '/':
ensure => 'mounted',
device => '/dev/mapper/vg_rhel6-lv_root',
dump => '1',
fstype => 'ext4',
options => 'defaults',
pass => '1',
target => '/etc/fstab',
}
[root@puppet ~]#
To see what all resource types are accepted in puppet you can fire
"puppet resource --types".
Comments
Post a Comment