Synchronize not working with Gitlab-ci

I have the following Gitlab-ci.yml config that calls an Ansible provisioning script:

image: ubuntu
deploy to dev:
stage: deploy
- develop
name: dev
url: http://URL HERE/
# Install required packages
- apt-get update && apt-get install -y software-properties-common
- apt-add-repository ppa:ansible/ansible
- apt-get update && apt-get install -y ansible openssh-client rsync

# Set up our SSH key
- eval $(ssh-agent -s)
- ssh-add <(echo "$MY_SSH_KEY")
- mkdir -p ~/.ssh; chmod 700 ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'

# Deploy via ansible
- ansible-galaxy install -r ansible/requirements.yml --roles-path=ansible/roles
- ansible-playbook -i ansible/dev ansible/deploy.yml

This will execute the ansible-playbook and runs the deploy.yml

However; when pipeline is executed the code push fails with the following error:
TASK [Upload the project code] *************************************************
fatal: [URL HERE]: FAILED! => {“msg”: “failed to transfer file to ~ubuntu/.ansible/tmp/ansible-tmp-1526928263.0-14912160974412/ [Errno 2] No such file or directory: ‘~ubuntu/.ansible/tmp/ansible-tmp-1526928263.0-14912160974412/’”}


  • hosts: all


    • vars.yml


    • name: Ensure project directory exists and is writeable
      path: “{{ project_dir }}”
      state: directory
      owner: “{{ project_user }}”
      group: www-data
      mode: 0755
      become: yes

    • name: Upload the project code
      src: “…/…/”
      dest: “{{ project_dir }}”
      recursive: yes
      become: yes #tried this with and without

    • name: Install composer dependencies
      composer: command=install working_dir={{ project_dir }}

    • name: Migrate the database
      command: php artisan migrate chdir={{ project_dir }}

However; this runs successfully when pulled down and ran manually, additionally, this code executes within the pipeline if Ansible Copy command is used instead of Synchronize, but the Copy command takes 20min to complete. Any ideas / work arounds? I’ve tried setting remote / local paths in my ansible configs and giving different paths for tmp dir but nothing seems to work

Hello, I have the same issue exactly after ansible upgrade.
Fixed it by downgrading ansible from 2.5.3 to 2.4.0
Now it works, at least now