future2000
Enthusiast
Enthusiast

Cloudinit YAML syntax to write out multiple files on Windows guests

Hi,

I've been struggling getting cloudinit to write out multiple files on a Windows guest. I followed practically every example I've found on the web and whatever I do cloud init will only write out one file, it ignores the rest. The syntax is in the blueprint YAML and looks something like this.

cloudConfig: |

write_files:

-path c:\sources\Configure.PS1

content: |

     Powershell written here   

-path c:\sources\Configure-another-thing.PS1

content: |

     Powershell written here.

Whatever indentation and order I have tried only writes the first or last file. I previously had the path at the end of the content section. This then writes out only the last file. Never both files. I've tried all the syntax examples I've found across the web to no avail!

Anyone written out multiple files on Windows Guests with vRA 8.1 Blueprints?

Cheers

0 Kudos
7 Replies
A_Mikkelsen
Expert
Expert

Having same issue with 8.4

If you found this or any other answer useful please consider the use of the Helpful or correct buttons to award points. Regards A. Mikkelsen
0 Kudos
jimmyvandermast
Enthusiast
Enthusiast

cloudConfig: |

write_files:

  - content: |

     Powershell1 written here   

  path c:\sources\Configure.PS1

  - content: |

     Powershell2 written here.

  path c:\sources\Configure-another-thing.PS1

 

A_Mikkelsen
Expert
Expert

Thanks

I'll try, but it didn't work 3 days ago 😀

If you found this or any other answer useful please consider the use of the Helpful or correct buttons to award points. Regards A. Mikkelsen
0 Kudos
AMikkelsenJob
Contributor
Contributor

It worked.
https://cloudinit.readthedocs.io/en/latest/topics/modules.html#write-files 
I had tested (not working)

writefiles:
  content: |
       test 1
  path: C:\dl\file 1.ps1

  content: |
       test 2
  path: C:\dl\file 2.ps1

But changing to (worked)

writefiles:
  - content: |
       test 1
    path: C:\dl\file 1.ps1

  - content: |
       test 2
    path: C:\dl\file 2.ps1

0 Kudos
jimmyvandermast
Enthusiast
Enthusiast

like my suggestion.  🙂

first content with a dash and then path without a dash.

You say that the readthecods.io link example did not work, but I think you did not follow it correctly.
As far as I see, it does contain the working example:


write_files:
  - content: |
    15 * * * * root ship_logs
  path: /etc/crontab
  append: true

AMikkelsenJob
Contributor
Contributor

Link worked. just not placed optimal in text 😀

0 Kudos