Ansible bitbucket clone provisioning ssh error

懵懂的女人 提交于 2019-12-08 14:29:43

Since you run the whole playbook with become: true, SSH key-forwarding (as well as troubleshooting) becomes irrelevant, because the user connecting to BitBucket from your play is root.

Run the task connecting to BitBucket as ubuntu user:

  • either specifying become: false in the Clone bitbucket repo task),

  • or removing become: true From the play and adding it only to tasks that require elevated permissions.

This answer comes direct from techraf's helpful comments.

  • I changed the owner of the /var/www directory from 'www-data' to 'ubuntu' (the username I use to login via ssh).
  • I also added "become: false" above the git task.

NOTE: I have since been dealing with the following issue so this answer does not fully resolve my problems: Ansible bitbucket clone repo provisioning ssh error

Updated working playbook.yml file:

---

- hosts: all
  become: true

  tasks:
    - name: create /var/www/ directory
      file: dest=/var/www/ state=directory owner=ubuntu group=www-data mode=0755

    - name: Add the user 'ubuntu' to group 'www-data'
      user:
        name: ubuntu
        shell: /bin/bash
        groups: www-data
        append: yes

    - name: Clone bitbucket repo
      become: false
      git:
        repo: git@bitbucket.org:[username]/example.com.git
        dest: /var/www/poo
        version: master
        accept_hostkey: yes
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!