Reputation: 19
I'm trying to merge the following multi part cloud-init file.
The runcmd and write-files are working perfectly, but I can't merge the keys on the ssh-authorized-keys of the root user.
Anyone knows how to do that?
Content-Type: multipart/mixed; boundary="//"
MIME-Version: 1.0
--//
Content-Type: text/cloud-config; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cloud-config.txt"
Merge-Type: list(append)+dict(no_replace,recurse_list)+str()
#cloud-config'
hostname: ${hostname}
create_hostname_file: true
fqdn: ${fqdn}
prefer_fqdn_over_hostname: true
disable_root: false
users:
- name: root
ssh-authorized-keys:
- ssh-rsa AAA... the_one_key
runcmd:
- |
touch > /home/lele.txt
echo "lele" > /home/lele.txt
write_files:
- path: /home/du.conf
content: du
--//
Content-Type: text/cloud-config; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cloud-config(2).txt"
Merge-Type: list(append)+dict(no_replace,recurse_list)+str()
#cloud-config
users:
- name: root
ssh-authorized-keys:
- ssh-rsa AAA... the_second_key
runcmd:
- |
touch > /home/lala.txt
echo "lala" > /home/lala.txt
write_files:
- path: /home/ti.conf
content: ti
--//--
Here is the content generated by cloud-init after merge
As you can see the users: section is been merged but just the first key is included on the /root/.ssh/authorized_keys file.
What I want is that cloud-init merge the keys on ssh-authorized-keys: list instead duplicate the root section.
#cloud-config
# from 2 files
# cloud-config.txt
# cloud-config(2).txt
---
create_hostname_file: true
disable_root: false
fqdn: vm-test.com
hostname: vm-test
prefer_fqdn_over_hostname: true
runcmd:
- 'touch > /home/lele.txt
echo "lele" > /home/lele.txt
'
- 'touch > /home/lala.txt
echo "lala" > /home/lala.txt
'
users:
- name: root
ssh-authorized-keys:
- ssh-rsa AAAAB...
the_one_key
- name: root
ssh-authorized-keys:
- ssh-rsa AAAAB...
the_second_key
write_files:
- content: du
path: /home/du.conf
- content: ti
path: /home/ti.conf
...
Upvotes: 0
Views: 22