2016-07-13 5 views
0

私はサービスを開始した場所でntpモジュールを作成しました。私はコード全体を単一のntp.ppファイルに書きました。コードを1つのファイルに書き込んでこの問題が発生しましたか?人形で既にサービスが宣言されています

私のコードは次のとおりです。

package { 'ntp': ensure => installed } 

service { 'ntp-run': 
    name => 'ntpd', 
    ensure => running, 
    require => Package['ntp'], 
} 

file { '/tmp/classtest': ensure => file } 

file { '/tmp/ntplink': 
    ensure => link, 
    target => '/tmp/classtest', 
    require => File['/tmp/classtest'], 
} 

file { '/tmp/classdir': ensure => directory } 

exec { '/tmp/classtest': 
    command => "mv /tmp/classtest /tmp/classdir", 
    path => '/bin/mv', 
    require => File['/tmp/classtest'], 
} 

service { 'ntp-stop': 
    ensure => stopped, 
    require => Service['ntp-run'], 
} 

package { 'ntp': ensure => absent } 

file { '/tmp/classtest': 
    ensure => absent, 
    require => Exec['/tmp/classtest'], 
} 

が、私はこのエラーを取得しています:

Error: Duplicate declaration: Package[ntp] is already declared in file /etc/puppet/ntp.pp:3; cannot redeclare at /etc/puppet/ntp.pp:34 on node ip-172-31-41-100.us-west-2.compute.internal 
Error: Duplicate declaration: Package[ntp] is already declared in file /etc/puppet/ntp.pp:3; cannot redeclare at /etc/puppet/ntp.pp:34 on node ip-172-31-41-100.us-west-2.compute.internal 

答えて

1

あなたがライン34上で管理し、同じパッケージを持っているし、ライン上の1人形ではないので、エラーがありますスクリプト言語ですが、システム構成の終了状態のみをモデル化するための宣言型言語です。あなたがやろうとしていることは、Ansibleのようなものを使ってよりうまく成し遂げることができます。

関連する問題