ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
814 stars 1.49k forks source link

proxmox: Adds new parameter `cmode` (LXC / Options / Console mode) #8787

Open fdcastel opened 3 weeks ago

fdcastel commented 3 weeks ago

Summary

I just noticed the missing equivalent of the --cmode switch in the pct create command:

--cmode <console | shell | tty> (default = tty) Console mode. By default, the console command tries to open a connection to one of the available tty devices. By setting cmode to console it tries to attach to /dev/console instead. If you set cmode to shell, it simply invokes a shell inside the container (no login).

Source: https://pve.proxmox.com/pve-docs/pct.1.html

Via Web UI:

image

Issue Type

Feature Idea

Component Name

proxmox

Additional Information

I often create containers with --cmode shell.

It's very useful since it allows faster access to the LXC console without login.

Code of Conduct

fdcastel commented 3 weeks ago

Workaround using Proxmox API:

  vars:
    proxmox:
      node: MY_SAMPLE_NODE
      vmid: 123

      api_host: "{{ lookup('env', 'PROXMOX_API_HOST') }}"
      api_port: "{{ lookup('env', 'PROXMOX_API_PORT') }}"
      api_user: "{{ lookup('env', 'PROXMOX_API_USER') }}"
      api_password: "{{ lookup('env', 'PROXMOX_API_PASSWORD') }}"

  tasks:
    - name: Request auth ticket
      uri:
        url: "https://{{ proxmox.api_host }}:{{ proxmox.api_port }}/api2/json/access/ticket"
        method: POST
        validate_certs: no
        body_format: json
        body: { "username": "{{ proxmox.api_user }}", "password": "{{ proxmox.api_password }}" }
      register: ticket_response

    - name: Set console mode to shell
      uri:
        url: "https://{{ proxmox.api_host }}:{{ proxmox.api_port }}/api2/json/nodes/{{ proxmox.node }}/lxc/{{ proxmox.vmid }}/config"
        method: PUT
        validate_certs: no
        headers:
          Cookie: "PVEAuthCookie={{ ticket_response.json.data.ticket }}"
          CSRFPreventionToken: "{{ ticket_response.json.data.CSRFPreventionToken }}"
        body_format: json
        body: { "cmode": "shell" }
ansibullbot commented 3 weeks ago

cc @Ajpantuso @Thulium-Drake @UnderGreen @joshainglis @karmab @krauthosting click here for bot help