Search code examples
deploymentsftpansibleserver-configuration

Ansible playbook: pipeline local cmd output (e,g. git archive) to server?


So my project has a special infrastructure, the server has only SSH connection, I have to upload my project code to server using SSH/SFTP everytime, manually. The server can not fetch.

Basically I need something like git archive master | ssh user@host 'tar -zxvf -' automatically done using playbook.

I looked at docs, local_action seems to work but it requires a local ssh setup. Are there other ways around?


Solution

  • How about something like this. You may have to tweak to suit your needs.

     tasks:
        - shell: git archive master /tmp/master.tar.gz
        - unarchive: src=/tmp/master.tar.gz dest={{dir_to_untar}}
    

    I still do not understand it requires a local ssh setup in your question.