karmab/ansible-kcli-modules

kcli, ansible and cloudinit configfile

bgpack opened this issue · 1 comments

Hi @karmab

With joy I'm using your kcli and ansible-kcli-modules.

One short question:
Is it possible to use a cloudinit config file with your ansible-kcli-module?

So far I was not able to get ansible to provide a cloudinit file that kcli will use to create a new vm.

Cheers,
Victor

sorry for the delay, I missed this one! hope you still use kcli and the modules

With the kvirt_vm, you can use parameters the same way that you would with kcli, they get injected into the corresponding vm through cloudinit (or ignition for coreos based images).

For instance, the following will run the indicated commands and make sure the files get created on the box

    kvirt_vm:
      name: superpack
      state: present
      profile: centos8stream
      parameters:
       memory: 2048
       cmds:
       - yum -y install httpd
       - systemctl enable --now httpd
       files:
       - path: /etc/motd
          content: Welcome to the cruel world

Note that the syntax gets rendered to cloudinit and most of the time, the keywords cmds, scripts and files cover the need. Other elements such as ssh key injection happen without a need to specify them (although the keys dict array allow you to inject whatever set of pub keys you want).

Finally, if you want to bring your own cloudinit file, just create a file named $vm.cloudinit in the directory where you launch kcli (or the task using kcli_vm module), that will get merged with kcli generated cloudinit