ubuntuansibleyamllxclxd

Script is getting stuck in the LXC init task


I'm a new user of ansible and I'm trying to launch a lxc init in a yaml script:

  - name: Copy LXC init file
  ansible.builtin.copy:
    src: /home/user/lxcInitFile.yaml
    dest: /tmp/
    owner: root
    group: root
    mode: '0644'

#- name: Destroy default zpool storage
#  command: zpool destroy default

- name: Launch LXC Initialization
  command: lxd init --preseed < /tmp/lxcInitFile.yaml
  debugger: always

My lxcInitFile.yaml file

config: {}
networks:
- config:
    ipv4.address: auto
    ipv6.address: none
  description: ""
  name: custom0
  type: ""
storage_pools:
- config:
    size: 5GB
  description: ""
  name: default
  driver: zfs
profiles:
- config: {}
  description: ""
  devices:
    eth0:
      name: eth0
      network: custom0
      type: nic
    root:
      path: /
      pool: default
      type: disk
  name: default
cluster: null

When I launch this with ansible, my script is getting stuck in the LXC init task, without debugging informations. If somebody have an idea it will be great.


Solution

  • I've changed

    command: lxd init --preseed < /tmp/lxcInitFile.yaml
    

    to

    shell: lxd init --preseed < /tmp/lxcInitFile.yaml
    

    and it's ok