2016-04-30 12 views
1

をvarsの。ansible ansibleでのsshユーザーを識別するには、私は私のansibleがターゲットVMで使用しているユーザであるかどうか確認する必要があり</p> <pre><code>rsync: mkdir "/var/www/xxx" failed: Permission denied </code></pre> <p>をgetingてるいくつかのansibleスクリプトで

debug:行のユーザーを印刷するにはどうすればよいですか?

私は$ id unixコマンドのようなものを探して権限Pbをデバッグします。

答えて

1

アシスタントは常に(シェル内の)現在のユーザにデフォルト設定されています。別のユーザを使用してリモートマシンに接続する場合は、remote_userを使用できます。

詳細はhttp://docs.ansible.com/ansible/intro_configuration.html#remote-userを参照してください。

あなたはシェルコマンドを実行し、出力をキャプチャしたい場合:

- name: "Run a shell command" 
    shell: /usr/bin/id 
    register: result 

    - name: Print the value of result 
    debug: var=result 

または

- name: Print the user id using the ansible_user_id fact 
    debug: msg="{{ansible_user_id}}" 
関連する問題

 関連する問題