YaleUniversity / packer-plugin-goss

Goss Provisioner for Packer
MIT License
136 stars 45 forks source link

Fix & Enhance Goss packer provisioner #30

Closed EleanorRigby closed 4 years ago

EleanorRigby commented 4 years ago
EleanorRigby commented 4 years ago

@fishnix : Please review and let me know if the changes are good to go?

The format options will greatly increase readability of json output. There are other small cosmetic fixes but this is most significant one.

Previous

amazon-2: {"results":[{"duration":15827,"err":null,"expected":["true"],"found":["true"],"human":"","meta":null,"property":"running","resource-id":"containerd","resource-type":"Process","result":0,"successful":true,"summary-line":"Process: containerd: running: matches expectation: [true]","test-type":0,"title":""},{"duration":1566,"err":null,"expected":["false"],"found":["false"],"human":"","meta":null,"property":"running","resource-id":"dockerd","resource-type":"Process","result":0,"successful":true,"summary-line":"Process: dockerd: running: matches expectation: [false]","test-type":0,"title":""},{"duration":19693150,"err":null,"expected":["true"],"found":["true"],"human":"","meta":null,"property":"enabled","resource-id":"containerd","resource-type":"Service","result":0,"successful":true,"summary-line":"Service: containerd: enabled: matches expectation: [true]","test-type":0,"title":""},{"duration":15902768,"err":null,"expected":["true"],"found":["true"],"human":"","meta":null,"property":"running","resource-id":"containerd","resource-type":"Service","result":0,"successful":true,"summary-line":"Service: containerd: running: matches expectation: [true]","test-type":0,"title":""},{"duration":84376268,"err":null,"expected":["true"],"found":["true"],"human":"","meta":null,"property":"enabled","resource-id":"kubelet","resource-type":"Service","result":0,"successful":true,"summary-line":"Service: kubelet: enabled: matches expectation: [true]","test-type":0,"title":""},{"duration":29201776,"err":null,"expected":["false"],"found":["false"],"human":"","meta":null,"property":"running","resource-id":"kubelet","resource-type":"Service","result":0,"successful":true,"summary-line":"Service: kubelet: running: matches expectation: [false]","test-type":0,"title":""},{"duration":130738439,"err":null,"expected":["0"],"found":["0"],"human":"","meta":null,"property":"exit-status","resource-id":"crictl ps","resource-type":"Command","result":0,"successful":true,"summary-line":"Command: crictl ps: exit-status: matches expectation: [0]","test-type":0,"title":""},{"duration":134406083,"err":null,"expected":["true"],"found":["true"],"human":"","meta":null,"property":"installed","resource-id":"cloud-init","resource-type":"Package","result":0,"successful":true,"summary-line":"Package: cloud-init: installed: matches expectation: [true]","test-type":0,"title":""},{"duration":187403032,"err":null,"expected":["true"],"found":["true"],"human":"","meta":null,"property":"installed","resource-id":"kubelet","resource-type":"Package","result":0,"successful":true,"summary-line":"Package: kubelet: installed: matches expectation: [true]","test-type":0,"title":""},{"duration":195179061,"err":null,"expected":["true"],"found":["true"],"human":"","meta":null,"property":"installed","resource-id":"kubectl","resource-type":"Package","result":0,"successful":true,"summary-line":"Package: kubectl: installed: matches expectation: [true]","test-type":0,"title":""},{"duration":196327154,"err":null,"expected":["true"],"found":["true"],"human":"","meta":null,"property":"installed","resource-id":"kubernetes-cni","resource-type":"Package","result":0,"successful":true,"summary-line":"Package: kubernetes-cni: installed: matches expectation: [true]","test-type":0,"title":""},{"duration":201857445,"err":null,"expected":["true"],"found":["true"],"human":"","meta":null,"property":"installed","resource-id":"kubeadm","resource-type":"Package","result":0,"successful":true,"summary-line":"Package: kubeadm: installed: matches expectation: [true]","test-type":0,"title":""},{"duration":7818997442,"err":null,"expected":["0"],"found":["0"],"human":"","meta":null,"property":"exit-status","resource-id":"kubeadm init phase preflight","resource-type":"Command","result":0,"successful":true,"summary-line":"Command: kubeadm init phase preflight: exit-status: matches expectation: [0]","test-type":0,"title":""}],"summary":{"failed-count":0,"summary-line":"Count: 13, Failed: 0, Duration: 7.820s","test-count":13,"total-duration":7819783686}}

