From a36f2eb2d2ab4e3d57885177f3438037b15318e3 Mon Sep 17 00:00:00 2001 From: noelmcloughlin Date: Fri, 11 Sep 2020 20:53:00 +0100 Subject: [PATCH 1/5] fix(windows): dont run master state --- salt/init.sls | 2 +- salt/master.sls | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/salt/init.sls b/salt/init.sls index e0eecb1..bc1a5d6 100755 --- a/salt/init.sls +++ b/salt/init.sls @@ -6,7 +6,7 @@ include: {%- if salt.config.get('salt_formulas:list') %} - salt.formulas {%- endif %} - {%- if salt.config.get('salt:master')|length > 1 %} + {%- if salt.config.get('salt:master')|length > 1 and grains.kernel != 'Windows' %} - salt.master {%- endif %} {%- if salt.config.get('salt:cloud')|length > 1 %} diff --git a/salt/master.sls b/salt/master.sls index 10d5bb3..3a6835d 100644 --- a/salt/master.sls +++ b/salt/master.sls @@ -7,6 +7,8 @@ include: - .pin {% endif %} +{%- if grains.kernel != 'Windows' %} + {%- if grains.os == 'MacOS' %} salt-master-macos: file.managed: @@ -75,3 +77,12 @@ remove-default-master-conf-file: remove-old-master-conf-file: file.absent: - name: {{ salt_settings.config_path }}/master.d/_defaults.conf + +{%- else %} + +salt-master-install-skip: + test.show_notification: + - text: | + No salt-master state for Windows + +{%- endif %} From 0c591bba95cebd341e73cdd0fc986428ee34ce7e Mon Sep 17 00:00:00 2001 From: noelmcloughlin Date: Fri, 11 Sep 2020 22:03:25 +0100 Subject: [PATCH 2/5] fix(windows): git.latest(parallel:true) does not work --- salt/defaults.yaml | 1 + salt/formulas.sls | 4 ++-- salt/osmap.yaml | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/salt/defaults.yaml b/salt/defaults.yaml index 3e743e4..b35c418 100644 --- a/salt/defaults.yaml +++ b/salt/defaults.yaml @@ -11,6 +11,7 @@ salt: use_pip: false clean_config_d_dir: true restart_via_at: false + parallel: true # salt.git module argument config_path: /etc/salt diff --git a/salt/formulas.sls b/salt/formulas.sls index 7731d14..c8a75f3 100644 --- a/salt/formulas.sls +++ b/salt/formulas.sls @@ -34,7 +34,7 @@ {%- do processed_basedirs.append(basedir) %} {{ basedir }}: file.directory: - - parallel: {{ grains['saltversioninfo'] >= [2017, 7, 0] }} + - parallel: {{ salt_settings.parallel }} {%- for key, value in salt['pillar.get']('salt_formulas:basedir_opts', {'makedirs': True}).items() %} - {{ key }}: {{ value }} @@ -54,7 +54,7 @@ {{ gitdir_env }}: git.latest: - name: {{ baseurl }}/{{ f_name }}.git - - parallel: {{ grains['saltversioninfo'] >= [2017, 7, 0] }} + - parallel: {{ salt_settings.parallel }} - target: {{ gitdir }} {%- for key, value in options.items() %} - {{ key }}: {{ value }} diff --git a/salt/osmap.yaml b/salt/osmap.yaml index 2224a23..bd8ba2c 100644 --- a/salt/osmap.yaml +++ b/salt/osmap.yaml @@ -61,3 +61,6 @@ MacOS: master_service: com.saltstack.salt.master salt_master_macos_plist_hash: 8435331b2d48ca8f0759f216e5b15ec9171a4216b1441328c732c6906728b7c9 salt_minion_macos_plist_hash: 26b33da12e0d8960ee96b488c8352002c22a377c19bf3df3f986a1e49eca8b20 + +Windows: + parallel: false # not supported on windows/cygwin From 887d1559b5496dd07e730390f4309568d0428c2f Mon Sep 17 00:00:00 2001 From: noelmcloughlin Date: Fri, 11 Sep 2020 22:12:07 +0100 Subject: [PATCH 3/5] fix(windows): group name is users not root --- salt/osmap.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/salt/osmap.yaml b/salt/osmap.yaml index bd8ba2c..383355d 100644 --- a/salt/osmap.yaml +++ b/salt/osmap.yaml @@ -63,4 +63,5 @@ MacOS: salt_minion_macos_plist_hash: 26b33da12e0d8960ee96b488c8352002c22a377c19bf3df3f986a1e49eca8b20 Windows: + rootgroup: Users parallel: false # not supported on windows/cygwin From d61e671fa0de58fe60c5c0cdc23d55c49b93dd01 Mon Sep 17 00:00:00 2001 From: noelmcloughlin Date: Fri, 11 Sep 2020 22:28:29 +0100 Subject: [PATCH 4/5] fix(windows): group arg not supported on windows --- salt/formulas.sls | 2 ++ salt/osfamilymap.yaml | 14 +++++++++----- salt/osmap.yaml | 1 - 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/salt/formulas.sls b/salt/formulas.sls index c8a75f3..c20e1b4 100644 --- a/salt/formulas.sls +++ b/salt/formulas.sls @@ -39,7 +39,9 @@ {'makedirs': True}).items() %} - {{ key }}: {{ value }} - user: {{ salt_settings.rootuser }} + {%- if grains.kernel != 'Windows' %} - group: {{ salt_settings.rootgroup }} + {%- endif %} {%- endfor %} {%- endif %} diff --git a/salt/osfamilymap.yaml b/salt/osfamilymap.yaml index 1a530d8..5dc1a9f 100644 --- a/salt/osfamilymap.yaml +++ b/salt/osfamilymap.yaml @@ -15,11 +15,14 @@ {%- set suse_testing_repo = ':/products:/next:/testing' if [osfamily_lower, osrelease] == ['suse', '15.2'] else '' %} #from template-formula -{%- if grains.os == 'MacOS' %} -{%- set macos_rootuser = salt['cmd.run']("stat -f '%Su' /dev/console") %} -{%- set macos_rootgroup = salt['cmd.run']("stat -f '%Sg' /dev/console") %} +{%- if grains.os_family == 'MacOS' %} +{%- set rootuser = salt['cmd.run']("stat -f '%Su' /dev/console") %} +{%- set rootgroup = salt['cmd.run']("stat -f '%Sg' /dev/console") %} +{%- elif grains.os_family == 'Windows' %} +{%- set rootuser = salt['cmd.run']("id -un") %} {%- endif %} + Debian: pkgrepo: 'deb http://repo.saltstack.com/{{ py_ver_repr or 'apt' }}/{{ osfamily_lower }}/{{ osmajorrelease }}/amd64/{{ salt_release }} {{ oscodename }} main' key_url: 'https://repo.saltstack.com/{{ py_ver_repr or 'apt' }}/{{ osfamily_lower }}/{{ osmajorrelease }}/amd64/{{ salt_release }}/SALTSTACK-GPG-KEY.pub' @@ -130,6 +133,7 @@ Windows: salt_minion: salt-minion{{ '-' ~ py_ver_repr if py_ver_repr else '' }} config_path: 'C:\salt\conf' minion_service: salt-minion + rootuser: {{ rootuser | d('') }} MacOS: salt_minion: salt @@ -138,5 +142,5 @@ MacOS: config_path: /private/etc/salt minion_service: com.saltstack.salt.minion ## from template-formula - rootuser: {{ macos_rootuser | d('') }} - rootgroup: {{ macos_rootgroup | d('') }} + rootuser: {{ rootuser | d('') }} + rootgroup: {{ rootgroup | d('') }} diff --git a/salt/osmap.yaml b/salt/osmap.yaml index 383355d..bd8ba2c 100644 --- a/salt/osmap.yaml +++ b/salt/osmap.yaml @@ -63,5 +63,4 @@ MacOS: salt_minion_macos_plist_hash: 26b33da12e0d8960ee96b488c8352002c22a377c19bf3df3f986a1e49eca8b20 Windows: - rootgroup: Users parallel: false # not supported on windows/cygwin From e313401cd657a77a3624ed372c8e22e905c2d172 Mon Sep 17 00:00:00 2001 From: noelmcloughlin Date: Fri, 11 Sep 2020 23:27:30 +0100 Subject: [PATCH 5/5] fix(jinja): stop repeating user/group args --- salt/formulas.sls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/formulas.sls b/salt/formulas.sls index c20e1b4..ad7b09a 100644 --- a/salt/formulas.sls +++ b/salt/formulas.sls @@ -38,11 +38,11 @@ {%- for key, value in salt['pillar.get']('salt_formulas:basedir_opts', {'makedirs': True}).items() %} - {{ key }}: {{ value }} + {%- endfor %} - user: {{ salt_settings.rootuser }} {%- if grains.kernel != 'Windows' %} - group: {{ salt_settings.rootgroup }} {%- endif %} - {%- endfor %} {%- endif %} # Setup the formula Git repository