how split csvfile for each row for single column

11 views
Skip to first unread message

Atul Sharma

unread,
Aug 3, 2018, 8:48:31 PM8/3/18
to Ansible Project
I dont find way to use row with column , in csvfile module it is splitting only for single row it is not included rest of the lines in csvfile to split 

please share how to can do achieve this?

following playbook i am using 
###################################

---
- hosts: localhost
  connection: local
  gather_facts: yes

  tasks:

  - name: set_fact for produser
    set_fact:
      produser: "{{ lookup('csvfile', 'Production file=gpc.csv col=2 
      delimiter=,')}}"

  - name: checking produser
    debug:
        msg: "{{produser}}"


  - name: set_fact for prodcomm
    set_fact:
          prodcomm: "{{ lookup('csvfile', 'Production file=gpc.csv col=3 
          delimiter=,') }}"

  - name: checking prodcomm
    debug:
         msg: "{{prodcomm}}"

csvfile which am using to split column 3 and 4 for each row
###########################################################
following csvfile contain username (abst_o) at column 3 and column 4 contain command (cp /appl/abst/abst_o1/etc/bst/.passfile /tmp)

Acceptance,Backup .passfile file,5,abst_o,"cp /appl/abst/abst_o1/etc/bst/.passfile /tmp"
Acceptance,Clearing BATCH files from var/log and var/tmp folder,5,abst_b,"rm -rf /appl/abst/abst_o1/var/log/* \/appl/abst/abst_o1/var/tmp/*;\
find /appl/abst/abst_o1/var/log/ -user abst_b1 -type f -exec rm {} \;\
find /appl/abst/abst_o1/var/log/ -user abst_b1 -type l -exec rm {} \;\
find /appl/abst/abst_o1/var/tmp/ -user abst_b1 -type f -exec rm {} \;\
find /appl/abst/abst_o1/var/tmp/ -user abst_b1 -type l -exec rm {} \;\
find /appl/abst/abst_o1/var/log/ ! -name log -user abst_b1 -type d -exec rmdir {} \;\
find /appl/abst/abst_o1/var/tmp/ ! -name tmp -user abst_b1 -type d -exec rmdir {} \;"
Acceptance,Clearing OWNER files from var/log and var/tmp folder,5,abst_o,"find /appl/abst/abst_o1/var/log\/ -user abst_o1 -type f -\exec rm {} \;\
find /appl/abst/abst_o1/var/tmp/ -user abst_o1 -type f -exec rm {} \;\
find /appl/abst/abst_o1/var/log/ ! -name log -user abst_o1 -type d -exec rmdir {} \;\
find /appl/abst/abst_o1/var/tmp/ ! -name tmp -user abst_o1 -type d -exec rmdir {} \;\
ls -1a /appl/abst/abst_o1| grep -Evw "".|..|var|.ssh"" | xargs -I {} rm -rf {}"
Acceptance,Creating tmp folder,5,abst_o,"mkdir -m 2775 /appl/abst/abst_o1/tmp"
Acceptance,Secure Copy the source files,60,abst_o,"lrv153wc.europe.intranet:/appl/pbst/pbst_o1/var/tmp/pbst_*`date +"%Y%m%d"`* /appl/abst/abst_o1/tmp/."
Acceptance,Unzipping and untarring ER file,20,abst_o,"gunzip /appl/abst/abst_o1/tmp/pbst_o1_`date +""%Y%m%d""`????.tar.gz;\




Ali Khawaja

unread,
Aug 4, 2018, 12:54:38 PM8/4/18
to ansible...@googlegroups.com

Atul, you want to split by columns?

 

Sent from Mail for Windows 10

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/7c8dfc3d-3557-4878-a0a7-0def9ea5100b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

 

Atul Sharma

unread,
Aug 4, 2018, 1:44:36 PM8/4/18
to ansible...@googlegroups.com
Yeah want to split colum 3 and 4 for each row , without any extra characters like  “/ , /“, /r,/n 


Please tell me ho can I do this.





You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/WdXhNd7hH1Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.

To post to this group, send email to ansible...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
Best,
Atul

Sent from IPhone 6s+
Reply all
Reply to author
Forward
0 new messages