Created
July 22, 2016 20:01
-
-
Save keyboardscience/4324c6116cd27e8660b5842694a1afc7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| - name: Working with constrained remote host | |
| hosts: remotes_without_python27 | |
| gather_facts: yes # this may fail | |
| tasks: | |
| - name: Render template locally | |
| delegate_to: localhost | |
| template: | |
| src: templates/file_template.j2 | |
| dest: rendered_templates/file.extension | |
| # Ensure there are not issues with variable context | |
| - name: Save rendered template to fact | |
| set_fact: | |
| file_content: "{{ lookup('file', 'rendered_templates/file.extension') }}" | |
| - name: Write the content into a file on remote | |
| raw: "echo -e '{{ file_content }}' | sudo tee /path/to/destination.extension" | |
| - name: Fix permissions on file | |
| raw: "chmod {{ octal_permissions | default('700') }} /path/to/destination.extension && chown {{ owner | default('root') }}:{{ group | default('root') }} /path/to/destination.extension" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment