I'm working on a playbook to deploy an internal application to internal hosts. This application is delivered by development to QA in a *.tar.gz file. The file is staged and deployed to QA (by me) in that *.tar.gz file. What I would like/am thinking of is something like:
$ ansible-playbook remote-group -k -e '{"qahost":"qaserver","version":2.75.26.1","path":"/home/app/app_2.75.26.1.tar.gz"}'
and the playbook would be something like:
---
- hosts: v2app
gather_facts: yes
vars:
qahost: "{{ qahost }}"
version: "{{ version }}"
remotepath: "{{ path }}"
localpath: "/tmp/{{version}}.tar.gz"
tasks:
- name: bring file locally
command: scp "{{qahost}}":"{{remotepath}}" "{{localpath}}"
local: true
# localpath referes to /tmp, so using it twice means once on the local server and once on the remote app server
- name: copy the deployment file from QA locally
copy:src={{localpath}} dest={{localpath}}
- name: extract the deployment file on the app server
command: tar -xzf {{localpath}}
# still testing, so using /tmp for all updates
- name: make a copy of the application
shell: rm -rf /tmp/app ; cp -r -p /opt/app /tmp
- name: sync the new files to the application
shell: cd /tmp/app; rsync -a {{localpath}} .
- name: clean up
command: rm -f {{localpath}}
(I'm just typing from memory and haven't syntax checked the above.)
How can I execute a single task of a playbook on the local server and the rest of the tasks on the remote servers? (Is this even possible?)
TIA
Mike