Op vrijdag 15 mei 2020 04:38:50 UTC+2 schreef TheTube:
>
>
>
> Op vrijdag 15 mei 2020 03:17:47 UTC+2 schreef TheTube:
>>
>>
>>
>> Op vrijdag 15 mei 2020 00:56:13 UTC+2 schreef TheTube:
>>>
>>>
>>>
>>> Op donderdag 14 mei 2020 22:40:32 UTC+2 schreef Megan Marsh:
>>>>
>>>> This is where that bracket issue you found on another thread comes into
>>>> play.
>>>>
>>>> Instead of
>>>>
>>>> "post-processors": [
>>>>> {
>>>>> "type": "shell-local",
>>>>> "script": "create-cloudbox.sh"
>>>>> },
>>>>> {
>>>>> "output": "{{ user `build_directory` }}/{{user
>>>>> `box_basename`}}.{{.Provider}}.box",
>>>>> "type": "vagrant"
>>>>> },
>>>>> {
>>>>> "type": "vagrant-cloud",
>>>>> "box_tag": "username/nameofmybox",
>>>>> "access_token": "{{user `cloud_token`}}",
>>>>> "version": "{{user `version`}}"
>>>>> }
>>>>> ],
>>>>
>>>>
>>>> You need
>>>>
>>>> "post-processors": [[
>>>>> {
>>>>> "type": "shell-local",
>>>>> "script": "create-cloudbox.sh"
>>>>> },
>>>>> {
>>>>> "output": "{{ user `build_directory` }}/{{user
>>>>> `box_basename`}}.{{.Provider}}.box",
>>>>> "type": "vagrant"
>>>>> },
>>>>> {
>>>>> "type": "vagrant-cloud",
>>>>> "box_tag": "username/nameofmybox",
>>>>> "access_token": "{{user `cloud_token`}}",
>>>>> "version": "{{user `version`}}"
>>>>> }
>>>>> ]],
>>>>
>>>>
>>>> Any post-processors only wrapped in the first set of brackets will get
>>>> the build artifact as its input.
>>>>
>>>> Any post-processors inside the second set of brackets will run in
>>>> order, with the output artifact from one post-processor becoming the input
>>>> artifact to the next.
>>>>
>>>> Why?
>>>>
>>>> The double-bracketing doesn't make intuitive sense in a single-flow
>>>> context like yours, but it allows users to create multiple output
>>>> artifacts
>>>> using different postprocessor flows from the same build artifact.
>>>>
>>>> So, for example, you could take the same vmware artifact and both
>>>> create a vagrant box that you upload to vagrant cloud in one flow like
>>>> you're doing here, but then, and in another flow upload it to vsphere, and
>>>> the postprocessors wouldn't get in each other's ways.
>>>>
>>>> For a little more detail on sequencing, you can see the docs at
>>>> https://www.packer.io/docs/templates/post-processors/#post-processor-definition
>>>>
>>>> <https://www.google.com/url?q=https%3A%2F%2Fwww.packer.io%2Fdocs%2Ftemplates%2Fpost-processors%2F%23post-processor-definition&sa=D&sntz=1&usg=AFQjCNFnvvTO9BpBDI8bMECSTCDToTFv1Q>
>>>>
>>>> Hope this helps!
>>>>
>>>
>>>
>>> Executing local shell command [/bin/sh -c
>>> PACKER_BUILDER_TYPE='vmware-iso' PACKER_BUILD_NAME='vmware-iso'
>>> ./create-cloudbox.sh]
>>> ==> vmware-iso (shell-local): % Total % Received % Xferd Average
>>> Speed Time Time Time Current
>>> ==> vmware-iso (shell-local): Dload
>>> Upload Total Spent Left Speed
>>> ==> vmware-iso (shell-local): 100 643 0 402 100 241 300
>>> 179 0:00:01 0:00:01 --:--:-- 479
>>> vmware-iso (shell-local):
>>> {"tag":"cool-base-nl/testmenow16","username":"myusername","name":"mybox","private":false,"downloads":0,"created_at":"2020-05-15T00:44:24.812+02:00","updated_at":"2020-05-15T00:44:24.812+02:00","short_description":"My
>>>
>>> dev box11","description_markdown":"Testbox11 to include Ansible
>>> scripts","description_html":"<p>Testbox11 to include Ansible
>>> scripts</p>\n","current_version":null,"versions":[]}
>>> 2020/05/15 00:44:25 [INFO] (telemetry) ending shell-local
>>> ==> vmware-iso: Running post-processor: vagrant
>>> 2020/05/15 00:44:25 Flagging to keep original artifact from
>>> post-processor 'shell-local'
>>> 2020/05/15 00:44:25 [INFO] (telemetry) Starting post-processor vagrant
>>> 2020/05/15 00:44:25 [INFO] (telemetry) ending vagrant
>>> Build 'vmware-iso' errored: 1 error(s) occurred:
>>>
>>> * Post-processor failed: Unknown artifact type, can't build box:
>>>
>>> * Post-processor failed: Unknown artifact type, can't build box:
>>> 2020/05/15 00:44:25 machine readable: error-count []string{"1"}
>>>
>>> ==> Some builds didn't complete successfully and had errors:
>>> ==> Some builds didn't complete successfully and had errors:
>>> 2020/05/15 00:44:25 machine readable: vmware-iso,error []string{"1
>>> error(s) occurred:\n\n* Post-processor failed: Unknown artifact type, can't
>>> build box: "}
>>> --> vmware-iso: 1 error(s) occurred:
>>>
>>>
>>> * Post-processor failed: Unknown artifact type, can't build box:
>>> ==> Builds finished but no artifacts were created.
>>> * Post-processor failed: Unknown artifact type, can't build box:
>>>
>>> ==> Builds finished but no artifacts were created.
>>> 2020/05/15 00:44:25 [INFO] (telemetry) Finalizing.
>>> 2020/05/15 00:44:26 waiting for all plugin processes to complete...
>>> 2020/05/15 00:44:26 [ERR] Error decoding response stream 12: EOF
>>> 2020/05/15 00:44:26 [ERR] Error decoding response stream 7: EOF
>>> 2020/05/15 00:44:26 [ERR] Error decoding response stream 8: EOF
>>> 2020/05/15 00:44:26 [ERR] Error decoding response stream 9: EOF
>>> 2020/05/15 00:44:26 [ERR] Error decoding response stream 10: EOF
>>> 2020/05/15 00:44:26 [ERR] Error decoding response stream 11: EOF
>>> 2020/05/15 00:44:26 /usr/local/bin/packer: plugin process exited
>>> 2020/05/15 00:44:26 /usr/local/bin/packer: plugin process exited
>>> 2020/05/15 00:44:26 /usr/local/bin/packer: plugin process exited
>>> 2020/05/15 00:44:26 /usr/local/bin/packer: plugin process exited
>>> 2020/05/15 00:44:26 /usr/local/bin/packer: plugin process exited
>>>
>>> "post-processors": [[
>>> {
>>> "type": "shell-local",
>>> "script": "./create-cloudbox.sh"
>>> },
>>> {
>>> "output": "{{ user `build_directory` }}/{{user
>>> `box_basename`}}.{{.Provider}}.box",
>>> "type": "vagrant"
>>> },
>>> {
>>> "type": "vagrant-cloud",
>>> "box_tag": "myusername/mybox",
>>> "access_token": "{{user `cloud_token`}}",
>>> "version": "{{user `version`}}"
>>> }
>>> ]],
>>>
>>> You need
>>>
>>> "post-processors": [[
>>>> {
>>>> "type": "shell-local",
>>>> "script": "create-cloudbox.sh"
>>>> },
>>>> {
>>>> "output": "{{ user `build_directory` }}/{{user
>>>> `box_basename`}}.{{.Provider}}.box",
>>>> "type": "vagrant"
>>>> },
>>>> {
>>>> "type": "vagrant-cloud",
>>>> "box_tag": "username/nameofmybox",
>>>> "access_token": "{{user `cloud_token`}}",
>>>> "version": "{{user `version`}}"
>>>> }
>>>> ]],
>>>
>>>
>>> Mybe first the vagrant and than the output ?
>>>
>>> "type": "vagrant",
>>> "output": "{{ user `build_directory` }}/{{user
>>> `box_basename`}}.{{.Provider}}.box"
>>>
>>> will give it a try.
>>>
>>> In the documentation:
>>> https://www.packer.io/docs/post-processors/vagrant-cloud/
>>>
>>
>> "post-processors": [ { "type": "shell-local", "inline": ["echo Doing
>> stuff..."] }, [ { "type": "vagrant", "include": ["image.iso"],
>> "vagrantfile_template": "vagrantfile.tpl", "output":
>> "proxycore_{{.Provider}}.box" }, { "type": "vagrant-cloud", "box_tag":
>> "hashicorp/precise64", "access_token": "{{user `cloud_token`}}",
>> "version": "{{user `version`}}" } ] ] }
>>
>>
>>
>>
>> if I do the same I get:
>>
>> access_token must be set if vagrant_cloud_url has not been overriden
>> * Failed to verify authentication token: 401 Unauthorized
>>
>>
>> ok simple
>> { "post-processors": ["compress"] }
>>
>>
>>
>> detailed:
>> { "post-processors": [ { "type": "compress", "format": "tar.gz" } ] }
>>
>> sequenced
>> { "post-processors": [[
>> "compress",
>> { "type": "upload", "endpoint": "http://example.com" }
>>
>> ]] }
>>
>> This is from the Packer documentation:
>> https://www.packer.io/docs/post-processors/vagrant-cloud/#use-with-the-vagrant-post-processor
>>
>
>
>> {
>> "variables": {
>> "cloud_token": "{{ env `VAGRANT_CLOUD_TOKEN` }}",
>> "version": "1.0.{{timestamp}}"
>> },
>> "post-processors": [
>> {
>> "type": "shell-local",
>> "inline": ["echo Doing stuff..."]
>> },
>> [
>> {
>> "type": "vagrant",
>> "include": ["image.iso"],
>> "vagrantfile_template": "vagrantfile.tpl",
>> "output": "proxycore_{{.Provider}}.box"
>> },
>> {
>> "type": "vagrant-cloud",
>> "box_tag": "hashicorp/precise64",
>> "access_token": "{{user `cloud_token`}}",
>> "version": "{{user `version`}}"
>> }
>> ]
>> ]
>> }
>>
>
Letś break it down.
The first post-processor is self explenatory.
{
"type": "shell-local",
"inline": ["echo Doing stuff..."]
},
The second one:
{
"type": "vagrant",
"include": ["image.iso"],
"vagrantfile_template": "vagrantfile.tpl",
"output": "proxycore_{{.Provider}}.box"
},
I don´t want to include an iso file so I leave this inlude
line "include": ["image.iso"], out of the json file
Handy option but not for now. "vagrantfile_template": "vagrantfile.tpl",
output etc will be "output": "{{ user `build_directory` }}/{{user
`box_basename`}}.{{.Provider}}.box"
The last processor will be the same.
Still errors.
2020/05/15 12:21:10 [INFO] (telemetry) ending vagrant
2020/05/15 12:21:10 [INFO] (telemetry) Starting post-processor vagrant-cloud
==> vmware-iso: Running post-processor: vagrant-cloud
2020/05/15 12:21:10 packer-post-processor-vagrant-cloud plugin:
Post-Processor Vagrant Cloud API GET:
https://vagrantcloud.com/api/v1/box/cool-base-nl/testmenow20
==> vmware-iso (vagrant-cloud): Verifying box is accessible:
cool-base-nl/testmenow20
2020/05/15 12:21:11 packer-post-processor-vagrant-cloud plugin:
Post-Processor Vagrant Cloud API Response:
2020/05/15 12:21:11 packer-post-processor-vagrant-cloud plugin:
2020/05/15 12:21:11 packer-post-processor-vagrant-cloud plugin:
&{Status:404 Not Found StatusCode:404 Proto:HTTP/1.1 ProtoMajor:1
ProtoMinor:1 Header:map[Cache-Control:[no-cache] Connection:[keep-alive]
Content-Type:[application/json; charset=utf-8] Date:[Fri, 15 May 2020
10:21:10 GMT] Referrer-Policy:[strict-origin-when-cross-origin]
Server:[Cowboy]
Set-Cookie:[_atlas_session_data=V3NrYzlTbkhoWmhKL21JRHdycHFybkdNUmh3Uk54UkxmS1BjZHo4VkZLK3pqVy9sdVFKLzk1UlU0WVRrd21DOUE1STVoNDErMlBnZXRiYlErOG9qNkc3ZkFYeHZCNDc4NkNwUHp6RFh6Q1U9LS1oQlNSWXRXQnJSaG5rS0RwS2JiZ1pnPT0%3D--0e6aadc88af3860b329e7d9aa35537bab8582341;
path=/; expires=Sun, 14 Jun 2020 10:21:11 GMT; secure; HttpOnly]
Strict-Transport-Security:[max-age=31536000; includeSubDomains; preload]
Via:[1.1 vegur] X-Content-Type-Options:[nosniff]
X-Download-Options:[noopen] X-Frame-Options:[SAMEORIGIN]
X-Permitted-Cross-Domain-Policies:[none]
X-Request-Id:[d74d1111-aecc-44c4-a831-dd142fd7d5d2] X-Runtime:[0.215624]
X-Vagrantcloud-Rate-Limit:[99/100] X-Xss-Protection:[1; mode=block]]
Body:0xc000488a40 ContentLength:-1 TransferEncoding:[chunked] Close:false
Uncompressed:false Trailer:map[] Request:0xc0000e0400 TLS:0xc0007640b0}
2020/05/15 12:21:11 [INFO] (telemetry) ending vagrant-cloud
2020/05/15 12:21:11 Deleting original artifact for build 'vmware-iso'
* Post-processor failed: Script exited with non-zero exit status:
127.Allowed exit codes are: [0]
* Post-processor failed: Error retrieving box: Resource not found!
Build 'vmware-iso' errored: 2 error(s) occurred:
* Post-processor failed: Script exited with non-zero exit status:
127.Allowed exit codes are: [0]
* Post-processor failed: Error retrieving box: Resource not found!
2020/05/15 12:21:11 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
2020/05/15 12:21:11 machine readable: vmware-iso,error []string{"2 error(s)
occurred:\n\n* Post-processor failed: Script exited with non-zero exit
status: 127.Allowed exit codes are: [0]\n* Post-processor failed: Error
retrieving box: Resource not found!"}
* Post-processor failed: Script exited with non-zero exit status:
127.Allowed exit codes are: [0]
* Post-processor failed: Error retrieving box: Resource not found!
==> Builds finished but no artifacts were created.
==> Some builds didn't complete successfully and had errors:
--> vmware-iso: 2 error(s) occurred:
* Post-processor failed: Script exited with non-zero exit status:
127.Allowed exit codes are: [0]
* Post-processor failed: Error retrieving box: Resource not found!
==> Builds finished but no artifacts were created.
2020/05/15 12:21:11 [INFO] (telemetry) Finalizing.
2020/05/15 12:21:12 waiting for all plugin processes to complete...
2020/05/15 12:21:12 /usr/local/bin/packer: plugin process exited
2020/05/15 12:21:12 /usr/local/bin/packer: plugin process exited
2020/05/15 12:21:12 [ERR] Error decoding response stream 7: EOF
2020/05/15 12:21:12 /usr/local/bin/packer: plugin process exited
2020/05/15 12:21:12 [ERR] Error decoding response stream 8: EOF
2020/05/15 12:21:12 /usr/local/bin/packer: plugin process exited
2020/05/15 12:21:12 /usr/local/bin/packer: plugin process exited
Unfortunately the example leads to an error. Why do people publish this ?
packer-post-processor-vagrant-cloud plugin: Post-Processor Vagrant Cloud
API GET: https://vagrantcloud.com/api/v1/box/cool-base-nl/testmenow20
2020/05/15 12:21:11 packer-post-processor-vagrant-cloud plugin:
Post-Processor Vagrant Cloud API Response:
2020/05/15 12:21:11 packer-post-processor-vagrant-cloud plugin:
2020/05/15 12:21:11 packer-post-processor-vagrant-cloud plugin:
&{Status:404 Not Found StatusCode:404
So I need to create the box. Like I do on the web. I create manually a box.
Then I build with packer the box and it uploads to the cloud.
Now I use the API for creating the box.
Let´s listen again to Megan:
Any post-processors only wrapped in the first set of brackets will get the
build artifact as its input.
Any post-processors inside the second set of brackets will run in order,
with the output artifact from one post-processor becoming the input
artifact to the next.
Why?
The double-bracketing doesn't make intuitive sense in a single-flow context
like yours, but it allows users to create multiple output artifacts using
different postprocessor flows from the same build artifact.
So, for example, you could take the same vmware artifact and both create a
vagrant box that you upload to vagrant cloud in one flow like you're doing
here, but then, and in another flow upload it to vsphere, and the
postprocessors wouldn't get in each other's ways.
For a little more detail on sequencing, you can see the docs at
https://www.packer.io/docs/templates/post-processors/#post-processor-definition
<https://www.google.com/url?q=https%3A%2F%2Fwww.packer.io%2Fdocs%2Ftemplates%2Fpost-processors%2F%23post-processor-definition&sa=D&sntz=1&usg=AFQjCNFnvvTO9BpBDI8bMECSTCDToTFv1Q>
"post-processors": [I read from left to right. I count from left to right
so Iám now in the first set of brackets. So i get the build artifact as
input. Well I must be wrong.
This must be the second set of brackets. because I get the build
artifact as input. [
{
"type": "shell-local",
"script": "create-cloudbox.sh"
},
{
"output": "{{ user `build_directory` }}/{{user
`box_basename`}}.{{.Provider}}.box",
"type": "vagrant"
},
{
"type": "vagrant-cloud",
"box_tag": "username/nameofmybox",
"access_token": "{{user `cloud_token`}}",
"version": "{{user `version`}}"
}
]],
===============================================================================================
So.
"post-processors": [Second set of brackets. Any pp here will run in
order, with the output artifact from one post-processor becoming the input
artifact to the next. Here is nothing.
[ post-processors only wrapped in this first set of brackets will get the
build artifact as its input.
********** My shell-local ¨post-provider¨ isn´t used as a post provider. In
that sense that is modifing the build artifact. It is only creating a
placeholde for a box.
But the vagrant-cloud preprocessor doesn´t modify a box either. It just
copies the box over. However I had good results with manually via the
webintetface creating
the placeholder for the box. And then run packer afterwards.
¨¨
{
"type": "shell-local",
"script": "create-cloudbox.sh"
},
{
"output": "{{ user `build_directory` }}/{{user
`box_basename`}}.{{.Provider}}.box",
"type": "vagrant"
},
{
"type": "vagrant-cloud",
"box_tag": "username/nameofmybox",
"access_token": "{{user `cloud_token`}}",
"version": "{{user `version`}}"
}
]],
--
This mailing list is governed under the HashiCorp Community Guidelines -
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of
those guidelines may result in your removal from this mailing list.
GitHub Issues: https://github.com/hashicorp/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups
"Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/packer-tool/62ab26c2-babe-411e-be4c-cf47ed8f1ce8%40googlegroups.com.