From ed142772fd9e1f7f4c81d2024749710ea124f75b Mon Sep 17 00:00:00 2001 From: Andrey Gubarev Date: Thu, 25 May 2023 08:32:28 +0400 Subject: [PATCH] add templates for metadata and userdata --- molecule_qemu/playbooks/create.yml | 17 ++++++----------- molecule_qemu/playbooks/templates/meta-data.j2 | 2 ++ molecule_qemu/playbooks/templates/user-data.j2 | 3 +++ 3 files changed, 11 insertions(+), 11 deletions(-) create mode 100644 molecule_qemu/playbooks/templates/meta-data.j2 create mode 100644 molecule_qemu/playbooks/templates/user-data.j2 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 }}