Anisible not working lxd 3.0 on ubuntu 18.10

we try to run ansible to create LXD but have problem this below log:

“logs”: [
{
“request”: {
“json”: null,
“method”: “GET”,
“timeout”: null,
“url”: “/1.0/containers/mycontainer”
},
“response”: {
“json”: {
“error”: “not found”,
“error_code”: 404,
“type”: “error”
}
},
“type”: “sent request”
},
{
“request”: {
“json”: {
“name”: “mycontainer”,
“profiles”: [
“default”
],
“source”: {
“alias”: “ubuntu/bionic/amd64”,
“mode”: “pull”,
“protocol”: “simplestreams”,
“server”: “https://images.linuxcontainers.org”,
“type”: “image”
}
},
“method”: “POST”,
“timeout”: null,
“url”: “/1.0/containers”
},
“response”: {
“json”: {
“error”: “No storage pool found. Please create a new storage pool”,
“error_code”: 400,
“type”: “error”
}
},
“type”: “sent request”
}
],
“msg”: “No storage pool found. Please create a new storage pool”
}

I try to using curl to test APT then API working. But with anisble not working. This below is content of ansible:

  • hosts: localhost
    connection: local
    tasks:
    • name: Create a started container
      lxd_container:
      name: mycontainer
      state: started
      source:
      type: image
      mode: pull
      server: https://images.linuxcontainers.org
      alias: ubuntu/bionic/amd64
      protocol: simplestreams
      profiles: [“default”]
      wait_for_ipv4_addresses: true
      timeout: 600

Someone have ideal to solve this case ?

Looks like you never configured LXD (ran lxd init) so Ansible can’t create containers as storage was never configured.

Yes, I think so too. There’s an Ansible role that can do some basic LXD initialization (as well as install LXD itself) in case you want to automate that: GitHub - juju4/ansible-lxd: Ansible role to setup LXD, its bridge, pre-copy images and eventually pre-configure some

Hi!

It looks like LXD has not been configured yet, yet there has been an API call to create a container.
Do you have some specific tutorial on how to use the API? Does it have a section on LXD initialization?

I configured lxd init completed in past. Because i can create container by using command such as “lxc launch ubuntu:18.04” . I try to reinstall VM and this problem solved.

Thanks you