diff --git a/salt/defaults.yaml b/salt/defaults.yaml index 40a8e68..1e345ca 100644 --- a/salt/defaults.yaml +++ b/salt/defaults.yaml @@ -28,6 +28,13 @@ salt: install_from_source: True pygit2: install_from_source: True + version: 0.23.0 + libgit2: + version: 0.23.0 + install_from_source: True + build_parent_dir: /usr/src/ + # hash necessary until github issue #9272 is addressed + download_hash: 683d1164e361e2a0a8d52652840e2340 gitpython: install_from_source: False diff --git a/salt/gitfs/pygit2.sls b/salt/gitfs/pygit2.sls index dd7ec61..1a8341a 100644 --- a/salt/gitfs/pygit2.sls +++ b/salt/gitfs/pygit2.sls @@ -1,9 +1,16 @@ {% from "salt/map.jinja" import salt_settings with context %} +{% set pygit2_settings = salt_settings.gitfs.pygit2 %} git: pkg.installed -{% if salt_settings.gitfs.pygit2.install_from_source %} +{% if pygit2_settings.install_from_source %} +{% set libgit2_settings = pygit2_settings.libgit2 %} + +{% if libgit2_settings.install_from_source %} +{% set libgit2_src_dir = libgit2_settings.build_parent_dir + 'libgit2-' + libgit2_settings.version %} +{% set libgit2_build_dir = libgit2_src_dir + '/_build' %} + # we probably don't have a package or it's not a high enough version # install latest from source/pip pygit-deps: @@ -17,32 +24,32 @@ pygit-deps: dl-libgit2-src: archive.extracted: - - name: /usr/src - - source: https://github.com/libgit2/libgit2/archive/v0.22.1.tar.gz - - source_hash: md5=dbf516d18e176bbb131de3efccfee533 + - name: {{ libgit2_settings.build_parent_dir }} + - source: https://github.com/libgit2/libgit2/archive/v{{ libgit2_settings.version }}.tar.gz + - source_hash: md5={{ libgit2_settings.download_hash }} - archive_format: tar - keep: True - - if_missing: /usr/src/libgit2-0.22.1 + - if_missing: /usr/src/libgit2-{{ libgit2_settings.version }} -/usr/src/libgit2-0.22.1/_build: +{{ libgit2_build_dir }}: file.directory configure-libgit2: cmd.run: - name: cmake .. - - cwd: /usr/src/libgit2-0.22.1/_build - - creates: /usr/src/libgit2-0.22.1/_build/Makefile + - cwd: {{ libgit2_build_dir }} + - creates: {{ libgit2_build_dir }}/Makefile build-libgit2: cmd.run: - name: make -j4 - - cwd: /usr/src/libgit2-0.22.1/_build - - creates: /usr/src/libgit2-0.22.1/_build/libgit2.so + - cwd: {{ libgit2_build_dir }} + - creates: {{ libgit2_build_dir }}/libgit2.so install-libgit2: cmd.run: - name: make install - - cwd: /usr/src/libgit2-0.22.1/_build + - cwd: {{ libgit2_build_dir }} - creates: /usr/local/lib/libgit2.so run-ldconfig-after-lib-install: @@ -51,9 +58,15 @@ run-ldconfig-after-lib-install: - onchanges: - cmd: install-libgit2 +{% else %} +{{ salt_settings.libgit2 }}: + pkg.installed + +{% endif %} + install-pygit2: pip.installed: - - name: pygit2 + - name: pygit2 == {{ pygit2_settings.version }} {% else %} {{ salt_settings.pygit2 }}: diff --git a/salt/map.jinja b/salt/map.jinja index 6126b3e..027e9ee 100644 --- a/salt/map.jinja +++ b/salt/map.jinja @@ -9,22 +9,29 @@ Setup variable using grains['os_family'] based logic, only add key:values here that differ from whats in defaults.yaml ##} {% set os_family_map = salt['grains.filter_by']({ - 'Debian': {}, - 'Ubuntu': {}, - 'CentOS': {}, - 'Amazon': {}, - 'Fedora': {}, + 'Debian': { + 'libgit2': 'libgit2-22', + 'gitfs': { + 'pygit2': { + 'install_from_source': True, + 'version': '0.22.1', + 'libgit2': { + 'install_from_source': False, + }, + }, + }, + }, 'RedHat': { 'pygit2': 'python-pygit2', 'gitfs': { 'pygit2': { - 'install_from_source': False + 'install_from_source': False, }, }, 'master': { 'gitfs_provider': 'pygit2' }, - 'repotype': 'epel' + 'repotype': 'epel', }, 'Suse': {}, 'Gentoo': { @@ -32,7 +39,7 @@ that differ from whats in defaults.yaml 'salt_minion': 'app-admin/salt', 'salt_syndic': 'app-admin/salt', 'salt_api': 'app-admin/salt', - 'salt_cloud': 'app-admin/salt' + 'salt_cloud': 'app-admin/salt', }, 'Arch': { 'salt_master': 'salt-zmq', @@ -40,7 +47,7 @@ that differ from whats in defaults.yaml 'salt_syndic': 'salt-zmq', 'salt_cloud': 'salt-zmq', 'salt_api': 'salt-zmq', - 'salt_ssh': 'salt-zmq' + 'salt_ssh': 'salt-zmq', }, 'FreeBSD': { 'salt_master': 'py27-salt', @@ -55,20 +62,17 @@ that differ from whats in defaults.yaml 'minion_service': 'salt_minion', 'master_service': 'salt_master', 'api_service': 'salt_api', - 'syndic_service': 'salt_syndic' + 'syndic_service': 'salt_syndic', }, - } - , grain="os_family" - , merge=salt['pillar.get']('salt:lookup')) + }, grain="os_family", merge=salt['pillar.get']('salt:lookup')) %} {## Merge the flavor_map to the default settings ##} {% do default_settings.salt.update(os_family_map) %} - + {## Merge in salt:lookup pillar ##} {% set salt_settings = salt['pillar.get']( 'salt', default=default_settings.salt, - merge=True - ) + merge=True) %}