Saltstack Official OpenSSH Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

feat(semantic-release): implement for this formula * Close #165 * Move existing `.kitchen.yml` => `kitchen.vagrant.yml` * Semi-automated using https://github.com/myii/ssf-formula/pull/30 * Fix errors shown below: ```bash openssh-formula$ yamllint -s . ./pillar.example 49:3 error duplication of key "AllowUsers" in mapping (key-duplicates) 57:3 error duplication of key "DenyUsers" in mapping (key-duplicates) 63:3 error duplication of key "AllowGroups" in mapping (key-duplicates) 70:3 error duplication of key "DenyGroups" in mapping (key-duplicates) 79:24 warning truthy value should be one of [false, true] (truthy) 80:29 warning truthy value should be one of [false, true] (truthy) 118:4 warning missing starting space in comment (comments) 119:4 warning missing starting space in comment (comments) 119:89 error line too long (122 > 88 characters) (line-length) 120:4 warning missing starting space in comment (comments) 120:89 error line too long (144 > 88 characters) (line-length) 147:30 warning truthy value should be one of [false, true] (truthy) 148:21 warning truthy value should be one of [false, true] (truthy) 149:19 warning truthy value should be one of [false, true] (truthy) 150:32 warning truthy value should be one of [false, true] (truthy) 151:26 warning truthy value should be one of [false, true] (truthy) 152:31 warning truthy value should be one of [false, true] (truthy) 153:32 warning truthy value should be one of [false, true] (truthy) 154:29 warning truthy value should be one of [false, true] (truthy) 155:34 warning truthy value should be one of [false, true] (truthy) 175:8 warning missing starting space in comment (comments) 175:89 error line too long (152 > 88 characters) (line-length) 176:8 warning missing starting space in comment (comments) 176:89 error line too long (126 > 88 characters) (line-length) 177:8 warning missing starting space in comment (comments) 177:89 error line too long (148 > 88 characters) (line-length) 213:18 warning truthy value should be one of [false, true] (truthy) 219:18 warning truthy value should be one of [false, true] (truthy) 225:18 warning truthy value should be one of [false, true] (truthy) 241:22 warning truthy value should be one of [false, true] (truthy) 243:22 warning truthy value should be one of [false, true] (truthy) 244:20 warning truthy value should be one of [false, true] (truthy) 245:21 warning truthy value should be one of [false, true] (truthy) 254:24 warning truthy value should be one of [false, true] (truthy) 255:22 warning truthy value should be one of [false, true] (truthy) 256:23 warning truthy value should be one of [false, true] (truthy) 265:22 warning truthy value should be one of [false, true] (truthy) 268:21 warning truthy value should be one of [false, true] (truthy) 269:20 warning truthy value should be one of [false, true] (truthy) 270:21 warning truthy value should be one of [false, true] (truthy) 279:26 warning truthy value should be one of [false, true] (truthy) 280:24 warning truthy value should be one of [false, true] (truthy) 281:25 warning truthy value should be one of [false, true] (truthy) 307:16 warning truthy value should be one of [false, true] (truthy) 308:6 warning missing starting space in comment (comments) 314:6 warning missing starting space in comment (comments) 316:24 warning truthy value should be one of [false, true] (truthy) 339:89 error line too long (546 > 88 characters) (line-length) 340:89 error line too long (546 > 88 characters) (line-length) 341:89 error line too long (546 > 88 characters) (line-length) 342:89 error line too long (546 > 88 characters) (line-length) 344:4 warning missing starting space in comment (comments) 345:4 warning missing starting space in comment (comments) 357:19 warning truthy value should be one of [false, true] (truthy) ./openssh/osfamilymap.yaml 1:1 warning missing document start "---" (document-start) ./openssh/osfingermap.yaml 1:1 warning missing document start "---" (document-start) ./openssh/osmap.yaml 1:1 warning missing document start "---" (document-start) ./openssh/defaults.yaml 1:1 warning missing document start "---" (document-start) 3:18 warning truthy value should be one of [false, true] (truthy) 6:34 warning too few spaces before comment (comments) 10:25 warning truthy value should be one of [false, true] (truthy) 12:32 warning too few spaces before comment (comments) 16:24 warning truthy value should be one of [false, true] (truthy) 18:24 warning too few spaces before comment (comments) 20:42 warning too few spaces before comment (comments) 27:6 warning missing starting space in comment (comments) ```
5 년 전
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. {%- macro files_switch(
  2. source_files,
  3. lookup=None,
  4. default_files_switch=["id", "os_family"],
  5. indent_width=6,
  6. use_subpath=False
  7. ) %}
  8. {#-
  9. Returns a valid value for the "source" parameter of a "file.managed"
  10. state function. This makes easier the usage of the Template Override and
  11. Files Switch (TOFS) pattern.
  12. Params:
  13. * source_files: ordered list of files to look for
  14. * lookup: key under "<tplroot>:tofs:source_files" to prepend to the
  15. list of source files
  16. * default_files_switch: if there's no config (e.g. pillar)
  17. "<tplroot>:tofs:files_switch" this is the ordered list of grains to
  18. use as selector switch of the directories under
  19. "<path_prefix>/files"
  20. * indent_width: indentation of the result value to conform to YAML
  21. * use_subpath: defaults to `False` but if set, lookup the source file
  22. recursively from the current state directory up to `tplroot`
  23. Example (based on a `tplroot` of `xxx`):
  24. If we have a state:
  25. Deploy configuration:
  26. file.managed:
  27. - name: /etc/yyy/zzz.conf
  28. - source: {{ files_switch(
  29. ["/etc/yyy/zzz.conf", "/etc/yyy/zzz.conf.jinja"],
  30. lookup="Deploy configuration",
  31. ) }}
  32. - template: jinja
  33. In a minion with id=theminion and os_family=RedHat, it's going to be
  34. rendered as:
  35. Deploy configuration:
  36. file.managed:
  37. - name: /etc/yyy/zzz.conf
  38. - source:
  39. - salt://xxx/files/theminion/etc/yyy/zzz.conf
  40. - salt://xxx/files/theminion/etc/yyy/zzz.conf.jinja
  41. - salt://xxx/files/RedHat/etc/yyy/zzz.conf
  42. - salt://xxx/files/RedHat/etc/yyy/zzz.conf.jinja
  43. - salt://xxx/files/default/etc/yyy/zzz.conf
  44. - salt://xxx/files/default/etc/yyy/zzz.conf.jinja
  45. - template: jinja
  46. #}
  47. {#- Get the `tplroot` from `tpldir` #}
  48. {%- set tplroot = tpldir.split("/")[0] %}
  49. {%- set path_prefix = salt["config.get"](tplroot ~ ":tofs:path_prefix", tplroot) %}
  50. {%- set files_dir = salt["config.get"](tplroot ~ ":tofs:dirs:files", "files") %}
  51. {%- set files_switch_list = salt["config.get"](
  52. tplroot ~ ":tofs:files_switch", default_files_switch
  53. ) %}
  54. {#- Lookup source_files (v2), files (v1), or fallback to an empty list #}
  55. {%- set src_files = salt["config.get"](
  56. tplroot ~ ":tofs:source_files:" ~ lookup,
  57. salt["config.get"](tplroot ~ ":tofs:files:" ~ lookup, []),
  58. ) %}
  59. {#- Append the default source_files #}
  60. {%- set src_files = src_files + source_files %}
  61. {#- Only add to [""] when supporting older TOFS implementations #}
  62. {%- set path_prefix_exts = [""] %}
  63. {%- if use_subpath and tplroot != tpldir %}
  64. {#- Walk directory tree to find {{ files_dir }} #}
  65. {%- set subpath_parts = tpldir.lstrip(tplroot).lstrip("/").split("/") %}
  66. {%- for path in subpath_parts %}
  67. {%- set subpath = subpath_parts[0 : loop.index] | join("/") %}
  68. {%- do path_prefix_exts.append("/" ~ subpath) %}
  69. {%- endfor %}
  70. {%- endif %}
  71. {%- for path_prefix_ext in path_prefix_exts | reverse %}
  72. {%- set path_prefix_inc_ext = path_prefix ~ path_prefix_ext %}
  73. {#- For older TOFS implementation, use `files_switch` from the config #}
  74. {#- Use the default, new method otherwise #}
  75. {%- set fsl = salt["config.get"](
  76. tplroot ~ path_prefix_ext | replace("/", ":") ~ ":files_switch",
  77. files_switch_list,
  78. ) %}
  79. {#- Append an empty value to evaluate as `default` in the loop below #}
  80. {%- if "" not in fsl %}
  81. {%- set fsl = fsl + [""] %}
  82. {%- endif %}
  83. {%- for fs in fsl %}
  84. {%- for src_file in src_files %}
  85. {%- if fs %}
  86. {%- set fs_dirs = salt["config.get"](fs, fs) %}
  87. {%- else %}
  88. {%- set fs_dirs = salt["config.get"](
  89. tplroot ~ ":tofs:dirs:default", "default"
  90. ) %}
  91. {%- endif %}
  92. {#- Force the `config.get` lookup result as a list where necessary #}
  93. {#- since we need to also handle grains that are lists #}
  94. {%- if fs_dirs is string %}
  95. {%- set fs_dirs = [fs_dirs] %}
  96. {%- endif %}
  97. {%- for fs_dir in fs_dirs %}
  98. {#- strip empty elements by using a select #}
  99. {%- set url = (
  100. [
  101. "- salt:/",
  102. path_prefix_inc_ext.strip("/"),
  103. files_dir.strip("/"),
  104. fs_dir.strip("/"),
  105. src_file.strip("/"),
  106. ]
  107. | select
  108. | join("/")
  109. ) %}
  110. {{ url | indent(indent_width, true) }}
  111. {%- endfor %}
  112. {%- endfor %}
  113. {%- endfor %}
  114. {%- endfor %}
  115. {%- endmacro %}