community.general
community.general copied to clipboard
proxmox: Usage of hookscripts
Summary
I am trying to provision lxc containers via ansible and to have further ansible roles to configure the containers (add packages, etc...) however my first step would be to enable ssh on the containers. i figured i could use hookscripts on my newly created containers to install the ssh package and start the service but i am struggling to understand how to use this configuration token. i have tried to store a script on the proxmox server in one of my mounted volumes but i consistently get Creation of lxc VM 10001 failed with exception: 500 Internal Server Error: unable to parse directory volume name 'hooks/hook.sh'
This is the extract of my playbook, i figured that backups needs to be one of the volumes proxmox knows of but unsure:
- name: Create new container with default
hosts: containers
gather_facts: false
tasks:
- name: Create Containers
delegate_to: 127.0.0.1
community.general.proxmox:
node: proxmox
proxmox_default_behavior: compatibility
api_user: root@pam
api_password: XXXXXXX
api_host: XXXXXXX
vmid: "{{vmid}}"
memory: "{{ memory }}"
cpus: "{{ cpus }}"
hostname: "{{ inventory_hostname }}"
pubkey: "ssh-rsa ..."
password: testtest
ostemplate: 'local:vztmpl/alpine-3.15-default_20211202_amd64.tar.xz'
storage: local-lvm
hookscript: 'backups:hooks/hook.sh`
Issue Type
Documentation Report
Component Name
community.general.proxmox
Ansible Version
$ ansible --version
ansible [core 2.11.12]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/<user>/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/<user>/.local/lib/python3.7/site-packages/ansible
ansible collection location = /home/<user>/.ansible/collections:/usr/share/ansible/collections
executable location = /home/<user>/.local/bin/ansible
python version = 3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0]
jinja version = 3.1.2
libyaml = True
Community.general Version
$ ansible-galaxy collection list community.general
# /home/<user>/.ansible/collections/ansible_collections
Collection Version
----------------- -------
community.general 5.7.0
# /home/<user>/.local/lib/python3.7/site-packages/ansible_collections
Collection Version
----------------- -------
community.general 3.8.3
Configuration
$ ansible-config dump --only-changed
OS / Environment
Debian
Additional Information
No response
Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct
Files identified in the description: None
If these files are incorrect, please update the component name section of the description or use the !component bot command.
!component community.general.proxmox
Files identified in the description:
plugins/modules/cloud/misc/proxmox
If these files are incorrect, please update the component name section of the description or use the !component bot command.
cc @Ajpantuso @Thulium-Drake @joshainglis @karmab @tleguern click here for bot help
fwiw I finally got hook scripts working for myself. You might want to try changing the directory name from hook to snippets, this seems to be where PVE expects scripts to be, this might be the parsing issue you're facing.
thanks! that's a good lead. do you happen to know where this 'snippets' directory needs to be on the proxmox host?
nailed it! https://gist.github.com/aw/ce460c2100163c38734a83e09ac0439a
Files identified in the description:
plugins/modules/proxmox
If these files are incorrect, please update the component name section of the description or use the !component bot command.
cc @UnderGreen click here for bot help
cc @krauthosting click here for bot help