diff --git a/molecule_qemu/playbooks/create.yml b/molecule_qemu/playbooks/create.yml index d0cee39..7298e2c 100644 --- a/molecule_qemu/playbooks/create.yml +++ b/molecule_qemu/playbooks/create.yml @@ -70,23 +70,18 @@ loop_control: label: "{{ item.name }}" - - name: Create cloud-init meta-data - ansible.builtin.copy: - content: | - instance-id: {{ item.name }} - local-hostname: {{ item.name }} + - name: Render meta-data template + ansible.builtin.template: + src: templates/meta-data.j2 dest: "{{ molecule_ephemeral_directory }}/run/cloud-init/{{ item.name }}/meta-data" mode: "0644" loop: "{{ molecule_instances }}" loop_control: label: "{{ item.name }}" - - name: Create cloud-init user-data - ansible.builtin.copy: - content: | - #cloud-config - ssh_authorized_keys: - - {{ vm_ssh_identity_file.public_key }} + - name: Render user-data template + ansible.builtin.template: + src: templates/user-data.j2 dest: "{{ molecule_ephemeral_directory }}/run/cloud-init/{{ item.name }}/user-data" mode: "0644" loop: "{{ molecule_instances }}" diff --git a/molecule_qemu/playbooks/templates/meta-data.j2 b/molecule_qemu/playbooks/templates/meta-data.j2 new file mode 100644 index 0000000..345155d --- /dev/null +++ b/molecule_qemu/playbooks/templates/meta-data.j2 @@ -0,0 +1,2 @@ +instance-id: {{ item.name }} +local-hostname: {{ item.name }} diff --git a/molecule_qemu/playbooks/templates/user-data.j2 b/molecule_qemu/playbooks/templates/user-data.j2 new file mode 100644 index 0000000..c2e758d --- /dev/null +++ b/molecule_qemu/playbooks/templates/user-data.j2 @@ -0,0 +1,3 @@ +#cloud-config +ssh_authorized_keys: +- {{ vm_ssh_identity_file.public_key }}