pve-apt-hook und ansible

ThorstenS

Member
May 21, 2015
18
1
23
~
Hi Leute,

ich mag die Tage nen ganzen Schwung priv. proxmox Server von 6.4 auf 7 updaten und zwar mit ansible.
Dazu habe ich ein kleines playbook, welches pve6to7 aufruft, die repos umschreibt und dann auch den Updateprozeß begleiten soll.
Aber das Script /usr/share/proxmox-ve/pve-apt-hook verlangt beim Upgrade des Pakets proxmox-ve nach einem Druck auf RETURN oder STRG+C.

Ich könnte die entspr. Zeile in 10pveapthook auskommentieren, oder das Script durch einen dummy ersetzen, oder im Scriptanfang ein exit 0; einfügen usw.
Wie macht ihr das, wie ist u.U. der vorgesehen Weg, wenn man $VIELE Instanzen aktualisieren mag?
 
alternativ apt in ansible so aufrufen dass STDIN auf /dev/null zeigt, das sollte auch funktionieren (habs aber nicht probiert ;))
 
Ich wüßte leider nicht wie das gehen soll. Zur Inspiration mein erster Entwurf:

YAML:
#!/usr/bin/ansible-playbook
---
#  //////////////////////
#  Upgrade pve 6.x to 7.x
#  //////////////////////
#
#                                  ThorstenS 2020-07
####################################################
- hosts: pve

  tasks:
    - name: Only run "update_cache=yes" if the last one is more than 3600 seconds ago
      apt:
          autoclean: yes
          update_cache: yes
          cache_valid_time: 3600                                                                                                                                                                                                                     
    - name: upgrade all packages
      apt:
          name: "*"
          state: latest
          #autoclean: yes
          force_apt_get: yes
      environment:
          - NEEDRESTART_MODE: a
      tags:
          - skip_ansible_lint

    - name: pve6to7 has to be there
      stat:
        path: /usr/bin/pve6to7
      register: pve6to7

    - name: fail when pve6to7 is not present or no regular file
      fail:
        msg: "pve6to7 isn`t here - check updates"
      when: not pve6to7.stat.exists and pve6to7.stat.isreg

    - name: run pve6to7
      command: "/usr/bin/pve6to7"
      register: pve6to7status

    - name: Are you satisfied, is it going on??
      pause:
        prompt: "[STRG+C] vs [RETURN]"
        echo: no

    #- name: check if update cold do…
    #  fail:
    #    msg: "pve6to7 has errors"
    #  when: not pve6to7.stdout is search("FAILURES: 0")

    - name: block files
      block:
      - name: place sources.list
        copy:
          dest: /etc/apt/sources.list
          content: |
            # debian repo
            deb http://ftp.de.debian.org/debian bullseye main contrib

            deb http://ftp.de.debian.org/debian bullseye-updates main contrib

            # security updates not yet available in 2021-07
            #deb http://security.debian.org bullseye-updates main contrib

      - name: place ceph.list
        copy:
          dest: /etc/apt/sources.list.d/ceph.list
          content: |
            # ceph
            deb http://download.proxmox.com/debian/ceph-octopus bullseye main

      - name: place community.list
        copy:
          dest: /etc/apt/sources.list.d/community.list
          content: |
            # pve updates
            deb http://download.proxmox.com/debian/pve bullseye pve-no-subscription

      - name: place pve-enterprise.list
        copy:
          dest: /etc/apt/sources.list.d/pve-enterprise.list
          content: |
            # subscription updates
            # deb https://enterprise.proxmox.com/debian/pve bullseye pve-enterprise

      - name: remove linux-image-amd64
        apt: name=linux-image-amd64 state=absent

      rescue:
        - name: Print when errors
          debug:
            msg: 'something went wrong while creating repos'
 
yeah, seems like the ansible apt module does not allow that.. if you are motivated, feel free to whip up a patch that skips the check based on some condition (e.g., file exists/env variable is set/...) and send it our way :)

https://pve.proxmox.com/wiki/Developer_Documentation
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!