From 27b7829031f9415f29089138b384fb1d9fe9f2c7 Mon Sep 17 00:00:00 2001 From: Laurent Hoss Date: Thu, 8 Feb 2018 19:53:26 +0100 Subject: [PATCH] Enable apt pinning (#81) * Enable APT pinning * Allow overriding a different upstream server for packages * Preserve compatibility with people still using 'mesos=' in the variables * Update EPEL URLs with default unversioned package * Update for Ansible syntax change --- README.md | 5 +++-- defaults/main.yml | 11 +++++++---- tasks/Debian.yml | 6 ++++++ templates/mesos.pref.j2 | 3 +++ vars/RedHat.yml | 5 ----- 5 files changed, 19 insertions(+), 11 deletions(-) create mode 100644 templates/mesos.pref.j2 diff --git a/README.md b/README.md index 52ef646..628eacf 100644 --- a/README.md +++ b/README.md @@ -37,10 +37,11 @@ mesos_version: "1.0.1" # Debian mesos_package_version: "2.0.93" -mesosphere_apt_url: "http://repos.mesosphere.com/{{ ansible_distribution | lower }}" mesos_os_distribution: "{{ ansible_distribution | lower }}" mesos_os_version: "{{ ansible_distribution_version.split('.') | join('') }}" -mesos_apt_package: "mesos={{ mesos_version }}-{{ mesos_package_version }}.{{ mesos_os_distribution }}{{ mesos_os_version }}" +mesos_apt_url: "http://{{ mesos_repo_host }}/{{ ansible_distribution | lower }}" +mesos_package_full_version: "{{ mesos_version }}-{{ mesos_package_version }}.{{ mesos_os_distribution }}{{ mesos_os_version }}" +mesos_apt_package: "mesos={{ mesos_package_full_version }}" # RedHat: EPEL and Mesosphere yum repositories URL epel_repo: "https://dl.fedoraproject.org/pub/epel/{{ os_version_major }}/{{ ansible_architecture }}/{{ epel_releases[os_version_major] }}" diff --git a/defaults/main.yml b/defaults/main.yml index 8eecd86..2533668 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -2,16 +2,19 @@ mesos_install_mode: "master" # {master|slave|master-slave} mesos_version: "1.1.0" +mesos_repo_host: repos.mesosphere.com + # Debian mesos_package_version: "2.0.107" -mesosphere_apt_url: "http://repos.mesosphere.com/{{ ansible_distribution | lower }}" mesos_os_distribution: "{{ ansible_distribution | lower }}" mesos_os_version: "{{ ansible_distribution_version.split('.') | join('') }}" -mesos_apt_package: "mesos={{ mesos_version }}-{{ mesos_package_version }}.{{ mesos_os_distribution }}{{ mesos_os_version }}" +mesos_package_full_version: "{{ mesos_version }}-{{ mesos_package_version }}.{{ mesos_os_distribution }}{{ mesos_os_version }}" +mesosphere_apt_url: "http://{{ mesos_repo_host }}/{{ ansible_distribution | lower }}" +mesos_apt_package: "mesos={{ mesos_package_full_version }}" # RedHat: EPEL and Mesosphere yum repositories URL -epel_repo: "https://dl.fedoraproject.org/pub/epel/{{ os_version_major }}/{{ ansible_architecture }}/{{ epel_releases[os_version_major] }}" -mesosphere_yum_repo: "https://repos.mesosphere.com/el/{{ os_version_major }}/noarch/RPMS/{{ mesosphere_releases[os_version_major] }}" +epel_repo: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ os_version_major }}.noarch.rpm" +mesosphere_yum_repo: "https://{{ mesos_repo_host }}/el/{{ os_version_major }}/noarch/RPMS/{{ mesosphere_releases[os_version_major] }}" # conf file settings mesos_cluster_name: "mesos_cluster" diff --git a/tasks/Debian.yml b/tasks/Debian.yml index 569445b..60e0b20 100644 --- a/tasks/Debian.yml +++ b/tasks/Debian.yml @@ -5,6 +5,12 @@ - name: Add mesosphere repo apt_repository: repo='deb {{ mesosphere_apt_url }} {{ ansible_distribution_release | lower }} main' state=present update_cache=yes +- name: Pin Mesos version + template: + src: mesos.pref.j2 + dest: /etc/apt/preferences.d/mesos.pref + when: mesos_apt_pin_priority is defined + - name: Install Debian OS packages apt: pkg={{ item }} state=present update_cache=yes cache_valid_time=3600 with_items: diff --git a/templates/mesos.pref.j2 b/templates/mesos.pref.j2 new file mode 100644 index 0000000..fe03412 --- /dev/null +++ b/templates/mesos.pref.j2 @@ -0,0 +1,3 @@ +Package: mesos +Pin: version {{ mesos_package_full_version }} +Pin-Priority: {{ mesos_apt_pin_priority }} diff --git a/vars/RedHat.yml b/vars/RedHat.yml index f5985ac..1d3d3c0 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -1,10 +1,5 @@ os_version_major: "{{ ansible_distribution_major_version }}" -# EPEL repository released packaged per OS version -epel_releases: - '6': 'epel-release-6-8.noarch.rpm' - '7': 'e/epel-release-7-10.noarch.rpm' - # Mesosphere released packaged per OS version mesosphere_releases: '6': 'mesosphere-el-repo-6-3.noarch.rpm'