From 17eac6723b32c5980410f46294dcaa3018ddfdd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Jonas=20S=C3=A4mann?= Date: Sat, 5 Jan 2019 22:52:41 +0100 Subject: [PATCH] Added conditional repo config to pve-subscribe This commit introduces a new inventory host variable: pve_enterprise=False If set to True, apt sources and environment on the target is configured for subscribed operation. If set to False annoying "subscribe me" popups are disabled and apt sources are configured to the no-subscription repositorys. The default value is False. Proxmox's default state after installation is similar to pve_enterprise=True. This Role must be called before first apt call. --- roles/pve-subscribe/files/pve-enterprise.list | 1 + .../files/pve-no-subscription.list | 1 + roles/pve-subscribe/tasks/enterprise.yml | 17 +++++++++++++++++ roles/pve-subscribe/tasks/main.yml | 13 ++++++------- roles/pve-subscribe/tasks/no-subscription.yml | 16 ++++++++++++++++ site.yml | 2 +- 6 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 roles/pve-subscribe/files/pve-enterprise.list create mode 100644 roles/pve-subscribe/files/pve-no-subscription.list create mode 100644 roles/pve-subscribe/tasks/enterprise.yml create mode 100644 roles/pve-subscribe/tasks/no-subscription.yml diff --git a/roles/pve-subscribe/files/pve-enterprise.list b/roles/pve-subscribe/files/pve-enterprise.list new file mode 100644 index 0000000..27c0fbc --- /dev/null +++ b/roles/pve-subscribe/files/pve-enterprise.list @@ -0,0 +1 @@ +deb https://enterprise.proxmox.com/debian/pve stretch pve-enterprise diff --git a/roles/pve-subscribe/files/pve-no-subscription.list b/roles/pve-subscribe/files/pve-no-subscription.list new file mode 100644 index 0000000..5c1ddaa --- /dev/null +++ b/roles/pve-subscribe/files/pve-no-subscription.list @@ -0,0 +1 @@ +deb http://download.proxmox.com/debian stretch pve-no-subscription diff --git a/roles/pve-subscribe/tasks/enterprise.yml b/roles/pve-subscribe/tasks/enterprise.yml new file mode 100644 index 0000000..0c593f1 --- /dev/null +++ b/roles/pve-subscribe/tasks/enterprise.yml @@ -0,0 +1,17 @@ +--- + +- name: Unset no-subscription repo + file: path=/etc/apt/sources.list.d/pve-no-subscription.list state=absent + +- name: Configuring enterprise repo + copy: src=pve-enterprise.list dest=/etc/apt/sources.list.d/pve-enterprise.list + +- name: Removing previously installed pve-subscribe hook for cron + cron: name=pve-subscribe special_time=reboot job=/etc/cron.d/pve-subscribe state=absent + +- name: Removing previously installed pve-subscribe hook for apt + file: path=/etc/apt/apt.conf.d/99pve-subscribe state=absent + +- name: Removing previously installed pve-subscribe script + file: path=/usr/local/bin/pve-subscribe state=absent + diff --git a/roles/pve-subscribe/tasks/main.yml b/roles/pve-subscribe/tasks/main.yml index babad5b..9f1452f 100644 --- a/roles/pve-subscribe/tasks/main.yml +++ b/roles/pve-subscribe/tasks/main.yml @@ -1,10 +1,9 @@ --- -- name: Installing pve-subscribe script - copy: src=pve-subscribe dest=/usr/local/bin/pve-subscribe mode=0755 owner=root +- name: Configuring pve for unsubscribed operation + import_tasks: no-subscription.yml + when: pve_enterprise | default(False) != True -- name: Configuring cron to run pve-subscribe hook after reboot - cron: name=pve-subscribe special_time=reboot job=/etc/cron.d/pve-subscribe - -- name: Configuring apt to run pve-subscribe hook - copy: src=apt-pve-subscribe dest=/etc/apt/apt.conf.d/99pve-subscribe mode=0644 +- name: Configuring pve for licensed operation + import_tasks: enterprise.yml + when: pve_enterprise | default(False) == True diff --git a/roles/pve-subscribe/tasks/no-subscription.yml b/roles/pve-subscribe/tasks/no-subscription.yml new file mode 100644 index 0000000..98f7613 --- /dev/null +++ b/roles/pve-subscribe/tasks/no-subscription.yml @@ -0,0 +1,16 @@ +--- + +- name: Unset enterprise repo + file: path=/etc/apt/sources.list.d/pve-enterprise.list state=absent + +- name: Configuring no-subscription repo + copy: src=pve-no-subscription.list dest=/etc/apt/sources.list.d/pve-no-subscription.list + +- name: Installing pve-subscribe script + copy: src=pve-subscribe dest=/usr/local/bin/pve-subscribe mode=0755 owner=root + +- name: Configuring cron to run pve-subscribe hook after reboot + cron: name=pve-subscribe special_time=reboot job=/etc/cron.d/pve-subscribe + +- name: Configuring apt to run pve-subscribe hook + copy: src=apt-pve-subscribe dest=/etc/apt/apt.conf.d/99pve-subscribe mode=0644 diff --git a/site.yml b/site.yml index 261b373..f6f0f0a 100644 --- a/site.yml +++ b/site.yml @@ -3,5 +3,5 @@ - name: Setup VM hosts hosts: all roles: - - vmhost - pve-subscribe + - vmhost