Skip to content

Commit

Permalink
feat(win): do not apply user/group to windows filesystem
Browse files Browse the repository at this point in the history
  • Loading branch information
noelmcloughlin committed Oct 10, 2020
1 parent e08e8eb commit 4be7c26
Show file tree
Hide file tree
Showing 21 changed files with 140 additions and 78 deletions.
4 changes: 3 additions & 1 deletion kubernetes/client/aliases/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ include:
)
}}
- mode: '0640'
- makedirs: True
{%- if grains.os != 'Windows' %}
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
- makedirs: True
{%- endif %}
- template: jinja
- require:
- sls: {{ sls_archive_install if d.client.pkg.use_upstream == 'archive' else sls_binary_install if d.client.pkg.use_upstream == 'binary' else sls_package_install }} # noqa 204
2 changes: 1 addition & 1 deletion kubernetes/client/archive/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ include:
- names:
- {{ d.dir.tmp }}/client*
- {{ d.client.pkg.path }}/bin
{%- if d.linux.altpriority|int == 0 or grains.os_family in ('Arch', 'MacOS') %}
{%- if (d.linux.altpriority|int == 0 and grains.os != 'Windows') or grains.os_family in ('Arch', 'MacOS') %}
{%- for cmd in d.client.pkg.commands|unique %}
- /usr/local/bin/{{ cmd }}
{%- endfor %}
Expand Down
18 changes: 12 additions & 6 deletions kubernetes/client/archive/install.sls
Original file line number Diff line number Diff line change
@@ -1,45 +1,51 @@
# -*- coding: utf-8 -*-
# vim: ft=sls

