Not possible to source .bashrc with Ansible

后端 未结 10 1592
耶瑟儿~
耶瑟儿~ 2020-12-02 08:19

I can ssh to the remote host and do a source /home/username/.bashrc - everything works fine. However if I do:

- name: source bashrc
  sudo: no
          


        
10条回答
  •  既然无缘
    2020-12-02 08:45

    I found become as best solution:

    - name: Source .bashrc
      shell: . .bashrc
      become: true
    

    You can change the user by adding (default: root):

    - name: Source .bashrc
      shell: . .bashrc
      become: true
      become-user: {your_remote_user}
    

    More info here: Ansible become

提交回复
热议问题