---
- hosts: lokal
  become: yes

  vars:
    lxc_names:
      - debian
      - suse
      - rocky
      - ubuntu

  tasks:
  - name: Create a started container
    community.general.lxc_container:
      name: "{{ item }}"
      container_log: true
      template: ubuntu
      state: started
      template_options: --release focal
      #container_command: |
      #  hostname -I
    with_items: "{{ lxc_names }}"
    register: lvm_container_info

  - name: Variable ausgeben
    debug:
      msg: "Der Container {{ item.item }} hat {{ item.lxc_container.ips[0] }}"
    with_items: "{{ lvm_container_info.results }}"

  - name: Create inventory
    template:
      src: inventory.j2
      dest: inventory
