-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(alternatives): add linux alternatives support
- Loading branch information
1 parent
e7a1523
commit 0b05c5d
Showing
10 changed files
with
162 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=sls | ||
|
||
{#- Get the `tplroot` from `tpldir` #} | ||
{%- set tplroot = tpldir.split('/')[0] %} | ||
{%- from tplroot ~ "/map.jinja" import grafana with context %} | ||
{%- set sls_archive_clean = tplroot ~ '.archive.clean' %} | ||
{%- set sls_package_clean = tplroot ~ '.package.clean' %} | ||
{%- if grains.kernel|lower == 'linux' and grafana.linux.altpriority|int > 0 %} | ||
include: | ||
- {{ sls_archive_clean if grafana.pkg.use_upstream_archive else sls_package_clean }} | ||
grafana-package-archive-remove-home-alternative-remove: | ||
alternatives.remove: | ||
- name: grafana-home | ||
- path: {{ grafana.base_dir }} | ||
- onlyif: update-alternatives --get-selections |grep ^grafana-home | ||
- require: | ||
- sls: {{ sls_archive_clean if grafana.pkg.use_upstream_archive else sls_package_clean }} | ||
{% for i in ['grafana',] %} | ||
grafana-package-archive-remove-{{ i }}-alternative-remove: | ||
alternatives.remove: | ||
- name: link-{{ i }} | ||
- path: {{ grafana.base_dir }}/{{ i }} | ||
- onlyif: update-alternatives --get-selections |grep ^link-{{ i }} | ||
- require: | ||
- sls: {{ sls_archive_clean if grafana.pkg.use_upstream_archive else sls_package_clean }} | ||
{% endfor %} | ||
{%- endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=sls | ||
|
||
include: | ||
- .install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=sls | ||
|
||
{#- Get the `tplroot` from `tpldir` #} | ||
{%- set tplroot = tpldir.split('/')[0] %} | ||
{%- from tplroot ~ "/map.jinja" import grafana with context %} | ||
{%- set sls_archive_install = tplroot ~ '.archive.install' %} | ||
{%- set sls_package_install = tplroot ~ '.package.clean' %} | ||
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} | ||
{%- if grains.kernel|lower == 'linux' and grafana.linux.altpriority|int > 0 %} | ||
include: | ||
- {{ sls_archive_install if grafana.pkg.use_upstream_archive else sls_package_install }} | ||
grafana-package-archive-install-home-alternative-install: | ||
cmd.run: | ||
- name: update-alternatives --install {{ grafana.dir }} grafana-home {{ grafana.base_dir }} {{grafana.linux.altpriority}} | ||
- watch: | ||
- archive: grafana-package-archive-install-archive-extracted | ||
- require: | ||
- {{ sls_archive_install if grafana.pkg.use_upstream_archive else sls_package_install }} | ||
- onlyif: {{ grains.os_family in ('Suse',) }} | ||
alternatives.install: | ||
- name: grafana-home | ||
- link: {{ grafana.dir }} | ||
- path: {{ grafana.base_dir }} | ||
- priority: {{ grafana.linux.altpriority }} | ||
- order: 10 | ||
- watch: | ||
- archive: grafana-package-archive-install-archive-extracted | ||
- unless: {{ grains.os_family in ('Suse',) }} | ||
- require: | ||
- {{ sls_archive_install if grafana.pkg.use_upstream_archive else sls_package_install }} | ||
grafana-package-archive-install-home-alternative-set: | ||
alternatives.set: | ||
- name: grafana-home | ||
- path: {{ grafana.base_dir }} | ||
- require: | ||
- alternatives: grafana-package-archive-install-home-alternative-install | ||
- unless: {{ grains.os_family in ('Suse',) }} | ||
{% for i in ['grafana',] %} | ||
grafana-package-archive-install-{{ i }}-alternative-install: | ||
cmd.run: | ||
- name: update-alternatives --install /usr/bin/{{i}} link-{{i}} {{ grafana.base_dir }}/{{i}} {{grafana.linux.altpriority}} | ||
- require: | ||
- cmd: grafana-package-archive-install-home-alternative-install | ||
- onlyif: {{ grains.os_family in ('Suse',) }} | ||
alternatives.install: | ||
- name: link-{{ i }} | ||
- link: /usr/bin/{{ i }} | ||
- path: {{ grafana.base_dir }}/{{ i }} | ||
- priority: {{ grafana.linux.altpriority }} | ||
- order: 10 | ||
- require: | ||
- alternatives: grafana-package-archive-install-home-alternative-install | ||
- unless: {{ grains.os_family in ('Suse',) }} | ||
grafana-package-archive-install-{{ i }}-alternative-set: | ||
alternatives.set: | ||
- name: link-{{ i }} | ||
- path: {{ grafana.base_dir }}/{{ i }} | ||
- require: | ||
- alternatives: grafana-package-archive-install-{{ i }}-alternative-install | ||
- unless: {{ grains.os_family in ('Suse',) }} | ||
{% endfor %} | ||
{%- endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
include: | ||
- .file | ||
- .environ | ||
- .alternatives |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters