2017-06-05 12 views
2

私は可能な世界に新しいです。 jsonファイルからすべての変数を提供しようとしていますが、受け付けていません。それが表示され、エラー変数未定義jsonファイルから読み込み可能な変数

以下

は私のJSONファイル

以下
{ 
    "Tomcat":{ 
     "SHPN":"8905", 
     "HTPN":"8980", 
     "SSPN":"8943", 
     "AJPN":"8909", 
     "Server":"test.example.com", 
     "JENKINS_HOME":"/apps/tech/jenkins/jenkins-configuration", 
     "PName":"Tomcat-Installation", 
     "IName":"ansible_test", 
     "IUID":"jbosscfg", 
     "IGID":"staff", 
     "IDEPT":"tech", 
     "IRECPT":"[email protected]" 
    } 
} 

はansible脚本を実行しながら、私は以下のよ私の脚本

--- 
- 
    gather_facts: false 
    hosts: "{{Server}}" 
    tasks: 
    - 
     ignore_errors: true 
     name: "find no of Tomcat Instance available on the Server" 
     copy: 
     src: "{{ JENKINS_HOME }}/workspace/{{ PName }}/instance/" 
     dest: /apps/tech/{{IName}} 
     group: "{{IGID}}" 
     owner: "{{IUID}}" 
     mode: 0755 
    - 
     replace: "dest='/apps/tech/{{IName}}/scripts/set_env.sh' regexp='<DEPARTMENT NAME>' replace='{{IDEPT}}'" 
    - 
     replace: "dest='/apps/tech/{{IName}}/scripts/set_env.sh' regexp='<RECIPIENT>' replace='{{IRECPT}}'" 
    - 
     replace: "dest='/apps/tech/{{IName}}/scripts/set_env.sh' regexp='<TOMCAT INSTANCE NAME>' replace='{{IName}}'" 
    - 
     replace: "dest='/apps/tech/{{IName}}/scripts/set_env.sh' regexp='<USER ID>' replace='{{IUID}}'" 
    - 
     name: "Ansible Template Example" 
     template: 
     src: tomcat_server.j2 
     dest: /apps/tech/{{IName}}/conf/server.xml 
     mode: 0777 

です - エラーが変数未定義

test.example.com:~/final:$ ansible-playbook configure-tomcat-instance.yml --extra-vars "@test.json" 
ERROR! the field 'hosts' has an invalid value, which appears to include a variable that is undefined. The error was: 'Server' is undefined 

The error appears to have been in '/home/jbosscfg/final/configure-tomcat-instance.yml': line 3, column 3, but may 
be elsewhere in the file depending on the exact syntax problem. 

The offending line appears to be: 

- 
    gather_facts: false 
^here 
を語ります

答えて

0

変数はトップレベルにあるものとして参照しますが、unde r Tomcatキー。

hosts: "{{Tomcat.Server}}"を使用するか、jsonファイルを再フォーマットしてTomcatレベルを除去してください。

+0

ありがとうございました。その愚かな間違い –

関連する問題