Skip to content

Instantly share code, notes, and snippets.

@goreilly
Created September 14, 2016 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goreilly/9aab2611d07a58f88f787f2984cd594d to your computer and use it in GitHub Desktop.
Save goreilly/9aab2611d07a58f88f787f2984cd594d to your computer and use it in GitHub Desktop.
---
##
# Invoke any type of script to modify files. Dry-run friendly usually.
# remote_path: Path to file on server.
# script: Commands that returns altered content on stdout
##
- name: get current content
always_run: yes
register: remote
slurp: src={{ remote_path }}
- name: modify contents
register: modified
delegate_to: localhost
become: no
always_run: yes
changed_when: no
shell: echo {{ remote.content }} | base64 -D | {{ script }}
- name: replace contents
copy:
content: '{{ modified.stdout }}'
dest: '{{ remote_path }}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment