Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Commit

Permalink
Merge pull request #654 from digitalrebar/v451-pullback
Browse files Browse the repository at this point in the history
V451 pullback
  • Loading branch information
galthaus authored Oct 14, 2020
2 parents 8f0fcd0 + cca6260 commit 08445d2
Show file tree
Hide file tree
Showing 36 changed files with 467 additions and 43 deletions.
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ sledgehammer-builder/ contains the Sledgehammer Builder content

The extraneous directories and files (images, tools, .gitignore, etc.) are
not part of the content packs.

.. Release v4.6.0 Start
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/bin/mkdir -p /var/log/chef

# Make sure we have a node name
{{if not (.ParamExists "chef-bootstrap/node_name")}}
{{ if not (.ParamExists "chef-bootstrap/node_name") }}
drpcli machines set {{.Machine.UUID}} param "chef-bootstrap/node_name" to "$(hostname -f )"
{{end}}

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{if .ParamExists "chef-bootstrap/encrypted_data_bag_secret"}}{{.Param "chef-bootstrap/encrypted_data_bag_secret"}}{{end}}
{{ if .ParamExists "chef-bootstrap/encrypted_data_bag_secret" }}{{.Param "chef-bootstrap/encrypted_data_bag_secret"}}{{ end }}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{ if .ParamExists "chef-bootstrap/first_boot" }}
{{.Param "chef-bootstrap/first_boot"}}
{{ else if and .ParamExists "chef-bootstrap/policy_name" .ParamExists "chef-bootstrap/policy_group" }}
{{ else if and (.ParamExists "chef-bootstrap/policy_name") (.ParamExists "chef-bootstrap/policy_group") }}
{
"policy_group": "{{.Param "chef-bootstrap/policy_group"}}",
"policy_name": "{{.Param "chef-bootstrap/policy_name"}}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{.Param "chef-bootstrap/user_key"}}
{{ .Param "chef-bootstrap/user_key" }}
14 changes: 14 additions & 0 deletions classify/params/classification-data-parameter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
Name: "classify/data-parameter"
Description: "The name of the parameter to use for classification data"
Meta:
color: "blue"
icon: "search"
title: "RackN"
Documentation: |
This defines the name of a parameter that contains the classification data.
The parameter should have the same type as classify/classification-data.
Schema:
type: "string"
15 changes: 15 additions & 0 deletions classify/params/classification-disable-parameter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
Name: "classify/disable-parameter"
Description: "The name of the parameter to use for disabling this classifier"
Meta:
color: "blue"
icon: "search"
title: "RackN"
Documentation: |
This defines the name of a parameter that defines if this classifer should
be skipped.
The parameter should have the same type as classify/disable-classifier, boolean.
Schema:
type: "string"
16 changes: 16 additions & 0 deletions classify/params/classification-function-parameter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
Name: "classify/function-parameter"
Description: "The name of the parameter to use for classification functions"
Meta:
color: "blue"
icon: "search"
title: "RackN"
Documentation: |
This defines the name of a parameter that contains the list of classification
functions to add.
The parameter should have the same type as classify/custom-functions,
a list of template names.
Schema:
type: "string"
15 changes: 15 additions & 0 deletions classify/params/classification-version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
Name: "classify/version"
Description: "Indications what version of the classifier we use."
Documentation: |
This parameter defines the version of classifier to use.
Version 1 uses the normal parameters. Version 2 uses the parameter
name parameters to determine what to do.
Schema:
type: "number"
default: 1
Meta:
type: "config"
color: "blue"
icon: "fire"
title: "RackN Content"
15 changes: 15 additions & 0 deletions classify/params/classify-stage-list-parameter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
Name: "classify/stage-list-parameter"
Description: "The name of the parameter to use to define a list of stages to inject"
Meta:
color: "blue"
icon: "search"
title: "RackN"
Documentation: |
This defines the name of a parameter that defines the list of classifaction stages
to add to the machine.
The parameter should have the same type as classify/stage-list, array of strings.
Schema:
type: "string"
17 changes: 17 additions & 0 deletions classify/params/classify-stage-list.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
Name: "classify/stage-list"
Description: "A list of classify stages to added the machine"
Documentation: |
Use this Param to specify additional classify stages.
In general, this is an example and is used as a different parameter
through indirection.
Meta:
color: "blue"
icon: "hashtag"
title: "RackN Content"
Schema:
type: "array"
default: []
items:
type: "string"
18 changes: 18 additions & 0 deletions classify/stages/classify-stage-list.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
Name: "classify-stage-list"
Description: "Adds stages to the machines task list to run multiple classifiers"
Documentation: |
This stages uses the ``classify/stage-list`` parameter to add classification stages
to the machine.
To build custom sets of lists, you can extend this by changing the ``classify/stage-list-parameter``.
Meta:
color: "yellow"
icon: "search"
title: "RackN"
Params:
classify/stage-list-parameter: "classify/stage-list"
Tasks:
- "classify-stage-list-start"
- "classify-stage-list-stop"
3 changes: 0 additions & 3 deletions classify/stages/classify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,5 @@ Meta:
color: "yellow"
icon: "search"
title: "RackN"
Reboot: false
RequiredParams:
- "classify/classification-data"
Tasks:
- "classify"
61 changes: 61 additions & 0 deletions classify/tasks/classify-stage-list-start.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
Name: "classify-stage-list-start"
Description: "Start a set of classification stages on a machine"
Documentation: |
Using the parameter specified by the ``classify/stage-list-parameter``, the
stages specified in that list will be added to the system. This assumes that
they are classify stages and have a single task of classify.
No other tasks should preceed it on the stage, and the only other task that
should follow is the ``classify-stage-list-stop`` task.
Tasks will be dynamically injected in to the workflow after this task, if they
have been specified by the appropriate control Params.
Meta:
color: "blue"
icon: "bug"
title: "RackN Content"
feature-flags: "sane-exit-codes"
Templates:
- Name: "classify-stage-list-start.sh"
Contents: |
#!/bin/bash
# Copyright RackN, 2020
set -e
{{ template "setup.tmpl" . }}
{{ if eq (.ParamExists "classify/stage-list-parameter") false }}
echo "classify/stage-list-parameter is not specified"
exit 1
{{ end }}
{{ $lp := .Param "classify/stage-list-parameter" -}}
{{ if eq (.ParamExists $lp) false -}}
echo "classify/stage-list-parameter is {{$lp}} and it does not exist."
exit 1
{{ end -}}
# Build new task list - This is dangerous and not to be done without planning.
{{ $cid := add .Machine.CurrentTask 1 -}}
{{ $first := slice .Machine.Tasks 0 $cid -}}
{{ $seestop := 0 -}}
{{ range $index, $taskname := (slice .Machine.Tasks $cid) -}}
{{ if eq $taskname "classify-stage-list-stop" -}}
{{ $seestop = $index -}}
{{ end -}}
{{ end -}}
{{ $last := slice .Machine.Tasks (add $cid $seestop) -}}
{{ range $index, $stagename := .ComposeParam $lp -}}
{{ $first = append $first (printf "stage:%s" $stagename) -}}
{{ $first = append $first "classify" -}}
{{ end -}}
{{ $full := concat $first $last -}}
# Reset the task list
drpcli machines update --force $RS_UUID - >/dev/null <<EOF
Tasks: {{toJson $full}}
EOF
exit 0
22 changes: 22 additions & 0 deletions classify/tasks/classify-stage-list-stop.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
Name: "classify-stage-list-stop"
Description: "Stop a set of classify stages"
Documentation: |
This task ends a given set of classifcation stages. No other tasks should follow it on
the stage.
Tasks will be dynamically injected in to the workflow if they have been specified
by the appropriate control Params prior to this task.
Meta:
color: "blue"
icon: "bug"
title: "RackN Content"
feature-flags: "sane-exit-codes"
Templates:
- Name: "validation_stop.sh"
Contents: |
#!/bin/bash
# Copyright RackN, 2020
exit 0
13 changes: 12 additions & 1 deletion classify/templates/classify-custom-functions.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,25 @@
# classifer to provide custom function blocks to extend the tests you can
# apply to the classifier

{{ $functParameter := "classify/custom-functions" }}
{{ if ne 1 (.Param "classify/version" | int) }}
{{ if .ParamExists "classify/function-parameter" }}
{{ $functParameter = .Param "classify/function-parameter" }}
{{ else }}
{{ $functParameter = "unknown-function-parameter" }}
{{ end }}
{{ end }}

{{ if .ParamExists $functParameter }}
{{ $dot := . -}}
{{range $index, $template := .Param "classify/custom-functions" -}}
{{range $index, $template := .Param $functParameter -}}

#############################################################################
# injecting custom template: {{ squote $template }}
{{ $dot.CallTemplate $template $dot }}
# end injection of template: {{ squote $template }}

{{ end -}}
{{ end }}
### end custom template injection
#############################################################################
38 changes: 35 additions & 3 deletions classify/templates/classify.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,39 @@ set -e
{{template "setup.tmpl" .}}
[[ $RS_UUID ]] && export RS_UUID="{{.Machine.UUID}}"

DISABLE_CLASSIFIER="{{.Param "classify/disable-classifier"}}"
{{ $dataParameter := "classify/classification-data" }}
{{ $functionParameter := "classify/custom-functions" }}
{{ $disableParameter := "classify/disable-classifier" }}
DISABLE_CLASSIFIER="{{.Param $disableParameter}}"
{{ if ne 1 (.Param "classify/version" | int) }}
{{ if .ParamExists "classify/data-parameter" }}
{{ $dataParameter = .Param "classify/data-parameter" }}
{{ else }}
{{ $dataParameter = "unknown-data-parameter" }}
{{ end }}

{{ if .ParamExists "classify/function-parameter" }}
{{ $functionParameter = .Param "classify/function-parameter" }}
{{ else }}
{{ $functionParameter = "unknown-function-parameter" }}
{{ end }}

{{ if .ParamExists "classify/disable-parameter" }}
{{ $disableParameter = .Param "classify/disable-parameter" }}
{{ if .ParamExists $disableParameter }}
DISABLE_CLASSIFIER="{{ .Param $disableParameter }}"
{{ else }}
DISABLE_CLASSIFIER="false"
{{ end }}
{{ end }}
{{ end }}

echo "Using data parameter: {{$dataParameter}}"
echo "Using function parameter: {{$functionParameter}}"
echo "Using disable parameter: {{$disableParameter}}"

if [[ "$DISABLE_CLASSIFIER" == "true" ]]; then
echo "Classification system disabled ('classify/disable-classifier' set to 'true')."
echo "Classification system disabled ('{{$disableParameter}}' set to 'true')."
exit 0
fi

Expand Down Expand Up @@ -128,7 +158,8 @@ function get_my_mac() {
# if any custom classify functions are specified, inject them here
{{ template "classify-custom-functions.tmpl" .}}

{{range $index, $group := .Param "classify/classification-data"}}
{{ if .ParamExists $dataParameter }}
{{range $index, $group := .Param $dataParameter }}

[[ $RS_DEBUG_ENABLE ]] && echo ">>> INDEX: {{$index}}"
[[ $RS_DEBUG_ENABLE ]] && echo ">>> GROUP: {{$group}}"
Expand All @@ -151,6 +182,7 @@ if [[ $RESULT == "pass" ]] ; then
exit 0
{{ end -}}
fi
{{end}}

{{else}}
echo "No data to classify. Continuing without classification ..."
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.13

require (
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/digitalrebar/provision/v4 v4.5.0 // indirect
github.com/digitalrebar/provision/v4 v4.5.1 // indirect
github.com/stevenroose/remarshal v0.0.0-20160825110430-37e7cbf22025 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
)
8 changes: 3 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg=
github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
Expand All @@ -22,8 +21,8 @@ github.com/digitalocean/go-smbios v0.0.0-20180907143718-390a4f403a8e h1:vUmf0yez
github.com/digitalocean/go-smbios v0.0.0-20180907143718-390a4f403a8e/go.mod h1:YTIHhz/QFSYnu/EhlF2SpU2Uk+32abacUYA5ZPljz1A=
github.com/digitalrebar/logger v0.3.0 h1:7/XP3BQiWfl1Lqmm7tvkvdwjPilDUUPC/iWbeWO9G6g=
github.com/digitalrebar/logger v0.3.0/go.mod h1:zH2t4FBhzVxZJTg+eaPzNCRL50nlcRLxWurfTsl5jWE=
github.com/digitalrebar/provision/v4 v4.5.0 h1:o9lx4DR0OEkAbz2TfLu+EqPYrqlTu8erHkNDgEHCTPg=
github.com/digitalrebar/provision/v4 v4.5.0/go.mod h1:6RVCvHA0zLLX+H0ykzoo4maLhSQ1LYHkR/wZcfO46Us=
github.com/digitalrebar/provision/v4 v4.5.1 h1:hgrURSBYfFLaucwbBq4B+HpzaYr8JJjz6CSa2rCZuc4=
github.com/digitalrebar/provision/v4 v4.5.1/go.mod h1:7Unaxd18JfzaxibzzUgBDFOVex6U8HZ1AmDPvGQszuY=
github.com/digitalrebar/tftp v2.1.0+incompatible h1:CzBcnsUaMtdLSOf3dSycinnfpajAAro7l8oo/ILyzOI=
github.com/digitalrebar/tftp v2.1.0+incompatible/go.mod h1:k1tcsyQwHE72oTU5sfXPJdOCHFiZUt3M2BdYdHsfw6c=
github.com/digitalrebar/tftp/v3 v3.0.0 h1:Ft2i3s2gCZ795rISs9vlcy3YSqfd6mtodxGoUcPSrhs=
Expand Down Expand Up @@ -108,7 +107,7 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/rackn/gohai v0.0.0-20190619164647-92918a701117/go.mod h1:1NhfVxJ6qD4S5ondz2CobWFiYlODF8ex4pNgQrKYCxc=
github.com/rackn/gohai v0.5.0 h1:W56MFkYUpHkzl6RhffVjcuH9wJHLcBHMIKA4U+xnOm4=
github.com/rackn/gohai v0.5.0/go.mod h1:L14W5Y4U9zycW/zJlbg75nVbrO6qWj80FWHjiCgxnag=
github.com/rackn/netwrangler v0.7.0/go.mod h1:1ZvFAprvzdbIZ/kMYh90tLMGsK4U31YqrAsKNIUEqls=
github.com/rackn/netwrangler v0.7.1/go.mod h1:hGj63TX3L7BRiZVZ3jIIsKTwy78VIpDHCoe1tkk//xI=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/shirou/gopsutil v2.18.12+incompatible h1:1eaJvGomDnH74/5cF4CTmTbLHAriGFsTZppLXDX93OM=
github.com/shirou/gopsutil v2.18.12+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
Expand All @@ -119,7 +118,6 @@ github.com/spf13/cobra v0.0.4-0.20180722215644-7c4570c3ebeb h1:l8xMeTl9t6JKC/dA1
github.com/spf13/cobra v0.0.4-0.20180722215644-7c4570c3ebeb/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/stevenroose/remarshal v0.0.0-20160825110430-37e7cbf22025 h1:7wJkExq7a8hs4thauj7otgYQD+zzmxWickV8uxpkJYY=
github.com/stevenroose/remarshal v0.0.0-20160825110430-37e7cbf22025/go.mod h1:hy8+qmjgBi7BCVwCLsE3nwNHNjEjAMVfdTKvykMrbcA=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
Expand Down
5 changes: 1 addition & 4 deletions integrations/docker-context/ansible-dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@ RUN pip3 install --no-cache-dir --upgrade yq
RUN pip3 install --no-cache-dir --upgrade mitogen boto3
# Linode
RUN pip3 install --no-cache-dir --upgrade linode-api4
RUN curl -o drpcli440 https://s3-us-west-2.amazonaws.com/rebar-catalog/drpcli/v4.4.0/amd64/linux/drpcli && \
chmod 755 drpcli440 && \
./drpcli440 catalog item download drpcli to /usr/bin/drpcli && \
RUN curl -o /usr/bin/drpcli https://s3-us-west-2.amazonaws.com/rebar-catalog/drpcli/v4.5.0/amd64/linux/drpcli && \
chmod 755 /usr/bin/drpcli && \
rm drpcli440 && \
ln -s /usr/bin/drpcli /usr/bin/jq && \
ln -s /usr/bin/drpcli /usr/bin/drpjq && \
echo "Installed DRPCLI $(drpcli version)"
Expand Down
7 changes: 2 additions & 5 deletions integrations/docker-context/runner-dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
FROM alpine:latest
RUN apk --no-cache add bash curl openssh-keygen
RUN curl -o drpcli440 https://s3-us-west-2.amazonaws.com/rebar-catalog/drpcli/v4.4.0/amd64/linux/drpcli && \
chmod 755 drpcli440 && \
./drpcli440 catalog item download drpcli to /usr/bin/drpcli && \
chmod 755 /usr/bin/drpcli && \
rm drpcli440 && \
RUN curl -o /usr/bin/drpcli https://s3-us-west-2.amazonaws.com/rebar-catalog/drpcli/v4.5.0/amd64/linux/drpcli && \
chmod 755 /usr/bin/drpcli && \
ln -s /usr/bin/drpcli /usr/bin/jq && \
ln -s /usr/bin/drpcli /usr/bin/drpjq && \
echo "Installed DRPCLI $(drpcli version)"
Expand Down
Loading

0 comments on commit 08445d2

Please sign in to comment.