ansible report

BinaryJacob Jul 20th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import csv
  2. import re  
  3. with open("sample.txt", mode="r") as fl:  
  5.     data2=data.strip("TASK [print out]").replace("*","").replace("{", "").replace("}","").replace("[","").replace("]","").replace("=>","").replace("ok:","").replace("\"msg\":","").replace("\t","")  
  6.     with open("ansible.csv", mode="a") as ansfl:
  7.         line_row=csv.writer(ansfl,delimiter=",", quotechar='"', quoting=csv.QUOTE_MINIMAL)
  8.         line_row.writerow(["HOSTNAME","PACKAGENAMES","STATUS"])
  9.         for line in data2.split():
  10.             if re.match(".*\.com", line):  
  11.                 domain=re.match(".*\.com", line)  
  12.                 line_row.writerow([line,"",""])
  13.             else:  
  14.                 line_row.writerow(["",line,"PENDING"])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand