Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1529598

Summary: write_files give an error "No such file or directory"
Product: Red Hat Enterprise Linux 7 Reporter: karima.rafes
Component: cloud-initAssignee: Ryan McCabe <rmccabe>
Status: CLOSED NOTABUG QA Contact: Vratislav Hutsky <vhutsky>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: 7.7CC: jbadiapa, jgreguske, lars, mmagr, mrunge
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-12-30 01:35:40 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description karima.rafes 2017-12-28 21:29:31 UTC
Description of problem:

I used this cloud config :
************************************
#!cloud-config
users:
  - name: jupyter
    shell: /bin/bash
    lock-passwd: true
    sudo: ALL=(ALL) NOPASSWD:ALL
    ssh-authorized-keys:
      - ssh-rsa XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
write_files:
-   encoding: gzip
    content: !!binary |
       ^_<8b>^H^@^@^@^@^@^B^CÍW[wã4^P~ϯ<98>ã^^hÊibØìÓÒö<81>årºÀR<96>îS<9b>ãUì<89>#"K®$'1=ýï<8c>äK<93>Ô)´4À<83>^SkfôÍh47ßö <88>Q^H^S¼<81>«^^À-=^U%²e<8e>D^M2¦ç<89>ZÊàØó2´,a<96>^Qëö®"^YUè^Xk^DZ<9f>ð,^E£ãÓë`8^LyÆR4!ÏK;S2^R*UÃ\¦×ÁYàÄÇôãq^Dõ7,<9e><83>U`g^H^Yã^R®Îe<82>«q<9f>^LñoC²CN<8e>ö ú^@Î/ü^QáGÔ^RÅ^^T4
r­^V<A^C¸²(^MWÒ4<87>¾<97>H5Ë2.S^PL¦^EÝ^Añ<99>%¯Ì^Q<96>JÏ^]<8b>K<8b><9a>Å<96>/P<94>^P+¹@ÉQZ`2^A<9c>NyìVC¸<9c>¡ÁumL#ð,^W<98>^Q^_^S^BòÚ7=àQ<9c>$[0.ØD <93>cB<80><9a>n<88>^?¯^U¡ÈÄ@ÿ½²8Qj~^L<97>¨É|&<8e>á-iT´ÙÁýj<9b>å^Q,g(A^WRº£Ø^Y70÷z<87>û¸Ý^C¸,¬Ò<9c>Q®¼<ü^Wpõ<96>^Pàg<96>òØ<8c>ûk<8b>:b¯k4/û[¬yn[é<8d>e<97>ü^G^^Ïà<97>Âæ<85>^]÷×^V]²o^KcU^Fßr<93>^KVÂO<8a>@É ^Nj×î^K¡¬­BË_qs<9f>ãþ.N§^M,·<85>vÂ<8d>ÑÛ<94>=æñ^A|·b.¶÷tÑ®F¥Z^U^TÍïÔ<84>®o<8b>Ðå<90>KÍrüCñ^D>^T^BÇýÍug<88><94>ÙEI¡áþ:C<82>-á\<92>'^_ÞÔNÖ^<9d>þ^É<81>¬^UQ©ÙÛ^M\ºB<91>p<8d>1¥sIåÈ(Wù,u^KÓê­j¥«]^ZÓB0Ý^TÖþ§a^~:<82>)'©¿.4±J°6^MW^X^W<96>ªg^TÓU[â~õÐæÊÄX      Ár<83>  <91>¦d :r}^\åÃß´ç©¶@°<81>@kKÕ:<9c>ÙL´<92>¾53<98>i<9c><9e>^^Ö^G^]$<98>Q;.^OÁ2<9d>¢==<8c>&Ô/æ<87>g[^B'!;;<99>èªg»C^_o(¢¢Àå<86>¦ð£AmB*áz^^&¸ ^AÀ-0l\^\n6<8b>pKa«¨ú¿«õuÜpë<94>ÖëIU¥"/×[ÛþLgÕ³Ë<80>^\4 èqqÓé³n¹ý»®[ï^K{°×<9a>þ ¥>£&^L4aQx^K^S
² ÊË*CxmÇKç0º±Â=.}^Y^X´n¨ØL_3SKp^OÍFnÒ¡<89>ÈÞ^O^]KngT^G¦S<82>¢<89>ç<87><8f>ç<80>^K÷&<94>ÊÍ<9b>^?<96>Ú¯þýÔvR¡<8b>³¶Ì;êçrbò¯«ß6<9e>½è<94>ª^Z^N^?7J>^Lä{Þ<93><83>×co<98>^@p^O÷?Èê´à^?ÓMN<92><9e>A*hÞèÊ÷5fã§' ÚùnPÏ{^Væè1ÐѳPó2^U¸Û^C-ûéÈ7»Qo<9e><87>ø<88>S<9f>éÓåj'¢g=9C^\ðV<82>¬^ER^WÇ[ÞÍ^XusÚ;éàÝì ïÒâOù<9f>6^SSLh`Ûj&=^O°]b<83>ê^SÐä^X7¥ Õ/Yæí©^[À¨®ÞÍ÷±cU<8d>´f4ò^Uq^T4Í Ý^Qq9U­^Z×^P2®µÒQæzC[ó^[^\¾<8e>^NÁ<82><9a><õ^Lâ<8c>Ö<9a><80>k<9b>Qû¥í¶9ï×í<84>Óik§úàZ^M^^1¸!Nüw½¶<84><9a>+M^_ü^OD(ZÜw¼<89>^Du2½fjã¢{S<83>ÑðõðUP]<80>3<99>ð§JgÌu½×ëë<88>F^VåÀ¾ìÝõþ^DÔ^X/yh^R^@^@
    owner: jupyter:jupyter
    path: "/home/jupyter/Notebooks/Index.ipynb"
    permissions: '0555'
************************************

 But I have an error in the log and the file  Index.ipynb  didn't write :
************************************
2017-12-28 20:37:54,182 - util.py[DEBUG]: Running command ['/var/lib/cloud/instance/scripts/part-001'] with allowed return codes [0] (shell=False, capture=False)
2017-12-28 20:37:54,186 - util.py[WARNING]: Failed running /var/lib/cloud/instance/scripts/part-001 [-]
2017-12-28 20:37:54,186 - util.py[DEBUG]: Failed running /var/lib/cloud/instance/scripts/part-001 [-]
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/cloudinit/util.py", line 802, in runparts
    subp(prefix + [exe_path], capture=False)
  File "/usr/lib/python2.7/site-packages/cloudinit/util.py", line 1849, in subp
    errno=e.errno)
ProcessExecutionError: Unexpected error while running command.
Command: ['/var/lib/cloud/instance/scripts/part-001']
Exit code: -
Reason: [Errno 2] No such file or directory
Stdout: -
Stderr: -
2017-12-28 20:37:54,195 - cc_scripts_user.py[WARNING]: Failed to run module scripts-user (scripts in /var/lib/cloud/instance/scripts)
2017-12-28 20:37:54,195 - handlers.py[DEBUG]: finish: modules-final/config-scripts-user: FAIL: running config-scripts-user with frequency once-per-instance
2017-12-28 20:37:54,195 - util.py[WARNING]: Running module scripts-user (<module 'cloudinit.config.cc_scripts_user' from '/usr/lib/python2.7/site-packages/cloudinit/config/cc_scripts_user.pyc'>) failed
2017-12-28 20:37:54,195 - util.py[DEBUG]: Running module scripts-user (<module 'cloudinit.config.cc_scripts_user' from '/usr/lib/python2.7/site-packages/cloudinit/config/cc_scripts_user.pyc'>) failed
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/cloudinit/stages.py", line 777, in _run_modules
    freq=freq)
  File "/usr/lib/python2.7/site-packages/cloudinit/cloud.py", line 54, in run
    return self._runners.run(name, functor, args, freq, clear_on_fail)
  File "/usr/lib/python2.7/site-packages/cloudinit/helpers.py", line 187, in run
    results = functor(*args)
  File "/usr/lib/python2.7/site-packages/cloudinit/config/cc_scripts_user.py", line 45, in handle
    util.runparts(runparts_path)
  File "/usr/lib/python2.7/site-packages/cloudinit/util.py", line 809, in runparts
    % (len(failed), len(attempted)))
RuntimeError: Runparts: 1 failures in 1 attempted commands
*********************************************

Version-Release number of selected component (if applicable):

cloud-init-0.7.9-9.el7.centos.2.x86_64 (installed via yum)
centos-release-7-4.1708.el7.centos.x86_64


How reproducible:


Steps to Reproduce:
1. Push the same cloud-config

Actual results:
The file didn't write after the cloud-init

Expected results:
A new file will exist (and uncompress).

Additional info:
I duplicate this bug also here : https://bugs.launchpad.net/cloud-init/+bug/1740431

This urgent for me ;-)
Can you help me ? or is it a bug in Cloud-init ?

