Passing values in a file

57 views
Skip to first unread message

Rakshatha shetty

unread,
Jul 1, 2016, 9:44:22 AM7/1/16
to Ansible Project
Hi,

I'm using Ansible 2.0.0.2 to create multiple directories by passing path to directories in a file and reading the values from file. How can multiple values be passed in a single file? Please revert with the format in which values (i.e. path to directories) should be passed in the file. 

Thanks & Regards,
Rakshatha

jta...@ansible.com

unread,
Jul 1, 2016, 12:43:02 PM7/1/16
to Ansible Project
Can you show an example of what you are trying to accomplish?

Rakshatha shetty

unread,
Jul 4, 2016, 1:33:15 AM7/4/16
to Ansible Project
- name: Create directory structure
  hosts: newserver
  tasks:
    - name: Directory structure
      win_file: path="{{ item }}" state=directory

      with_file:
        - first_example_file

Above is the ansible script I'm using to create directory, path to the new directory is given in the file 'first_example_file'. How should we pass multiple values in the file (i.e. when we have to create multiple directories, what is the format of tje file?)

Sam Darwin

unread,
Jul 4, 2016, 10:14:24 AM7/4/16
to Ansible Project

This stackoverflow article explains how to iterate over multiple lines in a file with ansible: http://stackoverflow.com/questions/33541870/how-do-i-loop-over-each-line-inside-a-file-with-ansible

Rakshatha shetty

unread,
Jul 5, 2016, 9:49:49 AM7/5/16
to Ansible Project
Thank you, with_lines module was very much helpful

Rakshatha shetty

unread,
Jul 7, 2016, 2:22:49 AM7/7/16
to Ansible Project
With_lines module is working fine when I pass values for single parameter. How to pass values for multiple parameters in a single file?

For example:  win_file: path="{{ item }}" state="{{ item }}"
 
In the above example values for path and state should be passed. Is it possible to accomplish this using with_lines? Please help...
Reply all
Reply to author
Forward
0 new messages