2016-08-28 5 views
1

Ansibleの脚本で定義されていないようだ:Wordpressのを設定するための可変Laravelアプリケーション用のサーバを設定するため、次のAnsibleの脚本が正常に動作します

--- 
- name: Set up a standard Laravel install 
    hosts: localhost 
    vars_prompt: 
    - name: "domain" 
     prompt: "Domain name" 
     private: no 
    - name: "dbname" 
     prompt: "Database name" 
     private: no 
    - name: "dbuser" 
     prompt: "Database username" 
     private: no 
    - name: "dbpassword" 
     prompt: "Database password" 
     private: yes 
    roles: 
    - create_droplet 
    - create_domain 
- name: Install dependencies 
    hosts: launched 
    roles: 
    - upgrade 
    - utilities 
    - users 
    - nginx-php 
    - composer 
    - nginx_firewall 
    - redis 
    - postgres 
    - git 

以下同様のものではないインストールします。

​​

どちらのプレイブックはcreate_dropletcreate_domain役割を使用してデジタルオーシャンに新しい液滴を設定し、launchedグループに追加します。二脚本でこのエラーメッセージのように、定義されて表示されていないためしかし、変数が促さ:デバッグ文の

TASK [wordpress : Add user "wordpress", belonging to group "wordpress" and having a home dir of /var/www] *** 
fatal: [<IP_ADDRESS_REDACTED>]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'pass' is undefined\n\nThe error appears to have been in '/home/matthew/Projects/ansible-setup/playbooks/roles/wordpress/tasks/main.yml': line 28, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Add user \"wordpress\", belonging to group \"wordpress\" and having a home dir of /var/www\n^here\nWe could be wrong, but this one looks like it might be an issue with\nunbalanced quotes. If starting a value with a quote, make sure the\nline ends with the same set of quotes. For instance this arbitrary\nexample:\n\n foo: \"bad\" \"wolf\"\n\nCould be written as:\n\n foo: '\"bad\" \"wolf\"'\n"} 

使用したロールのいずれにおいても、第二脚本に呼び出されることを確認していませんdomain変数が定義されたように見えます。私はそれがなぜであるかわからない。しかし、液滴を作る部分を取り除いて、既存の液滴と比較すると、うまくいくと思われます。

これはなぜ未定義として表示されますか?これらの変数の範囲とは関係がありますか?

答えて

4

これらの変数の範囲とは関係がありますか?

はい、変数は再生バインドされているため、最初の再生(プロンプトが表示された場合)および2番目の再生では使用できません。

再生の間に生き残るために変数が必要な場合は、それをホストファクトに変換する必要があります。例えば
は、あなたの最初のプレイにpost_tasksを追加します。

post_tasks: 
    - set_fact: 
     domain: '{{ domain }}' 
    delegate_to: '{{ item }}' 
    delegate_facts: true 
    with_inventory_hostnames: launched 

これはlaunchedグループ内のすべてのホストにdomain事実を追加します。

関連する問題