Thanks

Comment 2 Ryan McCabe 2017-12-29 03:16:15 UTC
The data needs to be base64 encoded.

Comment 3 karima.rafes 2017-12-29 09:36:49 UTC
Same error with gzip+base64 :

*******************
write_files:
-   encoding: "gzip+base64"
    content: |
        H4sIAAAAAAACA81XW3fjNBB+z6+Y4x5oymli2OzT0vaB5XK6wFKW7lOb41XsiSMiS64kJzE9/e+M5EuT1Cm0NMCDE2tm9M1oNDff9iCIUQgTvIGrHsAtPRUlsmWORA0ypueJWsrg2PMytCxhlhHr9q4iGVXoGGsEWp/wLAWj49PrYDgMecZSNCHPSztTMhIqVcNcptfBWeDEx/TjcV5E9TcsnoNVYGcIGeMSrs5lgqtxnwzxb0OyQ06O9qD6AM4v/BHhR9QSxR5UNApyrRY8QQO4sigNV9I0h76XSDXLMi5TEEymBd0B8Zklr8wRlkrPHYtLi5rFli9QlBAruUDJUVpgMgGcTnnsVkO4nKHBdW1MI/AsF5gRHxMC8to3PeBRnCRbMC7YRKCTY0KAmm6If68VocjEQP+9sjhRan4Ml6jJfCaO4S1pVLTZwf1qm+URLGcoQRdSuqPYGTcw93qH+7jdA7gsrNKcUa68PPwXcPWWEOBnlvLYjPtrizpir2s0L/tbrHluW+mNZZf8Bx7P4JfC5oUd99cWXbJvC2NVBt9ykwtWwk+KQMmgDmrX7guhrK1Cy19xc5/j/i5Opw0st4V2wo3R25Q95vEBfLdiLrb3dNGuRqVaFRTN79SErm+L0OWQS81y/EPxBD4UAsf9zXVniJTZRUmh4f46Q4It4VySJx/e1E7WXp3+XsmBrBVRqdnbDVy6QpFwjTGlc0nlyChX+Sx1C9PqrWqlq10a00Iw3RTW/qdhXn46giknqb8uNLFKsDYNVxgXlqpnFNNVW+J+9dDmysRYCcFygwmRpmQgOnJ9HOXD37TnqbZAsIFAa0vVOpzZTLSSvjUzmGmcnh7WBx0kmFE7Lg/BMp2iPT2MJtQv5odnWwInITs7meiqZ7tDH28ooqLA5Yam8KNBbUIq4XoeJrigAcAtMGxcHG42i3BLYauo+r+r9XXccOuU1utJVaUiL9db2/5MZ9Wzy4AcNKDocXHT6bNuuf27rlvvC3uw15r+IKU+oyYMNGFReAsTCrIgyssqQ3htx0vnMLqxwj0ufRkYtG6o2ExfM1NLcA/NRm7SoYnI3g8dS25nVAemU4KiieeHj+eAC/cmlMrNm3+W2q/+/dR2UqGLs7bMO+rncmLyr6vfNp696JSqGg5/N0o+DOR73pOD12NvmABwD/c/yOq04H/TTU6SnkEqaN7oyvc1ZuOnJ6Da+W5Qz3sW5ugx0NGzUPMyFbjbAy376cg3u1Fvnof4iFOf6dPlaieiZz05QxzwVoKsBVIXx1vezRh1c9o76eDd7KDv0uJP+Z82E1NMaGDbaiY9D7BdYoPqE9DkGDeloNUvWebtqRvAqK7ezfexY1WNtGY08hVxFDTNoN0RcTlVrRrXEDKutdJR5npDW/MbHL6ODsGCmjz1DOKM1pqAa5tR+6Xttjnv1+2E02lrp/rgWg0eMbghTvx3vbaEmitNH/wPRCha3He8iQR1Mr1mauOie1OD0fD18FVQXYAzmfCnSmfMdb3X6+uIRhblwL7s3fX+BNQYL3loEgAA
    owner: jupyter:jupyter
    path: "/home/jupyter/Notebooks/Index.ipynb"
    permissions: '0555'
