meffie / molecule-proxmox

Molecule driver for Proxmox VE
MIT License
36 stars 8 forks source link

Error creating a VM #4

Closed tazou closed 1 year ago

tazou commented 1 year ago

Hello, this is the first time I try your driver, so maybe I made something wrong. I would like to create ephemeral VM on a proxmox server from molecule command line to test ansible roles.

Here is my informations: I'm on MacOS M1 arch with:

molecule 3.5.2 using python 3.10 
    ansible:2.12.2
    delegated:3.5.2 from molecule
    proxmox:0.7.0 from molecule_proxmox
    vagrant:1.0.0 from molecule_vagrant

And

pip list |grep proxmox
molecule-proxmox           0.7.0
proxmoxer                  1.3.1

I installed on my Mac your driver, with: pip install molecule-proxmox

I create a new fresh role with: molecule init role --driver-name proxmox vim This step is working fine.

Inside the file molecule/default/molecule.yml I put this:

---
dependency:
  name: galaxy
driver:
  name: proxmox
  options:
     api_host: my-ip:8006
     api_user: my-user@pam
     api_password: "my-password"
     node: proxmox01
     ssh_user: tester #fill later
     ssh_identity_file: /path/to/id_rsa #fill later
     template_name: ubuntu-20-04-template-2022-05-10
     sethostname: no
platforms:
  - name: instance
provisioner:
  name: ansible
verifier:
  name: ansible

And when I run molecule converge I have this output:

INFO     default scenario test matrix: dependency, create, prepare, converge
INFO     Performing prerun...
INFO     Set ANSIBLE_LIBRARY=/Users/gduale/.cache/ansible-compat/f1d54c/modules:/Users/gduale/OPS_Tools/ansible/plugins/modules:/Users/gduale/.ansible/plugins/modules:/usr/share/ansible/plugins/modules
INFO     Set ANSIBLE_COLLECTIONS_PATH=/Users/gduale/.cache/ansible-compat/f1d54c/collections:/Users/gduale/.ansible/collections:/usr/share/ansible/collections
INFO     Set ANSIBLE_ROLES_PATH=/Users/gduale/.cache/ansible-compat/f1d54c/roles:/Users/gduale/OPS_Tools/ansible/roles
INFO     Running default > dependency
WARNING  Skipping, missing the requirements file.
WARNING  Skipping, missing the requirements file.
INFO     Running default > create

PLAY [Create] ******************************************************************

TASK [Load proxmox secrets.] ***************************************************
skipping: [localhost]

TASK [Create molecule instance(s).] ********************************************
failed: [localhost] (item=instance) => {"ansible_loop_var": "p", "changed": false, "msg": "No VM with name instance found", "p": {"name": "instance"}}

PLAY RECAP *********************************************************************
localhost                  : ok=0    changed=0    unreachable=0    failed=1    skipped=1    rescued=0    ignored=0

CRITICAL Ansible return code was 2, command was: ['ansible-playbook', '--inventory', '/Users/gduale/.cache/molecule/dt_vim/default/inventory', '--skip-tags', 'molecule-notest,notest', '/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/molecule_proxmox/playbooks/create.yml']

I don't understand why it said the VM is not here, because I believe it should create this VM.

From what I understand, the part:

platforms:
  - name: instance

tell to proxmox "you need to create a new VM named 'instance'". And it'll use the template_name: ubuntu-20-04-template-2022-05-10 to clone it to create the new VM "instance". I'm right?

I tried the option sethostname with "yes" and "no", but the issue is the same.

Do you have an idea please?

Thank you, Bests regards.

meffie commented 1 year ago

Hello,

Thank you for trying the molecule-proxmox driver.

Yes, your understanding is correct, and your molecule file does look correct. I'm taking a closer look at the code to investigate.

wontfixthis commented 1 year ago

I'm also running on a Apple M1 (with molecule-proxmox 0.7.0, proxmoxer 1.3.1, molecule 4.0.0) and PVE 7.2-7 and can not reproduce this error. But I had some other permission issues with PVE when I tried to use not the root user. Might be helpful to eliminate permission problems by using the root user or try the same PVE version as I did. Not sure if this comment is helpful for you, fingers crossed.

meffie commented 1 year ago

Not sure what went wrong here, but it may have been some local setup issues. Closing this one for now since wontfixthis reported success. We can reopen if we get more information

Many thanks.