version: '2.0'

st2ci.teardown_st2:
    description: Teardown a running instance of StackStorm.
    type: direct
    input:
        - host
        - repo

    tasks:
        stop_service:
            action: core.remote
            input:
                hosts: <% $.host %>
                cmd: <% $.repo %>/tools/launchdev.sh stop
            on-complete:
                - teardown_db

        teardown_db:
            action: core.remote
            input:
                hosts: <% $.host %>
                cmd: mongo st2 --eval "db.dropDatabase();"
            on-success:
                - remove_packs

        remove_packs:
            action: core.remote
            input:
                hosts: <% $.host %>
                cmd: rm -rf /opt/stackstorm/packs
            on-success:
                - remove_repo

        remove_repo:
            action: st2cd.git_clean
            input:
                hosts: <% $.host %>
                repo: <% $.repo %>

version: '2.0'

st2ci.teardown_st2:
    description: Teardown a running instance of StackStorm.
    type: direct
    input:
        - host
        - repo

    tasks:
        stop_service:
            action: core.remote
            input:
                hosts: <% $.host %>
                cmd: <% $.repo %>/tools/launchdev.sh stop
            on-complete:
                - teardown_db

        teardown_db:
            action: core.remote
            input:
                hosts: <% $.host %>
                cmd: mongo st2 --eval "db.dropDatabase();"
            on-success:
                - remove_packs

        remove_packs:
            action: core.remote_sudo
            input:
                hosts: <% $.host %>
                cmd: rm -rf /opt/stackstorm/packs
            on-success:
                - remove_repo

        remove_repo:
            action: st2cd.git_clean
            input:
                hosts: <% $.host %>
                repo: <% $.repo %>

Add sudo to pack removal step in st2ci.mistral
Add sudo to pack removal step in st2ci.mistral