******************************

Comment 4 karima.rafes 2017-12-29 10:19:59 UTC
Same error with this test :
******************************
write_files:
-   content: |
        # test
    path: /tmp/test.txt
******************************

Comment 5 karima.rafes 2017-12-29 11:10:45 UTC
I found.

First problem, I added '!' in the first line because Yaml had a problem probably about  base64 encoded.

So second problem, base64 encoded. Thanks

The solution is :
******************************
#cloud-config
write_files:
-   encoding: "gzip+base64"
    content: |
        H4sIAAAAAAACA81XW3fjNBB+z6+Y4x5oymli2OzT0vaB5XK6wFKW7lOb41XsiSMiS64kJzE9/e+M5EuT1Cm0NMCDE2tm9M1oNDff9iCIUQgTvIGrHsAtPRUlsmWORA0ypueJWsrg2PMytCxhlhHr9q4iGVXoGGsEWp/wLAWj49PrYDgMecZSNCHPSztTMhIqVcNcptfBWeDEx/TjcV5E9TcsnoNVYGcIGeMSrs5lgqtxnwzxb0OyQ06O9qD6AM4v/BHhR9QSxR5UNApyrRY8QQO4sigNV9I0h76XSDXLMi5TEEymBd0B8Zklr8wRlkrPHYtLi5rFli9QlBAruUDJUVpgMgGcTnnsVkO4nKHBdW1MI/AsF5gRHxMC8to3PeBRnCRbMC7YRKCTY0KAmm6If68VocjEQP+9sjhRan4Ml6jJfCaO4S1pVLTZwf1qm+URLGcoQRdSuqPYGTcw93qH+7jdA7gsrNKcUa68PPwXcPWWEOBnlvLYjPtrizpir2s0L/tbrHluW+mNZZf8Bx7P4JfC5oUd99cWXbJvC2NVBt9ykwtWwk+KQMmgDmrX7guhrK1Cy19xc5/j/i5Opw0st4V2wo3R25Q95vEBfLdiLrb3dNGuRqVaFRTN79SErm+L0OWQS81y/EPxBD4UAsf9zXVniJTZRUmh4f46Q4It4VySJx/e1E7WXp3+XsmBrBVRqdnbDVy6QpFwjTGlc0nlyChX+Sx1C9PqrWqlq10a00Iw3RTW/qdhXn46giknqb8uNLFKsDYNVxgXlqpnFNNVW+J+9dDmysRYCcFygwmRpmQgOnJ9HOXD37TnqbZAsIFAa0vVOpzZTLSSvjUzmGmcnh7WBx0kmFE7Lg/BMp2iPT2MJtQv5odnWwInITs7meiqZ7tDH28ooqLA5Yam8KNBbUIq4XoeJrigAcAtMGxcHG42i3BLYauo+r+r9XXccOuU1utJVaUiL9db2/5MZ9Wzy4AcNKDocXHT6bNuuf27rlvvC3uw15r+IKU+oyYMNGFReAsTCrIgyssqQ3htx0vnMLqxwj0ufRkYtG6o2ExfM1NLcA/NRm7SoYnI3g8dS25nVAemU4KiieeHj+eAC/cmlMrNm3+W2q/+/dR2UqGLs7bMO+rncmLyr6vfNp696JSqGg5/N0o+DOR73pOD12NvmABwD/c/yOq04H/TTU6SnkEqaN7oyvc1ZuOnJ6Da+W5Qz3sW5ugx0NGzUPMyFbjbAy376cg3u1Fvnof4iFOf6dPlaieiZz05QxzwVoKsBVIXx1vezRh1c9o76eDd7KDv0uJP+Z82E1NMaGDbaiY9D7BdYoPqE9DkGDeloNUvWebtqRvAqK7ezfexY1WNtGY08hVxFDTNoN0RcTlVrRrXEDKutdJR5npDW/MbHL6ODsGCmjz1DOKM1pqAa5tR+6Xttjnv1+2E02lrp/rgWg0eMbghTvx3vbaEmitNH/wPRCha3He8iQR1Mr1mauOie1OD0fD18FVQXYAzmfCnSmfMdb3X6+uIRhblwL7s3fX+BNQYL3loEgAA
    owner: jupyter:jupyter
    path: "/home/jupyter/Notebooks/Index.ipynb"
    permissions: '0555'
******************************