After this commit

==> ubuntu-1804: Running goss tests...
    ubuntu-1804: {
    ubuntu-1804:     "results": [
    ubuntu-1804:         {
    ubuntu-1804:             "duration": 31352,
    ubuntu-1804:             "err": null,
    ubuntu-1804:             "expected": [
    ubuntu-1804:                 "true"
    ubuntu-1804:             ],
    ubuntu-1804:             "found": [
    ubuntu-1804:                 "true"
    ubuntu-1804:             ],
    ubuntu-1804:             "human": "",
    ubuntu-1804:             "meta": null,
    ubuntu-1804:             "property": "running",
    ubuntu-1804:             "resource-id": "containerd",
    ubuntu-1804:             "resource-type": "Process",
    ubuntu-1804:             "result": 0,
    ubuntu-1804:             "successful": true,
    ubuntu-1804:             "summary-line": "Process: containerd: running: matches expectation: [true]",
    ubuntu-1804:             "test-type": 0,
    ubuntu-1804:             "title": ""
    ubuntu-1804:         },
    ubuntu-1804:         {
    ubuntu-1804:             "duration": 1610,
    ubuntu-1804:             "err": null,
    ubuntu-1804:             "expected": [
    ubuntu-1804:                 "false"
    ubuntu-1804:             ],
    ubuntu-1804:             "found": [
    ubuntu-1804:                 "false"
    ubuntu-1804:             ],
    ubuntu-1804:             "human": "",
    ubuntu-1804:             "meta": null,
    ubuntu-1804:             "property": "running",
    ubuntu-1804:             "resource-id": "dockerd",
    ubuntu-1804:             "resource-type": "Process",
    ubuntu-1804:             "result": 0,
    ubuntu-1804:             "successful": true,
    ubuntu-1804:             "summary-line": "Process: dockerd: running: matches expectation: [false]",
    ubuntu-1804:             "test-type": 0,
    ubuntu-1804:             "title": ""
    ubuntu-1804:         },
    ubuntu-1804:         {
    ubuntu-1804:             "duration": 20126709,
    ubuntu-1804:             "err": null,
    ubuntu-1804:             "expected": [
    ubuntu-1804:                 "true"
    ubuntu-1804:             ],
    ubuntu-1804:             "found": [
    ubuntu-1804:                 "true"
    ubuntu-1804:             ],
    ubuntu-1804:             "human": "",
    ubuntu-1804:             "meta": null,
    ubuntu-1804:             "property": "installed",
    ubuntu-1804:             "resource-id": "kubectl",
    ubuntu-1804:             "resource-type": "Package",
    ubuntu-1804:             "result": 0,
    ubuntu-1804:             "successful": true,
    ubuntu-1804:             "summary-line": "Package: kubectl: installed: matches expectation: [true]",
    ubuntu-1804:             "test-type": 0,
    ubuntu-1804:             "title": ""
    ubuntu-1804:         },
    ubuntu-1804:         {
    ubuntu-1804:             "duration": 71297161,
    ubuntu-1804:             "err": null,
    ubuntu-1804:             "expected": [
    ubuntu-1804:                 "0"
    ubuntu-1804:             ],
    ubuntu-1804:             "found": [
    ubuntu-1804:                 "0"
    ubuntu-1804:             ],
    ubuntu-1804:             "human": "",
    ubuntu-1804:             "meta": null,
    ubuntu-1804:             "property": "exit-status",
    ubuntu-1804:             "resource-id": "crictl ps",
    ubuntu-1804:             "resource-type": "Command",
    ubuntu-1804:             "result": 0,
    ubuntu-1804:             "successful": true,
    ubuntu-1804:             "summary-line": "Command: crictl ps: exit-status: matches expectation: [0]",
    ubuntu-1804:             "test-type": 0,
    ubuntu-1804:             "title": ""
    ubuntu-1804:         },
    ubuntu-1804:         {
    ubuntu-1804:             "duration": 86753240,
    ubuntu-1804:             "err": null,
    ubuntu-1804:             "expected": [
    ubuntu-1804:                 "true"
    ubuntu-1804:             ],
    ubuntu-1804:             "found": [
    ubuntu-1804:                 "true"
    ubuntu-1804:             ],
    ubuntu-1804:             "human": "",
    ubuntu-1804:             "meta": null,
    ubuntu-1804:             "property": "installed",
    ubuntu-1804:             "resource-id": "kubelet",
    ubuntu-1804:             "resource-type": "Package",
    ubuntu-1804:             "result": 0,
    ubuntu-1804:             "successful": true,
    ubuntu-1804:             "summary-line": "Package: kubelet: installed: matches expectation: [true]",
    ubuntu-1804:             "test-type": 0,
    ubuntu-1804:             "title": ""
    ubuntu-1804:         },
    ubuntu-1804:         {
    ubuntu-1804:             "duration": 87891744,
    ubuntu-1804:             "err": null,
    ubuntu-1804:             "expected": [
    ubuntu-1804:                 "true"
    ubuntu-1804:             ],
    ubuntu-1804:             "found": [
    ubuntu-1804:                 "true"
    ubuntu-1804:             ],
    ubuntu-1804:             "human": "",
    ubuntu-1804:             "meta": null,
    ubuntu-1804:             "property": "installed",
    ubuntu-1804:             "resource-id": "kubernetes-cni",
    ubuntu-1804:             "resource-type": "Package",
    ubuntu-1804:             "result": 0,
    ubuntu-1804:             "successful": true,
    ubuntu-1804:             "summary-line": "Package: kubernetes-cni: installed: matches expectation: [true]",
    ubuntu-1804:             "test-type": 0,
    ubuntu-1804:             "title": ""
    ubuntu-1804:         },
    ubuntu-1804:         {
    ubuntu-1804:             "duration": 152776916,
    ubuntu-1804:             "err": null,
    ubuntu-1804:             "expected": [
    ubuntu-1804:                 "true"
    ubuntu-1804:             ],
    ubuntu-1804:             "found": [
    ubuntu-1804:                 "true"
    ubuntu-1804:             ],
    ubuntu-1804:             "human": "",
    ubuntu-1804:             "meta": null,
    ubuntu-1804:             "property": "installed",
    ubuntu-1804:             "resource-id": "kubeadm",
    ubuntu-1804:             "resource-type": "Package",
    ubuntu-1804:             "result": 0,
    ubuntu-1804:             "successful": true,
    ubuntu-1804:             "summary-line": "Package: kubeadm: installed: matches expectation: [true]",
    ubuntu-1804:             "test-type": 0,
    ubuntu-1804:             "title": ""
    ubuntu-1804:         },
    ubuntu-1804:         {
    ubuntu-1804:             "duration": 93969870,
    ubuntu-1804:             "err": null,
    ubuntu-1804:             "expected": [
    ubuntu-1804:                 "true"
    ubuntu-1804:             ],
    ubuntu-1804:             "found": [
    ubuntu-1804:                 "true"
    ubuntu-1804:             ],
    ubuntu-1804:             "human": "",
    ubuntu-1804:             "meta": null,
    ubuntu-1804:             "property": "enabled",
    ubuntu-1804:             "resource-id": "containerd",
    ubuntu-1804:             "resource-type": "Service",
    ubuntu-1804:             "result": 0,
    ubuntu-1804:             "successful": true,
    ubuntu-1804:             "summary-line": "Service: containerd: enabled: matches expectation: [true]",
    ubuntu-1804:             "test-type": 0,
    ubuntu-1804:             "title": ""
    ubuntu-1804:         },
    ubuntu-1804:         {
    ubuntu-1804:             "duration": 69563047,
    ubuntu-1804:             "err": null,
    ubuntu-1804:             "expected": [
    ubuntu-1804:                 "true"
    ubuntu-1804:             ],
    ubuntu-1804:             "found": [
    ubuntu-1804:                 "true"
    ubuntu-1804:             ],
    ubuntu-1804:             "human": "",
    ubuntu-1804:             "meta": null,
    ubuntu-1804:             "property": "running",
    ubuntu-1804:             "resource-id": "containerd",
    ubuntu-1804:             "resource-type": "Service",
    ubuntu-1804:             "result": 0,
    ubuntu-1804:             "successful": true,
    ubuntu-1804:             "summary-line": "Service: containerd: running: matches expectation: [true]",
    ubuntu-1804:             "test-type": 0,
    ubuntu-1804:             "title": ""
    ubuntu-1804:         },
    ubuntu-1804:         {
    ubuntu-1804:             "duration": 163702862,
    ubuntu-1804:             "err": null,
    ubuntu-1804:             "expected": [
    ubuntu-1804:                 "true"
    ubuntu-1804:             ],
    ubuntu-1804:             "found": [
    ubuntu-1804:                 "true"
    ubuntu-1804:             ],
    ubuntu-1804:             "human": "",
    ubuntu-1804:             "meta": null,
    ubuntu-1804:             "property": "enabled",
    ubuntu-1804:             "resource-id": "kubelet",
    ubuntu-1804:             "resource-type": "Service",
    ubuntu-1804:             "result": 0,
    ubuntu-1804:             "successful": true,
    ubuntu-1804:             "summary-line": "Service: kubelet: enabled: matches expectation: [true]",
    ubuntu-1804:             "test-type": 0,
    ubuntu-1804:             "title": ""
    ubuntu-1804:         },
    ubuntu-1804:         {
    ubuntu-1804:             "duration": 27772014,
    ubuntu-1804:             "err": null,
    ubuntu-1804:             "expected": [
    ubuntu-1804:                 "false"
    ubuntu-1804:             ],
    ubuntu-1804:             "found": [
    ubuntu-1804:                 "false"
    ubuntu-1804:             ],
    ubuntu-1804:             "human": "",
    ubuntu-1804:             "meta": null,
    ubuntu-1804:             "property": "running",
    ubuntu-1804:             "resource-id": "kubelet",
    ubuntu-1804:             "resource-type": "Service",
    ubuntu-1804:             "result": 0,
    ubuntu-1804:             "successful": true,
    ubuntu-1804:             "summary-line": "Service: kubelet: running: matches expectation: [false]",
    ubuntu-1804:             "test-type": 0,
    ubuntu-1804:             "title": ""
    ubuntu-1804:         },
    ubuntu-1804:         {
    ubuntu-1804:             "duration": 191485080,
    ubuntu-1804:             "err": null,
    ubuntu-1804:             "expected": [
    ubuntu-1804:                 "true"
    ubuntu-1804:             ],
    ubuntu-1804:             "found": [
    ubuntu-1804:                 "true"
    ubuntu-1804:             ],
    ubuntu-1804:             "human": "",
    ubuntu-1804:             "meta": null,
    ubuntu-1804:             "property": "installed",
    ubuntu-1804:             "resource-id": "cloud-init",
    ubuntu-1804:             "resource-type": "Package",
    ubuntu-1804:             "result": 0,
    ubuntu-1804:             "successful": true,
    ubuntu-1804:             "summary-line": "Package: cloud-init: installed: matches expectation: [true]",
    ubuntu-1804:             "test-type": 0,
    ubuntu-1804:             "title": ""
    ubuntu-1804:         },
    ubuntu-1804:         {
    ubuntu-1804:             "duration": 9812091972,
    ubuntu-1804:             "err": null,
    ubuntu-1804:             "expected": [
    ubuntu-1804:                 "0"
    ubuntu-1804:             ],
    ubuntu-1804:             "found": [
    ubuntu-1804:                 "0"
    ubuntu-1804:             ],
    ubuntu-1804:             "human": "",
    ubuntu-1804:             "meta": null,
    ubuntu-1804:             "property": "exit-status",
    ubuntu-1804:             "resource-id": "kubeadm init phase preflight",
    ubuntu-1804:             "resource-type": "Command",
    ubuntu-1804:             "result": 0,
    ubuntu-1804:             "successful": true,
    ubuntu-1804:             "summary-line": "Command: kubeadm init phase preflight: exit-status: matches expectation: [0]",
    ubuntu-1804:             "test-type": 0,
    ubuntu-1804:             "title": ""
    ubuntu-1804:         }
    ubuntu-1804:     ],
    ubuntu-1804:     "summary": {
    ubuntu-1804:         "failed-count": 0,
    ubuntu-1804:         "summary-line": "Count: 13, Failed: 0, Duration: 9.817s",
    ubuntu-1804:         "test-count": 13,
    ubuntu-1804:         "total-duration": 9816845246
    ubuntu-1804:     }
    ubuntu-1804: }
EleanorRigby commented 4 years ago

cc: @codenrhoden

EleanorRigby commented 4 years ago

@fishnix : Addressed all comments. When are you planning to cut a release?

I was hoping we can also add support for environment variables for GOSS. What do you think?

EleanorRigby commented 4 years ago

fixes #29

fishnix commented 4 years ago

Thanks for the updates @EleanorRigby !

Do you mean like GOSS_FILE, GOSS_VARS, etc? I think that would be fine if you want to work on it.

Cheers!

EleanorRigby commented 4 years ago

Thanks for the updates @EleanorRigby !

Do you mean like GOSS_FILE, GOSS_VARS, etc? I think that would be fine if you want to work on it.

Cheers!

Thanks.