文件资源类型中的 Puppet 7.10 通知属性无法找到 运行 服务

Puppet 7.10 notify attribute in file resource type unable to find a running service

木偶新手,我对两个问题感到困惑:

(1) 安装包(apache2) 不仅安装包而且启动服务。发生这种情况是否可能是由于 apache2 在安装期间触发的脚本?

(2) puppet resource service apache2表示apache2是运行ning。但是当我尝试 运行 sudo puppet apply apache2-file.pp 时,我得到如下所示的错误:

ubuntu@ubuntu-xenial:~$ puppet resource service apache2
service { 'apache2':
  ensure   => 'running',
  enable   => 'true',
  provider => 'systemd',
}
ubuntu@ubuntu-xenial:~$ cat apache2-file.pp 
file { '/etc/apache2/ports.conf':
    ensure => present,
    replace => true,
    source => '/home/ubuntu/ports.conf',
    notify => Service['apache2']
}
ubuntu@ubuntu-xenial:~$ sudo puppet apply apache2-file.pp 
Error: Could not find resource 'Service[apache2]' in parameter 'notify' (file: /home/ubuntu/apache2-file.pp, line: 5) on node ubuntu-xenial

好的,我明白了,基本上包、文件和服务资源需要成为单个 sudo puppet apply 操作的一部分。我正在安装包作为一个人偶应用的一部分,然后更新文件作为另一个人偶应用的一部分,运行服务作为第三个人偶应用的一部分。