Skip to content

Commit

Permalink
fix(linux): corrected alternatives states
Browse files Browse the repository at this point in the history
  • Loading branch information
noelmcloughlin committed Jul 14, 2020
1 parent 18403a8 commit f96f727
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 36 deletions.
12 changes: 6 additions & 6 deletions kubernetes/client/alternatives/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ include:
alternatives.install:
- unless:
- {{ grains.os_family in ('Suse', 'Arch') }}
- update-alternatives --get-selections |egrep '^link-k8s-client-{{ cmd }}|link-k8s-server-{{ cmd }}'
- update-alternatives --get-selections |grep "^link-k8s-server-{{ cmd }}" # avoid server clash
- unless: {{ grains.os_family in ('Suse', 'Arch') }}
- name: link-k8s-client-{{ cmd }}
- link: /usr/local/bin/{{ cmd }}
Expand All @@ -28,21 +28,21 @@ include:
- sls: {{ sls_archive_install if d.client.pkg.use_upstream == 'archive' else sls_binary_install }}
cmd.run:
- onlyif: {{ grains.os_family in ('Suse',) }}
- name: update-alternatives --install /usr/local/bin/{{ cmd }} link-k8s-client {{ d.client.pkg.path }}/bin/{{ cmd }} {{ d.linux.altpriority }} # noqa 204
- name: update-alternatives --install /usr/local/bin/{{ cmd }} link-k8s-client-{{ cmd }} {{ d.client.pkg.path }}/bin/{{ cmd }} {{ d.linux.altpriority }} # noqa 204
- unless:
- update-alternatives --get-selections |egrep '^link-k8s-client-{{ cmd }}|link-k8s-server-{{ cmd }}'
- update-alternatives --get-selections |grep "^link-k8s-server-{{ cmd }}" # avoid server clash
- require:
- sls: {{ sls_archive_install if d.client.pkg.use_upstream == 'archive' else sls_binary_install }}
{{ formula }}-client-alternatives-set-bin-{{ cmd }}:
alternatives.set:
- unless: {{ grains.os_family in ('Suse', 'Arch') }}
- unless:
- {{ grains.os_family in ('Suse', 'Arch') }}
- update-alternatives --get-selections |grep "^link-k8s-server-{{ cmd }}" # avoid server clash
- name: link-k8s-client-{{ cmd }}
- path: {{ d.client.pkg.path }}/bin/{{ cmd }}
- require:
- alternatives: {{ formula }}-client-alternatives-install-bin-{{ cmd }}
- unless:
- update-alternatives --get-selections |grep '^link-k8s-server-{{ cmd }}'
{%- endfor %}
{%- endif %}
10 changes: 6 additions & 4 deletions kubernetes/node/alternatives/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ include:
alternatives.install:
- unless:
- {{ grains.os_family in ('Suse', 'Arch') }}
- update-alternatives --get-selections |grep ^link-k8s-node-{{ cmd }}
- update-alternatives --get-selections |egrep "^link-k8s-server-{{ cmd }}|link-k8s-client-{{ cmd }}"
- name: link-k8s-node-{{ cmd }}
- link: /usr/local/bin/{{ cmd }}
- path: {{ d.node.pkg.path }}/bin/{{ cmd }}
Expand All @@ -26,15 +26,17 @@ include:
- sls: {{ sls_archive_install }}
cmd.run:
- onlyif: {{ grains.os_family in ('Suse',) }}
- name: update-alternatives --install /usr/local/bin/{{ cmd }} link-k8s-node {{ d.node.pkg.path }}/bin/{{ cmd }} {{ d.linux.altpriority }} # noqa 204
- name: update-alternatives --install /usr/local/bin/{{ cmd }} link-k8s-node-{{ cmd }} {{ d.node.pkg.path }}/bin/{{ cmd }} {{ d.linux.altpriority }} # noqa 204
- unless:
- update-alternatives --get-selections |grep ^link-k8s-node-{{ cmd }}
- update-alternatives --get-selections |egrep "^link-k8s-server-{{ cmd }}|link-k8s-client-{{ cmd }}"
- require:
- sls: {{ sls_archive_install }}
{{ formula }}-node-alternatives-set-{{ cmd }}:
alternatives.set:
- unless: {{ grains.os_family in ('Suse', 'Arch') }}
- unless:
- update-alternatives --get-selections |egrep "^link-k8s-server-{{ cmd }}|link-k8s-client-{{ cmd }}"
- {{ grains.os_family in ('Suse', 'Arch') }}
- name: link-k8s-node-{{ cmd }}
- path: {{ d.node.pkg.path }}/bin/{{ cmd }}
- require:
Expand Down
12 changes: 6 additions & 6 deletions kubernetes/server/alternatives/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ include:
alternatives.install:
- unless:
- {{ grains.os_family in ('Suse', 'Arch') }}
- update-alternatives --get-selections |egrep '^link-k8s-client-{{ cmd }}|link-k8s-server-{{ cmd }}'
- update-alternatives --get-selections |grep "^link-k8s-client-{{ cmd }}" # avoid client clash
- name: link-k8s-server-{{ cmd }}
- link: /usr/local/bin/{{ cmd }}
- path: {{ d.server.pkg.path }}/bin/{{ cmd }}
Expand All @@ -26,21 +26,21 @@ include:
- sls: {{ sls_archive_install }}
cmd.run:
- onlyif: {{ grains.os_family in ('Suse',) }}
- name: update-alternatives --install /usr/local/bin/{{ cmd }} link-k8s-server {{ d.server.pkg.path }}/bin/{{ cmd }} {{ d.linux.altpriority }} # noqa 204
- name: update-alternatives --install /usr/local/bin/{{ cmd }} link-k8s-server-{{ cmd }} {{ d.server.pkg.path }}/bin/{{ cmd }} {{ d.linux.altpriority }} # noqa 204
- unless:
- update-alternatives --get-selections |egrep '^link-k8s-client-{{ cmd }}|link-k8s-server-{{ cmd }}'
- update-alternatives --get-selections |grep "^link-k8s-client-{{ cmd }}" # avoid client clash
- require:
- sls: {{ sls_archive_install }}
{{ formula }}-server-alternatives-set-{{ cmd }}:
alternatives.set:
- unless: {{ grains.os_family in ('Suse', 'Arch') }}
- unless:
- {{ grains.os_family in ('Suse', 'Arch') }}
- update-alternatives --get-selections |grep '^link-k8s-client-{{ cmd }}' # avoid client clash
- name: link-k8s-server-{{ cmd }}
- path: {{ d.server.pkg.path }}/bin/{{ cmd }}
- require:
- alternatives: {{ formula }}-server-alternatives-install-{{ cmd }}
- unless:
- update-alternatives --get-selections |grep '^link-k8s-client-{{ cmd }}'
{%- endfor %}
{%- endif %}
25 changes: 5 additions & 20 deletions test/integration/redhat/controls/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,11 @@
# it { should be_file }
# it { should_not be_directory }
# end
describe file('/usr/local/k8s-istio-1.6.4/bin/istioctl') do
it { should_not be_symlink }
it { should be_file }
it { should_not be_directory }
end
# describe file('/usr/local/k8s-istio-1.6.4/bin/istioctl') do
# it { should_not be_symlink }
# it { should be_file }
# it { should_not be_directory }
# end
describe file('/usr/local/bin/istioctl') do
it { should be_symlink }
it { should be_file }
Expand Down Expand Up @@ -258,21 +258,6 @@
# it { should be_file }
# it { should_not be_directory }
# end
describe file('/usr/local/src/k8s/libs/grafana-operator') do
it { should be_directory }
end
describe file('/usr/local/src/k8s/libs/prometheus-operator') do
it { should be_directory }
end
describe file('/usr/local/src/k8s/libs/akka-cluster-operator') do
it { should be_directory }
end
describe file('/usr/local/src/k8s/libs/istio-operator') do
it { should be_directory }
end
describe file('/usr/local/src/k8s-devlibs/shell-operator') do
it { should be_directory }
end
describe file('/usr/local/k8s-devtools-skaffold-1.12.0//bin/skaffold') do
it { should be_file }
end
Expand Down

0 comments on commit f96f727

Please sign in to comment.