[iyunv@sh-web1 puppet]# puppet agent -t
Notice: Ignoring --listen on onetime run
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for sh-web1.localdomain
Info: Applying configuration version '1505454999'
Error: Execution of '/usr/bin/yum -d 0 -e 0 -y list nginx' returned 1: Error: No matching Packages to list
Error: /Stage[main]/Nginx/Package[nginx]/ensure: change from absent to present failed: Execution of '/usr/bin/yum -d 0 -e 0 -y list nginx' returned 1: Error: No matching Packages to list
Notice: Finished catalog run in 6.93 seconds
原因:没有release源,更新安装eple-release源即可.
1
# yum install epel-release -y
更新安装nginx.
1
2
3
4
5
6
7
8
[iyunv@sh-web1 puppet]# puppet agent -t
Notice: Ignoring --listen on onetime run
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for sh-web1.localdomain
Info: Applying configuration version '1505454999'
Notice: /Stage[main]/Nginx/Package[nginx]/ensure: created
Notice: Finished catalog run in 34.99 seconds
[iyunv@sh-web1 nginx]# puppet agent -t
Notice: Ignoring --listen on onetime run
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for sh-web1.localdomain
Info: Applying configuration version '1505457148'
Notice: /Stage[main]/Nginx::Nginxconf/File[/etc/nginx/nginx.conf]/ensure: defined content as '{md5}142cb8f11006c0d78607c66cb82ae83d'
Notice: /Stage[main]/Nginx/Package[nginx]/ensure: created
Notice: Finished catalog run in 8.69 seconds
cat service.pp
class service {
service {"httpd":
name=> "httpd",
ensure=> running,
enable=> true,
provider => init,
require=> Class["install"],#注意:此处要求启动服务的前提时要完成install类的操作,如果不定义可能会报下面的错.
}
}
报错:
1
2
3
4
5
6
7
8
9
[iyunv@sh-proxy2 puppet]# puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for sh-proxy2.localdomain
Info: Applying configuration version '1505714213'
Error: /Service[httpd]: Could not evaluate: Could not find init script for 'httpd'
Notice: /Stage[main]/Admin/Exec[selinux]/returns: executed successfully
Notice: /Stage[main]/Install/Package[httpd]/ensure: created
Notice: Finished catalog run in 2.75 seconds
添加完require正确的更新:
1
2
3
4
5
6
7
8
9
10
11
12
[iyunv@sh-proxy2 puppet]# puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for sh-proxy2.localdomain
Info: Applying configuration version '1505714421'
Notice: /Stage[main]/Admin/Exec[selinux]/returns: executed successfully
Notice: /Stage[main]/Install/Package[httpd]/ensure: created
Notice: /Stage[main]/Service/Service[httpd]/ensure: ensure changed 'stopped' to 'running'
Info: /Service[httpd]: Unscheduling refresh on Service[httpd]
Notice: Finished catalog run in 3.27 seconds
[iyunv@sh-proxy2 puppet]# /etc/init.d/httpd status
httpd (pid 88530) is running...