Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proxmox lxc - allow update of existing containers #1278

Open
n0emis opened this issue Nov 12, 2020 · 10 comments
Open

proxmox lxc - allow update of existing containers #1278

n0emis opened this issue Nov 12, 2020 · 10 comments
Labels
cloud feature This issue/PR relates to a feature request has_pr module module plugins plugin (any type)

Comments

@n0emis
Copy link

n0emis commented Nov 12, 2020

SUMMARY

Allow to update existing containers.

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

proxmox

ADDITIONAL INFORMATION

When managing lxc-containers on proxmox from ansible, it is currently not possible to update these containers, e.g. change the ip-address etc. This would be a really good addition, since it is currently needed to update this at multiple places: the playbook and proxmox itself.

@ansibullbot
Copy link
Collaborator

Files identified in the description:
None

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot ansibullbot added affects_2.10 feature This issue/PR relates to a feature request needs_triage labels Nov 12, 2020
@ansibullbot
Copy link
Collaborator

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added cloud module module plugins plugin (any type) labels Nov 12, 2020
@tleguern
Copy link
Contributor

This is actually harder than it looks as a careless update will destroy and recreate the network devices instead of updating them.

I am working on this problem for proxmox_kvm.

@ansibullbot
Copy link
Collaborator

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.

click here for bot help

@ansibullbot
Copy link
Collaborator

@ansibullbot
Copy link
Collaborator

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.

click here for bot help

@ansibullbot
Copy link
Collaborator

@Skaronator
Copy link

This seems to be somewhat fixed by #7540. You can now provide a update: true flag, but sadly, it's not that simple. You cannot configure ostemplate in the same task, which means you have to split it up into 2 tasks, with the only difference being the ostemplate and update attribute.

I tried reducing duplicated code by using YAML Anchor like so:

- name: Create LXC Container (if missing) 
  community.general.proxmox: &container
    # proxmox api
    api_host: "{{ ansible_host }}"
    api_user: root@pam
    api_password: "{{ (admins | combine(users | default({}), recursive=true))['root']['password'] }}"
    node: "{{ ansible_hostname }}"
    # lxc config
    hostname: "{{ item.hostname }}"
    vmid: "{{ item.vmid }}"
    memory: "{{ item.memory }}"
    cpus: "{{ item.cpus }}"
    netif: "{{ item.netif | to_json }}"
    # static stuff
    swap: 0
    password: "{{ lxc_password }}"
    ostemplate: "{{ lxc_template_storage }}:{{ lxc_template_path }}/{{ item.template }}"
    pubkey: "{{ (admins | combine(users | default({}), recursive=true))['root']['sshpubkey'] }}"
  loop: "{{ lxc }}"

- name: Update LXC container
  community.general.proxmox:
    <<: *container
    state: "{{ item.state | default('started') }}"
    ostemplate: null
    update: true
  loop: "{{ lxc }}"

But this doesn't work since ostemplate is still present, and I can't get rid of it by setting ostemplate: null or leaving it empty (ostemplate: ).

It would be cool if the module ignored ostemplate altogether, and we can just use a single task with the limitation that you cannot update ostemplate.

@ansibullbot
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cloud feature This issue/PR relates to a feature request has_pr module module plugins plugin (any type)
Projects
None yet
Development

No branches or pull requests

5 participants