2016-04-19 7 views
0

ディレクトリ全体を1レベル下に移動するcfengine3約束を書こうとしています。CFE構文エラー

私は約束を配布するために、私のポリシーのハブを使用しましたが、私はまだ私のアクティブpromise.cf

にそれを折り畳まれていませんでしたここで約束です:私が使用した

body common control 

{ 

     bundlesequence => { dirstructure }; 
} 


#Find out by existance of directories if filesystem is old structure or new 
#Set classes for each instance. If old, copy down one level. 
#If new file system already, pat yourself on the back 

bundle agent dirstructure 
{  
classes: 

    "oldFILEstructure"expression => isdir("/old/dir/structure/"); 
    "newFILEstructure" expression => isdir("/new/dir/structure/"); 


reports: 

    oldFILEstructure:: 
     "system has old file structure.."; 
    newFILEstructure:: 
     "system has new file structure.."; 

methods: 
    oldFILEstructure:: 
     "migratedirectories" usebundle => movedirectories 
} 

bundle agent movedirectories 

{ 
files: 
     "/new/dir/" 

     copy_from => local_cp ("/old/dir/structure/."); 
     depth_search => recurse ("inf"); 
} 

this "isdir"ソースは(local_cp)です。どちらもCFEから約束を守っています。 呼び出されると、次のエラー出力が表示され、その理由を把握しようとしています。

:/var/cfengine/inputs/standalone# cf-agent --no-lock --inform --file ./file_structure.cf 
./file_structure.cf:41:12: error: syntax error 
depth_search => recurse ("inf"); 
     ^
./file_structure.cf:41:12: error: Expected promiser string, got 'depth_search' 
depth_search => recurse ("inf"); 
     ^
./file_structure.cf:41:15: error: Expected ';', got '=>' 
depth_search => recurse ("inf"); 
      ^
./file_structure.cf:41:23: error: Expected promiser string, got 'recurse' 
depth_search => recurse ("inf"); 
        ^
./file_structure.cf:41:25: error: Expected ';', got '(' 
depth_search => recurse ("inf"); 
         ^
./file_structure.cf:41:31: error: Expected ';', got ')' 
depth_search => recurse ("inf"); 
          ^
./file_structure.cf:41:32: error: Expected promiser string, got ';' 
depth_search => recurse ("inf"); 
          ^
./file_structure.cf:42:1: error: Expected ';', got '}' 
} 

答えて

2
files: 
     "/new/dir/" 

     copy_from => local_cp ("/old/dir/structure/."); 
     depth_search => recurse ("inf"); 
} 

あなたはcopy_fromラインの末尾に余分なセミコロンを持っています。

セミコロン;は、約束の終わりを示します。 copy_from行の最後にあるセミコロンをカンマ,に切り替えてみてください。

files: 
     "/new/dir/" 

     copy_from => local_cp ("/old/dir/structure/."), 
     depth_search => recurse ("inf"); 
} 

また、transformer属性をチェックアウトすることもできます。 あなたのケースには適しているかもしれません。\

bundle agent example 
{ 
    files: 
     "/old/dir/structure" -> { "jira:EXAMPLE-1234" } 
     transformer => "/bin/mv /old/dir/structure /new/dir/structure", 
     comment => "The standard is to use the new location because x, y, z. Bad thing Q or U might happen if this is not managed properly."; 
}