Create directory
Bug #1666446 reported by
Vincent Legoll
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init |
Invalid
|
Undecided
|
Unassigned |
Bug Description
Cloud-init has writefiles, but it looks like it does not have the capability to create directories.
how is mixing
runcmd:
- mkdir /home/toto/bin
and
write_files:
- content: |
#!/bin/sh
echo "Hello world!"
path: /home/toto/
permissions: '0755'
going to work ?
Is runcmd garanteed to happen before write_files ?
What about a "users" section ?
This is the same kind of problem that is reported here:
https:/
To post a comment you must log in.
Thank you for taking the time to report this bug. In an effort to keep
an up-to-date and valid list of bugs to work on, I have reviewed this
report verifying it still requires effort and occurs on a supported
version of Ubuntu.
Write-files is able to create the path for the file it needs to
create. Consider the following example:
userdata.yaml: dir2/file
#cloud-config
write_files:
- path: /root/dir1/
permissions: '0640'
content: my file
encoding: file
This should write a file to /root/dir1/ dir2/file and will be
required to create the dir1 and dir2 directories.
$ lxc init ubuntu-daily:x x
$ lxc config set x user.user-data - < userdata.yaml
$ lxc start x
# go install tree
$ lxc exec x -- tree
.
└── dir1
└── dir2
└── file
The actual code that is run is below, where we check that /github. com/cloud- init/cloud- init/blob/ master/ cloudinit/ util.py# L1492
the path exists and if not use os.makedirs to generate it:
https:/
I am marking this incomplete as I believe the feature works as expected. If
you disagree please feel free to say otherwise and provide additional
details or scenarios as to why.