From f7be659561344c2ed97478cee79646ecdd98dd9f Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Sat, 26 Jan 2019 23:49:19 +0000 Subject: [PATCH] Fix `repo.saltstack.com` URLs for Python 3 packages (#364) --- pillar.example | 4 ++++ salt/osfamilymap.yaml | 12 ++++++++---- salt/osmap.yaml | 15 ++++++++------- salt/ospyvermap.yaml | 30 ++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 11 deletions(-) create mode 100644 salt/ospyvermap.yaml diff --git a/pillar.example b/pillar.example index 9ea896f..bd2241a 100644 --- a/pillar.example +++ b/pillar.example @@ -10,6 +10,10 @@ salt: # This state will remove "/etc/salt/master" when you set this to true. master_remove_config: True + # Set this to 'py3' to install the Python 3 packages. + # If this is not set, the Python 2 packages will be installed by default. + py_ver: 'py3' + # Set this to False to not have the formula install packages (in the case you # install Salt via git/pip/etc.) install_packages: True diff --git a/salt/osfamilymap.yaml b/salt/osfamilymap.yaml index 68785ad..d824681 100644 --- a/salt/osfamilymap.yaml +++ b/salt/osfamilymap.yaml @@ -1,6 +1,10 @@ # -*- coding: utf-8 -*- # vim: ft=yaml +{% import_yaml "salt/ospyvermap.yaml" as ospyvermap %} +{% set ospyver = salt['grains.filter_by'](ospyvermap, grain='os_family') or {} %} +{% set py_ver_dir = salt['pillar.filter_by'](ospyver, pillar='salt:py_ver', default='py2') %} + {% set osrelease = salt['grains.get']('osrelease') %} {% set salt_release = salt['pillar.get']('salt:release', 'latest') %} {% if salt_release.split('.')|length >= 3 %} @@ -11,8 +15,8 @@ {% set oscodename = salt['grains.get']('oscodename') %} Debian: - pkgrepo: 'deb http://repo.saltstack.com/apt/{{ os_lower }}/{{ osmajorrelease }}/amd64/{{ salt_release }} {{ oscodename }} main' - key_url: 'https://repo.saltstack.com/apt/{{ os_lower }}/{{ osmajorrelease }}/amd64/{{ salt_release }}/SALTSTACK-GPG-KEY.pub' + pkgrepo: 'deb http://repo.saltstack.com/{{ py_ver_dir }}/{{ os_lower }}/{{ osmajorrelease }}/amd64/{{ salt_release }} {{ oscodename }} main' + key_url: 'https://repo.saltstack.com/{{ py_ver_dir }}/{{ os_lower }}/{{ osmajorrelease }}/amd64/{{ salt_release }}/SALTSTACK-GPG-KEY.pub' libgit2: libgit2-22 pyinotify: python-pyinotify gitfs: @@ -26,8 +30,8 @@ Debian: install_from_source: False RedHat: - pkgrepo: 'https://repo.saltstack.com/yum/redhat/$releasever/$basearch/{{ salt_release }}' - key_url: 'https://repo.saltstack.com/yum/redhat/$releasever/$basearch/{{ salt_release }}/SALTSTACK-GPG-KEY.pub' + pkgrepo: 'https://repo.saltstack.com/{{ py_ver_dir }}/redhat/$releasever/$basearch/{{ salt_release }}' + key_url: 'https://repo.saltstack.com/{{ py_ver_dir }}/redhat/$releasever/$basearch/{{ salt_release }}/SALTSTACK-GPG-KEY.pub' pygit2: python-pygit2 python_git: GitPython gitfs: diff --git a/salt/osmap.yaml b/salt/osmap.yaml index 9b640db..3d88110 100644 --- a/salt/osmap.yaml +++ b/salt/osmap.yaml @@ -1,6 +1,10 @@ # -*- coding: utf-8 -*- # vim: ft=yaml +{% import_yaml "salt/ospyvermap.yaml" as ospyvermap %} +{% set ospyver = salt['grains.filter_by'](ospyvermap, grain='os_family') or {} %} +{% set py_ver_dir = salt['pillar.filter_by'](ospyver, pillar='salt:py_ver', default='py2') %} + {% set osrelease = salt['grains.get']('osrelease') %} {% set salt_release = salt['pillar.get']('salt:release', 'latest') %} {% if salt_release.split('.')|length >= 3 %} @@ -14,8 +18,8 @@ Fedora: pygit2: python2-pygit2 Ubuntu: - pkgrepo: 'deb http://repo.saltstack.com/apt/{{ os_lower }}/{{ osrelease }}/amd64/{{ salt_release }} {{ oscodename }} main' - key_url: 'https://repo.saltstack.com/apt/{{ os_lower }}/{{ osrelease }}/amd64/{{ salt_release }}/SALTSTACK-GPG-KEY.pub' + pkgrepo: 'deb http://repo.saltstack.com/{{ py_ver_dir }}/{{ os_lower }}/{{ osrelease }}/amd64/{{ salt_release }} {{ oscodename }} main' + key_url: 'https://repo.saltstack.com/{{ py_ver_dir }}/{{ os_lower }}/{{ osrelease }}/amd64/{{ salt_release }}/SALTSTACK-GPG-KEY.pub' pygit2: python-pygit2 gitfs: pygit2: @@ -25,8 +29,8 @@ Ubuntu: install_from_package: Null Raspbian: - pkgrepo: 'deb http://repo.saltstack.com/apt/{{ os_lower }}/{{ osmajorrelease }}/armhf/{{ salt_release }} {{ oscodename }} main' - key_url: 'https://repo.saltstack.com/apt/{{ os_lower }}/{{ osmajorrelease }}/armhf/{{ salt_release }}/SALTSTACK-GPG-KEY.pub' + pkgrepo: 'deb http://repo.saltstack.com/{{ py_ver_dir }}/{{ os_lower }}/{{ osmajorrelease }}/armhf/{{ salt_release }} {{ oscodename }} main' + key_url: 'https://repo.saltstack.com/{{ py_ver_dir }}/{{ os_lower }}/{{ osmajorrelease }}/armhf/{{ salt_release }}/SALTSTACK-GPG-KEY.pub' SmartOS: salt_master: salt @@ -45,6 +49,3 @@ SmartOS: config_path: /opt/local/etc/salt master: gitfs_provider: dulwich - - - diff --git a/salt/ospyvermap.yaml b/salt/ospyvermap.yaml new file mode 100644 index 0000000..8e32918 --- /dev/null +++ b/salt/ospyvermap.yaml @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml + +Debian: + py2: 'apt' + py3: 'py3' + +RedHat: + py2: 'yum' + py3: 'py3' + +Suse: {} + +Gentoo: {} + +Arch: {} + +Alpine: {} + +FreeBSD: {} + +OpenBSD: {} + +Windows: + py2: 'Py2' + py3: 'Py3' + +MacOS: + py2: 'py2' + py3: 'py3'