2016-04-30 41 views
1

在一些ansible劇本我歌廳一個ansible識別SSH用戶ansible瓦爾

rsync: mkdir "/var/www/xxx" failed: Permission denied 

我需要檢查什麼是我ansible在目標虛擬機使用的用戶。

如何使用debug:行打印用戶?

我尋找類似於$ id unix命令來調試權限Pb。

回答

1

Ansible將始終默認爲當前用戶(在shell中),並且如果要使用其他用戶連接到遠程計算機,則可以在您的劇本中使用remote_user

參見:http://docs.ansible.com/ansible/intro_configuration.html#remote-user瞭解更多詳情。

如果你想運行shell命令並捕獲輸出:

- 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}}"