{%- if grains.kernel|lower in ('linux', 'darwin') %}
{%- if grains.kernel|lower in ('linux', 'darwin', 'windows') %}
{%- set tplroot = tpldir.split('/')[0] %}
{%- from tplroot ~ "/map.jinja" import data as d with context %}
{%- set formula = d.formula %}
{%- from tplroot ~ "/files/macros.jinja" import format_kwargs with context %}
{%- if d.client.pkg.use_upstream == 'archive' and 'pkg' in d.client and 'archive' in d.client['pkg'] %}
{{ formula }}-client-archive-install:
{%- if grains.os != 'Windows' %}
pkg.installed:
- names: {{ d.pkg.deps|json }}
- require_in:
- file: {{ formula }}-client-archive-install
{%- endif %}
file.directory:
- name: {{ d.client.pkg.path }}
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
- mode: 755
- makedirs: True
- clean: True
- require_in:
- archive: {{ formula }}-client-archive-install
{%- if grains.os != 'Windows' %}
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
- recurse:
- user
- group
- mode
{%- endif %}
archive.extracted:
{{- format_kwargs(d.client['pkg']['archive']) }}
- retry: {{ d.retry_option|json }}
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
- enforce_toplevel: false
- trim_output: true
{%- if grains.os != 'Windows' %}
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
- recurse:
- user
- group
{%- endif %}
- require:
- file: {{ formula }}-client-archive-install
{%- if d.linux.altpriority|int == 0 or grains.os_family in ('Arch', 'MacOS') %}
{%- if (d.linux.altpriority|int == 0 and grains.os != 'Windows') or grains.os_family in ('Arch', 'MacOS') %}
{%- for cmd in d.client.pkg.commands|unique %}
{{ formula }}-client-archive-install-symlink-{{ cmd }}:
Expand Down
10 changes: 5 additions & 5 deletions kubernetes/client/binary/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{%- from tplroot ~ "/map.jinja" import data as d with context %}
{%- set formula = d.formula %}
{%- if d.client.pkg.use_upstream == 'binary' %}
{%- if d.client.pkg.use_upstream == 'binary' and grains.os != 'Windows' %}
{{ formula }}-client-binary-install:
pkg.installed:
Expand All @@ -14,12 +14,12 @@
- file: {{ formula }}-client-binary-install
file.directory:
- name: {{ d.client.pkg.path }}/bin
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
- mode: 755
- makedirs: True
- require_in:
- cmd: {{ formula }}-client-binary-install
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
- recurse:
- user
- group
Expand All @@ -31,14 +31,14 @@
- retry: {{ d.retry_option|json }}
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
{%- if 'source_hash' in d.client.pkg.binary and d.client.pkg.binary.source_hash %}
{%- if 'source_hash' in d.client.pkg.binary and d.client.pkg.binary.source_hash %}
module.run:
- name: file.check_hash
- path: {{ d.client.pkg.path }}/bin/kubectl
- file_hash: {{ d.client.pkg.binary.source_hash }}
- require:
- cmd: {{ formula }}-client-binary-install
{%- endif %}
{%- endif %}
{{ formula }}-client-binary-install-symlink:
file.symlink:
Expand Down
15 changes: 10 additions & 5 deletions kubernetes/devlibs/archive/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,33 @@
{{ formula }}-devlibs-archive-{{ tool }}-install:
file.directory:
- name: {{ p['path'] }}/
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
- name: {{ p['path'] }}
- mode: 755
- clean: True
- makedirs: True
- require_in:
- archive: {{ formula }}-devlibs-archive-{{ tool }}-install
{%- if grains.os != 'Windows' %}
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
- recurse:
- user
- group
- mode
{%- endif %}
archive.extracted:
{{- format_kwargs(p['archive']) }}
- retry: {{ d.retry_option }}
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
- enforce_toplevel: false
- trim_output: true
{%- if grains.os != 'Windows' %}
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
- recurse:
- user
- group
- mode
{%- endif %}
{% endif %}
{% endif %}
Expand Down
24 changes: 14 additions & 10 deletions kubernetes/devtools/archive/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,34 @@
{{ formula }}-devtools-archive-{{ tool }}-install:
file.directory:
- name: {{ d.devtools['pkg'][tool]['path'] }}/
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
- name: {{ d.devtools['pkg'][tool]['path'] }}
- mode: 755
- clean: True
- makedirs: True
- require_in:
- archive: {{ formula }}-devtools-archive-{{ tool }}-install
{%- if grains.os != 'Windows' %}
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
- recurse:
- user
- group
- mode
{%- endif %}
archive.extracted:
{{- format_kwargs(d.devtools['pkg'][tool]['archive']) }}
- retry: {{ d.retry_option }}
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
- enforce_toplevel: false
- trim_output: true
{%- if grains.os != 'Windows' %}
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
- recurse:
- user
- group
{%- if d.linux.altpriority|int == 0 or grains.os_family in ('Arch', 'MacOS') %}
{%- for cmd in d.devtools['pkg'][tool]['commands']|unique %}
{%- endif %}
{%- if (d.linux.altpriority|int == 0 and grains.os != 'Windows') or grains.os_family in ('Arch', 'MacOS') %}
{%- for cmd in d.devtools['pkg'][tool]['commands']|unique %}
{{ formula }}-devtools-archive-{{ tool }}-install-symlink-{{ cmd }}:
file.symlink:
Expand All @@ -48,10 +52,10 @@
- require:
- archive: {{ formula }}-devtools-archive-{{ tool }}-install
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{%- endfor %}
{%- endif %}
10 changes: 7 additions & 3 deletions kubernetes/devtools/binary/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,27 @@
{{ formula }}-devtools-binary-{{ tool }}-install:
file.directory:
- name: {{ p[tool]['path'] }}/bin
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
- mode: 755
- makedirs: True
- require_in:
- cmd: {{ formula }}-devtools-binary-{{ tool }}-install
{%- if grains.os != 'Windows' %}
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
- recurse:
- user
- group
- mode
{%- endif %}
cmd.run:
- names:
- curl -Lo {{ p[tool]['path'] }}/bin/{{ tool }} {{ p[tool]['binary']['source'] }}
- chmod '0755' {{ p[tool]['path'] }}/bin/{{ tool }} 2>/dev/null
- retry: {{ d.retry_option|json }}
{%- if grains.os != 'Windows' %}
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
{%- endif %}
{%- if 'source_hash' in p[tool]['binary'] and p[tool]['binary']['source_hash'] %}
module.run:
- name: file.check_hash
Expand All @@ -40,7 +44,7 @@
- cmd: {{ formula }}-devtools-binary-{{ tool }}-install
{%- endif %}
{%- if d.linux.altpriority|int == 0 or grains.os_family in ('Arch', 'MacOS') %}
{%- if (d.linux.altpriority|int == 0 and grain.os != 'Windows') or grains.os_family in ('Arch', 'MacOS') %}
{%- for cmd in p[tool]['commands']|unique %}
{{ formula }}-devtools-binary-{{ tool }}-install-symlink-{{ cmd }}:
file.symlink:
Expand Down
13 changes: 9 additions & 4 deletions kubernetes/k3s/binary/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
- names: {{ d.pkg.deps|json }}
file.directory:
- name: {{ d.k3s.pkg.path }}/bin
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
- mode: 755
- makedirs: True
{%- if grains.os != 'Windows' %}
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
- recurse:
- user
- group
- mode
{%- endif %}
- require:
- pkg: {{ formula }}-k3s-binary-prerequisites
Expand All @@ -28,15 +30,18 @@
- name: {{ d.k3s.pkg.path }}/bin/k3s
- source: {{ d.k3s.pkg.binary.source }}
- source_hash: {{ d.k3s.pkg.binary.source_hash }}
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
- mode: 755
- retry: {{ d.retry_option|json }}
- require:
- file: {{ formula }}-k3s-binary-prerequisites
{%- if grains.os != 'Windows' %}
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
{%- endif %}
{{ formula }}-k3s-binary-install-symlink:
file.symlink:
- unless: {{ grains.os == 'Windows' }}
- name: /usr/local/bin/k3s
- target: {{ d.k3s.pkg.path }}/bin/k3s
- force: True
Expand Down
6 changes: 4 additions & 2 deletions kubernetes/k3s/config/file.sls
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ include:
)
}}
- mode: 644
- makedirs: True
{%- if grains.os != 'Windows' %}
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
- makedirs: True
{%- endif %}
- template: jinja
- context:
config: {{ d.k3s.config|json }}
config: {{ d.k3s.config|json }}
- require:
- sls: {{ sls_archive_install if d.k3s.pkg.use_upstream == 'archive' else sls_binary_install if d.k3s.pkg.use_upstream == 'binary' else sls_package_install }} # noqa 204
Expand Down
15 changes: 9 additions & 6 deletions kubernetes/k3s/script/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,28 @@
- file: {{ formula }}-k3s-script-install-prerequisites
{%- endif %}
file.directory:
- names:
- {{ d.dir.tmp }}
- user: root
- group: {{ d.identity.rootgroup }}
- name: {{ d.dir.tmp }}
- mode: '0755'
- makedirs: True
- require:
- pkg: {{ formula }}-k3s-script-install-prerequisites
{%- if grains.os != 'Windows' %}
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
{%- endif %}
{{ formula }}-k3s-script-download:
file.managed:
- name: {{ d.dir.tmp }}/k3s-bootstrap.sh
- source: {{ d.k3s.pkg.script.source }}
- source_hash: {{ d.k3s.pkg.script.source_hash }}
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
- mode: 755
- require:
- file: {{ formula }}-k3s-script-install-prerequisites
{%- if grains.os != 'Windows' %}
- user: {{ d.identity.rootuser }}
- group: {{ d.identity.rootgroup }}
{%- endif %}
{{ formula }}-k3s-script-download-clean:
file.absent:
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/node/archive/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ include:
- names:
- {{ d.dir.tmp }}/kubernetes-node*
- {{ d.node.pkg.path }}/bin
{%- if d.linux.altpriority|int == 0 or grains.os_family in ('Arch', 'MacOS') %}
{%- if (d.linux.altpriority|int == 0 and grain.os != 'Windows') or grains.os_family in ('Arch', 'MacOS') %}
{%- for cmd in d.node.pkg.commands|unique %}
- /usr/local/bin/{{ cmd }}
{%- endfor %}
Expand Down
Loading

0 comments on commit 4be7c26

Please sign in to comment.