Reputation: 305
For example i have variable A and I want to write a file B with these value from variable A. The value from var A will be vary from the survey input.
- hosts: myhost
vars:
A: "{{ input }}"
The content of the file B that I needed: A="{{ input }}"
I need to replace the input for the file from the input value in the variable. The input can be anything inserted in the ansible survey.
Is there a way to write the input values from var A to the file B?
Upvotes: 0
Views: 302
Reputation: 12009
Since your question and description are very vague
Is there a way to write the input values from var A to the file B?
the answer might not fit fully to your use case.
You may use the template
_module.
First create a file
variable.file.j2
A={{ A }}
and than write it to the destination.
- name: Template a file to /tmp/B
ansible.builtin.template:
src: variable.file.j2
dest: /tmp/B
Thanks to
Upvotes: 1
Reputation: 5720
Templating would indeed be better. The quick 'n dirty method would be:
---
- hosts: my_hosts
vars:
A: my_value
tasks:
- shell: "echo {{ A }} > /tmp/B"
register: the_echo
This way you'll see what's happening
Upvotes: 0